Ts-loader: TypeError: Cannot set property 'tsLoaderFileVersion' of undefined

Created on 19 Mar 2018  路  14Comments  路  Source: TypeStrong/ts-loader

Expected Behaviour

Build to work when happypackmode is not set

Actual Behaviour

Transpilation fails with following error message

ERROR in ./somefile.ts
Module build failed: TypeError: Cannot set property 'tsLoaderFileVersion' of undefined
    at successLoader (C:\sources\gitttl\gsk\MeetingWorkspace\node_modules\ts-loader\dist\index.js:47:54)
    at Object.loader (C:\sources\gitttl\gsk\MeetingWorkspace\node_modules\ts-loader\dist\index.js:21:12)

Steps to Reproduce the Problem

Have a project with webpack 3, ts-loader@latest, and happypackmode not set.

Location of a Minimal Repository that Demonstrates the Issue.

Most helpful comment

Same here, Webpack 3.8.1, I had to revert back to v3.3.1 in order to get this resolved.

Also note that ts-loader v4 and above does not support Webpack 3 as mentioned in v4 release notes.

All 14 comments

Same here, Webpack 3.8.1, I had to revert back to v3.3.1 in order to get this resolved.

Also note that ts-loader v4 and above does not support Webpack 3 as mentioned in v4 release notes.

Yep - ts-loader 4 supports webpack 4. If you're on webpack 3 then run with ts-loader 3.x. I'm going to leave this open for visibility for a while, but there is no issue with ts-loader.

does this mean I should update this PR to also include a comprehensive error message? https://github.com/TypeStrong/ts-loader/pull/749

If there was a reliable way to programmatically extract the webpack version number I'd happily use that to trigger a "not compatible" message. Alas I don't think that's possible. Unless you know otherwise?

well one way would be to read the version of the package.json of the webpack module (the one installed, not the package.json of the current project)
maybe there's something like that in the webpack api, but I don't know it well enough.
If you look at my PR, anything without the property I was adding defensive programming for it webpack <4 so maybe instead of version checking only a capability checking could be implemented?

If there's a simple (non-hacky) way to reliably test the webpack version I'm open to adding a "your webpack version is not supported - use webpack 4 or and older version of ts-loader". Otherwise I think it's best left as is.

This was intentionally a breaking changes release and TBH people should take a look at release notes if they are hoping to make a major version bump. Not trying to be difficult. Just trying to be a good semver citizen.

agree 200% on the semver, I didn't do my homework properly before upgrading (lots of deps to upgrade).
I do believe however that's it's always better to have meaningful error messages.
Do you consider the "reading webpack's package.json version" option to be hacky?

Uh.... It should work reliably. But it slightly gives me an icky feeling. Hmmmm. Not totally sure to be honest.

Any fix for this ?
Running with following configuration :

"ts-loader": "^4.3.0",
"webpack": "^4.10.2",

Edit : After downgrading ts-loader to v3.5.0, it is working.
@johnnyreilly Can you look into it ?

I've the same problem

"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"webpack": "^4.16.1"

To re-iterate what was said earlier: ts-loader 4 supports webpack 4. If you're on webpack 3 then run with ts-loader 3.x. AFAIK there is no issue with ts-loader.

Sorry for this, but I'm using webpack version 4.16.1 as mentioned in my first post.

% webpack --version
4.16.1

```json
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"webpack": "^4.16.1"
````

I'm using nuxt, maybe this the problem. I'll check that out next week.

@johnnyreilly why is this issue closed? I am myself having these versions

"ts-loader": "^4.3.0",
"typescript": "^2.9.1",
 "webpack": "^4.16.0",

and actual versions are

ts-loader: 4.5.0,
typescript: 2.9.2,
webpack: 4.16.5

and still it is not working. I guess this should be reopened and fixed or atleast be tagged as a bug ??

It turns out that the bug was in somehow related to nuxt. I've switch to nuxt-edge and now it's working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piotr-oles picture piotr-oles  路  5Comments

arcanis picture arcanis  路  5Comments

konpikwastaken picture konpikwastaken  路  4Comments

atrauzzi picture atrauzzi  路  5Comments

piernik picture piernik  路  7Comments