| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6e66833 commit 58837dc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,9 +18,7 @@ const { | |||
| 18 | 18 | ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING, | |
| 19 | 19 | ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX, | |
| 20 | 20 | } = require('internal/errors').codes; | |
| 21 | - const { getOptionValue } = require('internal/options'); | ||
| 22 | 21 | const assert = require('internal/assert'); | |
| 23 | - const { Buffer } = require('buffer'); | ||
| 24 | 22 | const { | |
| 25 | 23 | getCompileCacheEntry, | |
| 26 | 24 | saveCompileCacheEntry, | |
@@ -117,26 +115,18 @@ function stripTypeScriptTypes(code, options = kEmptyObject) { | |||
| 117 | 115 | } | |
| 118 | 116 | ||
| 119 | 117 | /** | |
| 120 | - * @typedef {'strip-only' | 'transform'} TypeScriptMode | ||
| 121 | 118 | * @typedef {object} TypeScriptOptions | |
| 122 | - * @property {TypeScriptMode} mode Mode. | ||
| 123 | - * @property {boolean} sourceMap Whether to generate source maps. | ||
| 124 | 119 | * @property {string|undefined} filename Filename. | |
| 125 | 120 | */ | |
| 126 | 121 | ||
| 127 | 122 | /** | |
| 128 | - * Processes TypeScript code by stripping types or transforming. | ||
| 129 | - * Handles source maps if needed. | ||
| 123 | + * Processes TypeScript code by stripping types. | ||
| 130 | 124 | * @param {string} code TypeScript code to process. | |
| 131 | 125 | * @param {TypeScriptOptions} options The configuration object. | |
| 132 | 126 | * @returns {string} The processed code. | |
| 133 | 127 | */ | |
| 134 | 128 | function processTypeScriptCode(code, options) { | |
| 135 | - const { code: transformedCode, map } = parseTypeScript(code, options); | ||
| 136 | - | ||
| 137 | - if (map) { | ||
| 138 | - return addSourceMap(transformedCode, map); | ||
| 139 | - } | ||
| 129 | + const { code: transformedCode } = parseTypeScript(code, options); | ||
| 140 | 130 | ||
| 141 | 131 | if (options.filename) { | |
| 142 | 132 | return `${transformedCode}\n\n//# sourceURL=${options.filename}`; | |
@@ -164,8 +154,6 @@ function stripTypeScriptModuleTypes(source, filename, sourceURL) { | |||
| 164 | 154 | if (isUnderNodeModules(filename)) { | |
| 165 | 155 | throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename); | |
| 166 | 156 | } | |
| 167 | - const sourceMap = getOptionValue('--enable-source-maps'); | ||
| 168 | - | ||
| 169 | 157 | // Get a compile cache entry into the native compile cache store, | |
| 170 | 158 | // keyed by the filename. If the cache can already be loaded on disk, | |
| 171 | 159 | // cached.transpiled contains the cached string. Otherwise we should do | |
@@ -178,7 +166,6 @@ function stripTypeScriptModuleTypes(source, filename, sourceURL) { | |||
| 178 | 166 | ||
| 179 | 167 | const options = { | |
| 180 | 168 | mode: 'strip-only', | |
| 181 | - sourceMap, | ||
| 182 | 169 | filename: sourceURL ?? filename, | |
| 183 | 170 | }; | |
| 184 | 171 | ||
@@ -194,20 +181,6 @@ function stripTypeScriptModuleTypes(source, filename, sourceURL) { | |||
| 194 | 181 | return transpiled; | |
| 195 | 182 | } | |
| 196 | 183 | ||
| 197 | - /** | ||
| 198 | - * | ||
| 199 | - * @param {string} code The compiled code. | ||
| 200 | - * @param {string} sourceMap The source map. | ||
| 201 | - * @returns {string} The code with the source map attached. | ||
| 202 | - */ | ||
| 203 | - function addSourceMap(code, sourceMap) { | ||
| 204 | - // The base64 encoding should be https://datatracker.ietf.org/doc/html/rfc4648#section-4, | ||
| 205 | - // not base64url https://datatracker.ietf.org/doc/html/rfc4648#section-5. See data url | ||
| 206 | - // spec https://tools.ietf.org/html/rfc2397#section-2. | ||
| 207 | - const base64SourceMap = Buffer.from(sourceMap).toString('base64'); | ||
| 208 | - return `${code}\n\n//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`; | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | 184 | module.exports = { | |
| 212 | 185 | stripTypeScriptModuleTypes, | |
| 213 | 186 | stripTypeScriptTypes, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments