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

Webpack 5 does not return compiler object with callback #2153

Open
KilianB opened this issue Aug 28, 2023 · 0 comments
Open

Webpack 5 does not return compiler object with callback #2153

KilianB opened this issue Aug 28, 2023 · 0 comments

Comments

@KilianB
Copy link

KilianB commented Aug 28, 2023

Current behavior

Attempting to run the build command fails with webpack 5.88.2 fails with the following error message:

TypeError: Cannot read properties of null (reading 'options')
TypeError: Cannot read properties of null (reading 'options')
at commandBuild (G:\git\react-date-range\node_modules\react-styleguidist\lib\bin\styleguidist.js:115:42)

The exact same issue has been reported and closed here: identical to the issues #1786 && #2143 even though it still is present with the most current version

According to the webpack docs a compiler object is not returned with a callback: https://webpack.js.org/api/node
The issue can temporarily fixed by modifying the files in the bin directory:

return webpack(makeWebpackConfig(config, 'production'), (err, stats) => {

Get rid of the callback:

function build(config) {
  const webpackWithConfig =  (0, _webpack.default)((0, _makeWebpackConfig.default)(config, 'production'));
  return webpackWithConfig;
}

and move the callback to the run command:
`
/lib/bin/styleguidist.js>commandBuild

  const compiler = build(config);

  compiler.run( err => {
    if (err) {
      console.error(err);
      process.exit(1);
    } else if (config.printBuildInstructions) {
      config.printBuildInstructions(config);
    } else {
      printBuildInstructions(config);
    }
  });
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

No branches or pull requests

1 participant