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

Error when upgrading ts-loader #1638

Closed
michaeltford opened this issue Nov 13, 2023 · 8 comments · Fixed by #1639
Closed

Error when upgrading ts-loader #1638

michaeltford opened this issue Nov 13, 2023 · 8 comments · Fixed by #1639

Comments

@michaeltford
Copy link

I now get a null pointer exception

mappings: inputSourceMap.mappings,

This is because my prod build is not generating source maps and somehow the inputSourceMap is null (I am not setting it). The following code checks for undefined but not null.

If I change the following

https://github.com/TypeStrong/ts-loader/blob/9315855cd6f87883b137fc762da02f99a7842f46/src/index.ts#L152C3-L152C3

if (sourceMap === undefined || inputSourceMap === undefined) { callback(null, output, sourceMap); return; }
to
if (!sourceMap || !inputSourceMap) { callback(null, output, sourceMap); return; }
everything works as expected.

@johnnyreilly
Copy link
Member

johnnyreilly commented Nov 13, 2023

What are the false-y values being passed that are triggering this? '' ? null? Also what is the nature of your upgrade?

@michaeltford
Copy link
Author

michaeltford commented Nov 13, 2023

John

thank you for the very quick response.

falsey value is null.
I did yarn upgrade ts-loader (from version 8.x? to 9.5.0).

TLDR

Sorry for the obtuse problem statement. I don't fully understand. I have a repo (I will publish the source in the next few weeks) that uses the create react template to generate a typescript project (so most of the code is a blackbox to me.) I did a yarn upgrade to ts-loader (and a few other packages) and I started getting an error. After several hours I figured out that ts-loader was throwing a null pointer exception because somehow the inputSourceMap is null (I honestly don't know where it's coming from but I suspect it's either from babel-loader or perhaps I have a tsconfig setting that is invalid?). This only happens with the ts-loader > 8.

{ test: /\.(ts|tsx|jsx|ts)$/, use: ["babel-loader", "ts-loader"], exclude: /node_modules/, },

The 'simple' solution (and maybe correct?) seemed to be to allow for the inputs to be falsy and not just check undefined.

@johnnyreilly
Copy link
Member

Sure, but are you able to confirm the nature of the false-y values that triggers this? '' ? null?

It's the first time this has been reported. Also are you chaining loaders?

@michaeltford
Copy link
Author

The inputSourceMap value is null. I am not sure who is setting it. (I assume it's the babel loader as I am not deliberately)
Yes, but the only loader before ts-loader is babel-loader (see in comments above.

It is possible there is an issue in my config but I don't know where it could be.

My question is should false-y values (or at least null) be supported as a valid inputtype? I would think so since you support undefined.

@johnnyreilly
Copy link
Member

Okay so I'm pretty sure the last release introduced the issue: #1626

I think inputSourceMap should have a false-y check

@michaeltford
Copy link
Author

Thanks John

@johnnyreilly
Copy link
Member

no worries - thanks for helping diagnose an issue!

@johnnyreilly
Copy link
Member

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 a pull request may close this issue.

2 participants