Skip to content

(feat): add webpack validation error logging #1596

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

Merged
merged 4 commits into from
Feb 24, 2017
Merged

(feat): add webpack validation error logging #1596

merged 4 commits into from
Feb 24, 2017

Conversation

johann-sonntagbauer
Copy link
Contributor

@johann-sonntagbauer johann-sonntagbauer commented Feb 20, 2017

Webpack validates the configuration during setup. If there are problems detected, it will throw a validation error. The problem is, that the build and start scripts don't print the messages.

Main cause for this particular problem is when users eject and modify the webpack config.

Only valid for webpack2 builds.

fixes #1595

Error logging before this change:

$ npm run build

> [email protected] build C:\Projects\combined
> node scripts/build.js

Creating an optimized production build...
C:\Projects\combined\node_modules\webpack\lib\webpack.js:19
                throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
                ^

Error
    at webpack (C:\Projects\combined\node_modules\webpack\lib\webpack.js:19:9)
    at build (C:\Projects\combined\scripts\build.js:125:3)
    at recursive (C:\Projects\combined\scripts\build.js:72:3)
    at C:\Projects\combined\node_modules\recursive-readdir\index.js:37:14
    at FSReqWrap.oncomplete (fs.js:111:15)

Error logging after this change:

$ npm run build

> [email protected] build C:\Projects\combined
> node scripts/build.js

Creating an optimized production build...
Failed to configure webpack.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'devtoo'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack 2 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           devtoo: ...
         }
       })
     ]
 - configuration.resolve has an unknown property 'fallback'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }

@gaearon gaearon added this to the 0.10.0 milestone Feb 24, 2017
@gaearon
Copy link
Contributor

gaearon commented Feb 24, 2017

Looks reasonable. To be honest, I haven't tested but I trust this works. 😅

@gaearon gaearon merged commit 0ef9e80 into facebook:master Feb 24, 2017
@johann-sonntagbauer
Copy link
Contributor Author

@gaearon I am sorry for the code style troubles.

@gaearon
Copy link
Contributor

gaearon commented Feb 24, 2017

Hah, no worries, we should just switch to Prettier to format our code.

kst404 pushed a commit to kst404/e8e-react-scripts that referenced this pull request Mar 2, 2017
* (feat): add webpack validation error logging

* Style nit

* Style tweak

* Style nit
SpaceK33z pushed a commit to CodeYellowBV/create-react-cy-app that referenced this pull request Mar 7, 2017
* (feat): add webpack validation error logging

* Style nit

* Style tweak

* Style nit
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print webpack configuration validation errors.
3 participants