Build: Remove all sourceMappingURL comments when copying Gutenberg files#10970
Build: Remove all sourceMappingURL comments when copying Gutenberg files#10970adamsilverstein wants to merge 1 commit intoWordPress:trunkfrom
Conversation
…les. The `removeSourceMaps` regex was missing the `/g` (global) flag, so it only stripped the first `sourceMappingURL` comment per file. Bundled files such as the vips web worker can contain multiple sourceMappingURL references from concatenated modules, causing the `verify:source-maps` build check to fail. Adding the `/g` flag ensures every occurrence is removed, consistent with the existing `replace:source-maps` Grunt task which already uses the global flag. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…les. 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
…les. 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/wordpress-develop#10968 (comment). Developed in WordPress/wordpress-develop#10970. Props adamsilverstein. See #64393. Built from https://develop.svn.wordpress.org/trunk@61677 git-svn-id: http://core.svn.wordpress.org/trunk@60985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Summary
The
removeSourceMapsregex incopy-gutenberg-build.jswas missing the/g(global) flag, so it only stripped the first//# sourceMappingURL=comment per file.Bundled files such as the
@wordpress/vipsweb worker can contain multiplesourceMappingURLreferences from concatenated modules (esbuild builds worker bundles withsourcemap: true, and when webpack bundles the module entry point it preserves comments from source modules). This causes theverify:source-mapsbuild check to fail:Adding the
/gflag ensures every occurrence is removed, consistent with the existingreplace:source-mapsGrunt task which already uses the global flag.Fixes the build failure reported in #10968 (comment).
Test plan
verify:source-mapsbuild check passes with this change when the vips package is included in the Gutenberg build output🤖 Generated with Claude Code