@vercel/next
Advanced tools
Comparing version 3.9.3 to 3.9.4
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0; | ||
exports.removeInlinedSourceMap = exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0; | ||
const convert_source_map_1 = __importDefault(require("convert-source-map")); | ||
@@ -54,3 +54,3 @@ const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const sourcemap = await getSourceMap(content, fullFilePath); | ||
const cleanContent = convert_source_map_1.default.removeComments(content); | ||
const cleanContent = removeInlinedSourceMap(content); | ||
return sourcemap | ||
@@ -92,1 +92,33 @@ ? new webpack_sources_1.SourceMapSource(cleanContent, sourceName, sourcemap) | ||
exports.stringifySourceMap = stringifySourceMap; | ||
// Based on https://github.com/thlorenz/convert-source-map/blob/f1ed815b4edacfa9c3c5552dd342e71a3cffbb0a/index.js#L4 (MIT license) | ||
// Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data. | ||
const SOURCE_MAP_COMMENT_REGEX = /^\s*?\/[/*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/gm; | ||
function isValidSourceMapData(encoding, data) { | ||
if (encoding !== 'base64') { | ||
// Unknown encoding. I think the comment is short (e.g. URL) if it's not | ||
// base64 encoded, so let's keep it to be safe. | ||
return false; | ||
} | ||
// Remove any spaces and "*/" of the source map comment. They should not be | ||
// considered as a part of the source map data. | ||
data = data.replace(/\s/g, '').replace(/\*\//g, ''); | ||
// If it's an invalid base64 string, it must be a sourceMappingURL | ||
// inside a template literal like the follwoing. | ||
// https://github.com/webpack-contrib/style-loader/blob/16e401b17a39544d5c8ca47c9032f02e2b60d8f5/src/runtime/styleDomAPI.js#L35C1-L40C1 | ||
return /^[a-zA-Z0-9+=/]+$/.test(data); | ||
} | ||
/* | ||
* Removes sourceMappingURL comments from a string. | ||
*/ | ||
function removeInlinedSourceMap(source) { | ||
for (const m of source.matchAll(SOURCE_MAP_COMMENT_REGEX)) { | ||
// Check if it's certainly a sourceMappingURL in a comment, not a part | ||
// of JavaScript code (e.g. template literal). | ||
if (!isValidSourceMapData(m[4], m[5])) { | ||
continue; | ||
} | ||
source = source.replace(m[0], ''); | ||
} | ||
return source; | ||
} | ||
exports.removeInlinedSourceMap = removeInlinedSourceMap; |
{ | ||
"name": "@vercel/next", | ||
"version": "3.9.3", | ||
"version": "3.9.4", | ||
"license": "Apache-2.0", | ||
@@ -29,3 +29,3 @@ "main": "./dist/index", | ||
"@types/webpack-sources": "3.2.0", | ||
"@vercel/build-utils": "6.8.2", | ||
"@vercel/build-utils": "6.8.3", | ||
"@vercel/nft": "0.22.5", | ||
@@ -32,0 +32,0 @@ "@vercel/routing-utils": "2.2.1", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1715049
45224