Skip to content

add .mjs to supported extensions#39

Merged
retlehs merged 1 commit intoroots:mainfrom
csorrentino:add-mjs-supported-extension
Mar 24, 2026
Merged

add .mjs to supported extensions#39
retlehs merged 1 commit intoroots:mainfrom
csorrentino:add-mjs-supported-extension

Conversation

@csorrentino
Copy link
Contributor

This PR adds .mjs to the default SUPPORTED_EXTENSIONS. Wordpress packages like @wordpress/icons switched to .mjs for their builds in a recent version.

The plugin's transform hook skips .mjs files, so the @wordpress/primitives imports inside @wordpress/icons are never rewritten to use wp.primitives globals.

The problem can easily be replicated using a fresh Radicle project because @wordpress/icons is used in a few of the included blocks. Without adding .mjs as a supported extension the browser fails with:

Uncaught TypeError: Failed to resolve module specifier "@wordpress/primitives". 
Relative references must start with either "/", "./", or "../".

Because wordpress packages seem to be moving to using .mjs extensions, I thought this would be a helpful default, but this can also be easily solved at the project level by adding the extension to the vite.config.js

Copy link
Member

@retlehs retlehs left a comment

Choose a reason for hiding this comment

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

Thanks for finding this and for the PR!

@retlehs retlehs merged commit 24d53dd into roots:main Mar 24, 2026
3 checks passed
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