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

Crash when adding/removing files in watch-mode since 0.9.5 #358

Closed
jthomaschewski opened this issue Nov 6, 2016 · 6 comments
Closed

Crash when adding/removing files in watch-mode since 0.9.5 #358

jthomaschewski opened this issue Nov 6, 2016 · 6 comments

Comments

@jthomaschewski
Copy link

jthomaschewski commented Nov 6, 2016

Since version 0.9.5 ts-loader crashes for me when adding new ts-files, deleting and maybe other cases.
I can say for sure that switching from 0.9.5/1.0.0 back to 0.9.4 fixes this issue.

Steps:

  • Run webpack in development configuration (webpack-dev-server, watch mode...)
  • Add a new *.ts file
  • Crash:
/myproject/node_modules/ts-loader/dist/after-compile.js:50
            Object.keys(instance.modifiedFiles).forEach(function (modifiedFileName) {
                   ^
TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at Compiler.<anonymous> (/myproject/node_modules/ts-loader/dist/after-compile.js:50:20)
    at next (/myproject/node_modules/meteor/webpack_webpack/node_modules/tapable/lib/Tapable.js:83:14)
....

Workaround/Fix:
Change the line https://github.com/TypeStrong/ts-loader/blob/master/src/after-compile.ts#L63 makes this error go away.

from Object.keys(instance.modifiedFiles).forEach ...
to Object.keys(instance.modifiedFiles || {}).forEach ...

I'm not sure if this is a good fix or if this might cause other troubles - so I did not create a pull request.

Environment:

Webpack 2.1.0-beta.25
Typescript 2.0.7
ts-loader 1.0.0
Webpack within Meteor (meteor-webpack)

I know that the configuration (Webpack 2.x, Webpack integrated into Meteor...) is not really supported. But as I can definitely say that this was introduced with 0.9.5 and a fix is probably as easy as the undefined check, this might still be worth reporting.

@jthomaschewski jthomaschewski changed the title Crashes since 0.9.5 Crash when adding/removing files in watch-mode since 0.9.5 Nov 6, 2016
@jthomaschewski
Copy link
Author

@johnnyreilly Sorry for accidentally posting before writing my issue. I added a description now. Maybe you could reopen it now?

Unfortunately I was not yet able to reproduce this behavior in a simple demo-repository outside of a meteor project but I was able to circumvent/fix this issue with a little undefined check.

Thanks in advance.

@johnnyreilly johnnyreilly reopened this Nov 6, 2016
@johnnyreilly
Copy link
Member

Thanks for the report!

@johnnyreilly
Copy link
Member

(and suggestion 😄 )

@johnnyreilly
Copy link
Member

Do you fancy submitting a PR with your suggested fix in? I think it's an improvement and so I say we should include it.

johnnyreilly added a commit that referenced this issue Nov 10, 2016
prevent adding/removing files crashes - fixes #358
@jthomaschewski
Copy link
Author

Thank you very much for fixing this.
I would have submitted a PR now but I see you made a lot more adjustments as I would have with my small workaround.

I'm using v1.2.0 now and didn't had any crashes since.

@johnnyreilly
Copy link
Member

No problem - to be honest the other changes are just refactoring. The actual solution is down to you - I just implemented it differently. Thanks for suggesting!

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

2 participants