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

scripts: Unknown command or entry 'index=./src/frontend/index.js' #34236

Closed
1 of 2 tasks
cpiber opened this issue Aug 23, 2021 · 3 comments · Fixed by #34264
Closed
1 of 2 tasks

scripts: Unknown command or entry 'index=./src/frontend/index.js' #34236

cpiber opened this issue Aug 23, 2021 · 3 comments · Fixed by #34264
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@cpiber
Copy link
Contributor

cpiber commented Aug 23, 2021

Description

Related to webpack v5 migration: #33818.

Using the latest @wordpress/scripts (18.0.0), building with a custom entry point is not possible (npx wp-scripts build ./src/frontent/index.js).

[webpack-cli] Unknown command or entry 'index=./src/frontend/index.js'
[webpack-cli] Run 'webpack --help' to see available commands and options

Works normally without the optional path.

Works as expected in 17.1.0.

Step-by-step reproduction instructions

  1. Install @wordpress/scripts@latest
  2. Run npx wp-scripts build <some path>

Screenshots, screen recording, code snippet

No response

Environment info

  • Ubuntu 18.04
  • Node v14.17.5

Pre-checks

  • I have searched the existing issues.
  • I have tested with all plugins deactivated except Gutenberg.
@gziolo gziolo added [Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended labels Aug 23, 2021
@gziolo
Copy link
Member

gziolo commented Aug 23, 2021

It looks like webpack 5 handles entry points differently when passed through CLI:

https://webpack.js.org/api/cli/#entry

vs

https://v4.webpack.js.org/api/cli/#usage-without-config-file

It's very likely that we can remove special handling added for webpack 4 from:

/**
* Converts a path to the entry format supported by webpack, e.g.:
* `./entry-one.js` -> `entry-one=./entry-one.js`
* `entry-two.js` -> `entry-two=./entry-two.js`
*
* @param {string} path The path provided.
*
* @return {string} The entry format supported by webpack.
*/
const pathToEntry = ( path ) => {
const entry = basename( path, '.js' );
if ( ! path.startsWith( './' ) ) {
path = './' + path;
}
return [ entry, path ].join( '=' );
};
// The following handles the support for multiple entry points in webpack, e.g.:
// `wp-scripts build one.js custom=./two.js` -> `webpack one=./one.js custom=./two.js`
webpackArgs = webpackArgs.map( ( cliArg ) => {
if (
getFileArgsFromCLI().includes( cliArg ) &&
! cliArg.includes( '=' )
) {
return pathToEntry( cliArg );
}
return cliArg;
} );

@gziolo
Copy link
Member

gziolo commented Sep 8, 2021

It looks like #34264 will fix this issue.

@gziolo
Copy link
Member

gziolo commented Sep 9, 2021

There is @wordpress/scripts v18.0.1 available with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants