-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid configuration object error when using --experimental-modules #61972
Labels
[Feature] Script Modules API
Related to the Script Modules API that adds support for native ES modules and import maps
[Type] Bug
An existing feature does not function as intended
Comments
mizan42047
added
the
[Type] Bug
An existing feature does not function as intended
label
May 24, 2024
This comment was marked as resolved.
This comment was marked as resolved.
jordesign
added
the
[Feature] Script Modules API
Related to the Script Modules API that adds support for native ES modules and import maps
label
May 26, 2024
When using
To handle this, you can extend both configs: const wordpressConfig = require('@wordpress/scripts/config/webpack.config');
function extendSharedConfig(config) {
return {
...config,
// Add shared config extensions here...
};
}
function extendScriptConfig(config) {
return {
...config,
// Add non-module config extensions here...
};
}
module.exports = (() => {
if (Array.isArray(wordpressConfig)) {
const [scriptConfig, moduleConfig] = wordpressConfig;
const extendedScriptConfig = extendSharedConfig(extendScriptConfig(scriptConfig));
const extendedModuleConfig = extendSharedConfig(moduleConfig);
return [extendedScriptConfig, extendedModuleConfig];
} else {
return extendSharedConfig(extendScriptConfig(wordpressConfig));
}
})(); |
Yeah, it works. Thank you so much @rafaucau |
@mizan42047 could you post your final webpack.config.js for reference how it turned out? Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Script Modules API
Related to the Script Modules API that adds support for native ES modules and import maps
[Type] Bug
An existing feature does not function as intended
Description
Without --experimental-modules, the configuration below runs fine:
However, when I added the --experimental-modules flag to my package.json like this:
"start": "wp-scripts start --experimental-modules"
I got the following error:
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: