Skip to content
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

wp-scripts: using --experimental-modules causes TypeError: config.plugins is not iterable when webpack.config.js is extending plugins. #60537

Open
nextgenthemes opened this issue Apr 7, 2024 · 0 comments
Labels
Needs Testing Needs further testing to be confirmed. [Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@nextgenthemes
Copy link

Description

Reduced webpack.config.js. Works perfectly fine without --experimental-modules

const WebpackNotifierPlugin = require( 'webpack-notifier' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );

const config = defaultConfig;

config.plugins = [ ...config.plugins, new WebpackNotifierPlugin( { onlyOnError: true } ) ];

module.exports = config;

commandline:

wp-scripts build --experimental-modules --webpack-copy-php --webpack-src-dir=plugins/nextgenthemes-blocks/src --output-path=plugins/nextgenthemes-blocks/build

[webpack-cli] Failed to load '/u/websites/webpack.config.js' config
[webpack-cli] TypeError: config.plugins is not iterable
    at Object.<anonymous> (/u/websites/webpack.config.js:6:30)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at WebpackCLI.tryRequireThenImport (/u/websites/node_modules/webpack-cli/lib/webpack-cli.js:223:30)
    at loadConfigByPath (/u/websites/node_modules/webpack-cli/lib/webpack-cli.js:1406:38)
    at WebpackCLI.loadConfig (/u/websites/node_modules/webpack-cli/lib/webpack-cli.js:1515:44)

Step-by-step reproduction instructions

  1. use webpack.config.js to extend plugins
  2. run wp-scripts

Screenshots, screen recording, code snippet

No response

Environment info

@wordpress/scripts@27.6.0

node -v
v21.7.2

npm -v
10.5.0

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

@nextgenthemes nextgenthemes added the [Type] Bug An existing feature does not function as intended label Apr 7, 2024
@nextgenthemes nextgenthemes changed the title Using --experimental-modules causes TypeError: config.plugins is not iterable when webpack.config.js is extending plugins. wp-scripts: using --experimental-modules causes TypeError: config.plugins is not iterable when webpack.config.js is extending plugins. Apr 7, 2024
@t-hamano t-hamano added [Package] Scripts /packages/scripts Needs Testing Needs further testing to be confirmed. labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants