Skip to content

Commit 135fa9e

Browse files
ellatrixdmsnell
authored andcommitted
Build: Remove all sourceMappingURL comments when copying Gutenberg files.
The `removeSourceMaps` regex in `copy-gutenberg-build.js` was missing the `/g` (global) flag, so it only stripped the **first** `//# sourceMappingURL=` comment per file. Bundled files such as the `@wordpress/vips` web worker can contain **multiple** `sourceMappingURL` references from concatenated modules (esbuild builds worker bundles with `sourcemap: true`, and when webpack bundles the module entry point it preserves comments from source modules). This causes the `verify:source-maps` build check to fail: ``` Warning: The build/wp-includes/js/dist/script-modules/vips/worker.js file must not contain a sourceMappingURL. ``` Adding the `/g` flag ensures every occurrence is removed, consistent with the existing `replace:source-maps` Grunt task which already uses the global flag. Fixes the build failure reported in WordPress#10968 (comment). Developed in WordPress#10970. Props adamsilverstein. See #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@61677 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 951e58a commit 135fa9e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/gutenberg/copy-gutenberg-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ async function main() {
890890

891891
// Transform function to remove source map comments from all JS files
892892
const removeSourceMaps = ( content ) => {
893-
return content.replace( /\/\/# sourceMappingURL=.*$/m, '' ).trimEnd();
893+
return content.replace( /\/\/# sourceMappingURL=.*$/gm, '' ).trimEnd();
894894
};
895895

896896
if ( fs.existsSync( scriptsSrc ) ) {

0 commit comments

Comments
 (0)