Skip to content

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

@jthomaschewski

Description

@jthomaschewski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions