Skip to content

Comments

Build: Remove all sourceMappingURL comments when copying Gutenberg files#10970

Closed
adamsilverstein wants to merge 1 commit intoWordPress:trunkfrom
adamsilverstein:fix/remove-all-sourcemap-urls
Closed

Build: Remove all sourceMappingURL comments when copying Gutenberg files#10970
adamsilverstein wants to merge 1 commit intoWordPress:trunkfrom
adamsilverstein:fix/remove-all-sourcemap-urls

Conversation

@adamsilverstein
Copy link
Member

Summary

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).

Test plan

  • Verify the verify:source-maps build check passes with this change when the vips package is included in the Gutenberg build output
  • Confirm existing source map removal still works correctly for all other packages

🤖 Generated with Claude Code

…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>
@github-actions
Copy link

Trac Ticket Missing

This 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.

@github-actions
Copy link

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it in #10968 and it fixes the issue.

pento pushed a commit that referenced this pull request Feb 18, 2026
…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
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Feb 18, 2026
…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
@ellatrix ellatrix closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants