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(loader): new Error to webpack when errors occured in the loader f… #792

Merged
merged 1 commit into from
Jun 27, 2018
Merged

Conversation

linxiaowu66
Copy link

…unction

When using callback(instanceOrError.error) to throw error, webpack will print :

NonErrorEmittedError: (Emitted value instead of an instance of Error) [object Object]
    at runLoaders (/Users/linxiaowu/SourceCode/eno/node_modules/webpack/lib/NormalModule.js:300:13)
    at /Users/linxiaowu/SourceCode/eno/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /Users/linxiaowu/SourceCode/eno/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/Users/linxiaowu/SourceCode/eno/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at Object.loader (/Users/linxiaowu/SourceCode/eno/node_modules/ts-loader/dist/index.js:19:9)

This way can not show the error message explicitly. So I change the returning value when error.

new Error(instanceOrError.error.message)

@johnnyreilly
Copy link
Member

johnnyreilly commented Jun 12, 2018

What does the error message look like with your change? (Obviously it depends on the particular error!)

@linxiaowu66
Copy link
Author

@johnnyreilly

Error just like that:

{ message: '\u001b[31mA file specified in tsconfig.json could not be found: /Users/linxiaowu/SourceCode/eno/types/index.d.ts\u001b[39m',
  location: undefined,
  file: '/Users/linxiaowu/SourceCode/eno/types/index.d.ts',
  loaderSource: 'ts-loader' }

Even though we had not this error, the error info can not be printed in the console

@johnnyreilly
Copy link
Member

Seems reasonable. I'm currently busy with a few things. When they're resolved I'll take a proper look at this.

@linxiaowu66
Copy link
Author

ok

@ghost
Copy link

ghost commented Jun 21, 2018

I got the same error starting a new project and forgetting to install typescript locally. I temporarily patched index.js with @linxiaowu66 fix and it worked. I guess it will take a more generic fix, maybe stringify the error object?

@johnnyreilly
Copy link
Member

@systemmetaphor are you suggesting a different fix or keeping the current suggestion?

@johnnyreilly johnnyreilly merged commit 3c26aea into TypeStrong:master Jun 27, 2018
@johnnyreilly
Copy link
Member

Going to roll with this I think - it's slightly simpler and... it was first 😄

@linxiaowu66
Copy link
Author

😂

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

Successfully merging this pull request may close these issues.

2 participants