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

Fix displaying third party webpack plugins errors #5137

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

Fer0x
Copy link
Contributor

@Fer0x Fer0x commented Sep 27, 2018

Some third party webpack plugins can generate custom single-line compiler errors without stacktrace.

For example with html-webpack-plugin I got following error as formatMessage argument:

'Template execution failed: TypeError: Cannot read property \'main\' of undefined' 

As fast solution I propose to add empty line to avoid big changes in formatMessage logic.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@Timer
Copy link
Contributor

Timer commented Sep 27, 2018

Can you please give us a reproducing case that triggers this exact error? What exactly happens?

@Timer Timer added this to the 2.0.0 milestone Sep 27, 2018
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@Fer0x
Copy link
Contributor Author

Fer0x commented Sep 27, 2018

@Timer
I have ejected react-scripts and now I try to upgrade to 2.x version.
I use custom html template where I use this line:

var scriptSrc = '<%= htmlWebpackPlugin.files.chunks.main.entry %>';

By some reasons files.chunks is not defined, but I can't see this error, instead I got following error:

  if (lines[1].indexOf(moduleWarningPrefix) === 0) {
               ^

TypeError: Cannot read property 'indexOf' of undefined
    at formatMessage (/Users/myproject/node_modules/react-dev-utils/formatWebpackMessages.js:44:16)
    at /Users/myproject/node_modules/react-dev-utils/formatWebpackMessages.js:169:12
    at Array.map (<anonymous>)
    at formatWebpackMessages (/Users/myproject/node_modules/react-dev-utils/formatWebpackMessages.js:168:37)
    at compiler.run (/Users/myproject/scripts/build.js:126:24)
    at finalCallback (/Users/myproject/node_modules/webpack/lib/Compiler.js:204:39)
    at hooks.done.callAsync.err (/Users/myproject/node_modules/webpack/lib/Compiler.js:253:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/myproject/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/myproject/node_modules/tapable/lib/Hook.js:154:20)
    at emitRecords.err (/Users/myproject/node_modules/webpack/lib/Compiler.js:251:22)
    at Compiler.emitRecords (/Users/myproject/node_modules/webpack/lib/Compiler.js:366:39)
    at emitAssets.err (/Users/myproject/node_modules/webpack/lib/Compiler.js:245:10)
    at hooks.afterEmit.callAsync.err (/Users/myproject/node_modules/webpack/lib/Compiler.js:352:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/myproject/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/myproject/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEach.err (/Users/myproject/node_modules/webpack/lib/Compiler.js:349:27)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@Timer
Copy link
Contributor

Timer commented Sep 27, 2018

Excellent. Thank you.

@Timer Timer merged commit be8f9da into facebook:master Sep 27, 2018
@Fer0x Fer0x deleted the fix-format-webpack-messages branch October 2, 2018 10:11
@lock lock bot locked and limited conversation to collaborators Jan 19, 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.

3 participants