Skip to content

fix(loader): new Error to webpack when errors occured in the loader f…#792

Merged
johnnyreilly merged 1 commit intoTypeStrong:masterfrom
linxiaowu66:master
Jun 27, 2018
Merged

fix(loader): new Error to webpack when errors occured in the loader f…#792
johnnyreilly merged 1 commit intoTypeStrong:masterfrom
linxiaowu66:master

Conversation

@linxiaowu66
Copy link
Copy Markdown

…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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

ok

@ghost
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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

@linxiaowu66
Copy link
Copy Markdown
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