Skip to content

Commit 8301c96

Browse files
committed
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 #10968 (comment). Developed in #10970. Props adamsilverstein. See #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@61677 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 265fbb4 commit 8301c96

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
@@ -922,7 +922,7 @@ async function main() {
922922

923923
// Transform function to remove source map comments from all JS files
924924
const removeSourceMaps = ( content ) => {
925-
return content.replace( /\/\/# sourceMappingURL=.*$/m, '' ).trimEnd();
925+
return content.replace( /\/\/# sourceMappingURL=.*$/gm, '' ).trimEnd();
926926
};
927927

928928
if ( fs.existsSync( scriptsSrc ) ) {

0 commit comments

Comments
 (0)