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

Fix: Increase the instance version when new root files are found #955

Merged
merged 2 commits into from Jun 21, 2019

Conversation

davazp
Copy link
Contributor

@davazp davazp commented Jun 19, 2019

This is a minimal fix for #943.

When a new root file is processed, ensure that the instance version is increased.

It is an alternative to the bigger PR #945.

@davazp
Copy link
Contributor Author

davazp commented Jun 19, 2019

This fixes the problem by correctly allowing files not covered by tsconfig.json.

There is no conflict with any other option and ts-loader behaves as it used to.

@johnnyreilly, @andrewbranch

@johnnyreilly
Copy link
Member

johnnyreilly commented Jun 20, 2019

Heya, thanks for this!

It looks like this tweak may be breaking the nodeModulesMeaningfulErrorWhenImportingTs test.

Essentially with the change this code is never executed:

https://github.com/TypeStrong/ts-loader/blob/6e955861994f04943e57303f2e2beb77670d9ede/src/index.ts#L164-165

Interestingly, actually importing ts from node_modules (a feature I feel that has questionable value but that people wanted) still seems fine: https://github.com/TypeStrong/ts-loader/tree/master/test/execution-tests/allowTsInNodeModules

Can you confirm why the meaningful error message code isn't being executed now please? I've a feeling it may be valid behaviour that this is the case but I'd like to know for sure.

If there's good reasons to go with this behaviour then we should think about removing code around the meaningful error message and it's associated comparison test:

https://github.com/TypeStrong/ts-loader/tree/master/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs

But before we do that, let's be sure this is intentional. Thanks!

PS more information here:

cc @aelawson

@davazp
Copy link
Contributor Author

davazp commented Jun 20, 2019

Ok, this is interesting. It seems very similar to the bug I was trying to fix! Only that in my situation, instead of an explicit node_modules directly, I was using yarn workspaces.

I guess I can normalize the path to remove symlinks and check for node_modules as well.

@davazp davazp force-pushed the ts-fix-non-root-files branch 3 times, most recently from f53003b to 1c3464f Compare June 20, 2019 08:51
@johnnyreilly
Copy link
Member

johnnyreilly commented Jun 20, 2019

It doesn't look like your change has resolved the issue? Was it intended to?

I think my original questions still stand; is this something that we should be concerned about?

@davazp
Copy link
Contributor Author

davazp commented Jun 20, 2019

It doesn't look like your change has resolved the issue? Was it intended to?

That is strange! It works for me locally. I'll try to find out more.

I think my original questions still stand; is this something that we should be concerned about?

I think we should. My changes allow you to compile files that are under node_modules even if allowTsInNodeModules is falsed

@davazp davazp force-pushed the ts-fix-non-root-files branch 2 times, most recently from 3a8e05a to 360a6ff Compare June 20, 2019 14:10
@davazp
Copy link
Contributor Author

davazp commented Jun 20, 2019

Silly mistake. Wrong comparison... ! It worked locally because it updated the snapshot 😄

I updated the PR.

Should we also check for /node_modules/ . (for whatever separators the OS has?) . Not likely but a path like abcnode_modulesxyz would match this and be considered node_modules/. I leave it out for another PR maybe.

@johnnyreilly
Copy link
Member

Yeah - I think that's an edge case. I'm happy with how things are now I think. Do you want to update the package.json and CHANGELOG.md please?

@johnnyreilly
Copy link
Member

I'm afraid we already have 6.0.3 published... 6.0.4?

CHANGELOG.md Outdated Show resolved Hide resolved
@johnnyreilly johnnyreilly merged commit 35b1b56 into TypeStrong:master Jun 21, 2019
@johnnyreilly
Copy link
Member

Release going out now - thanks for your help!

https://github.com/TypeStrong/ts-loader/releases/tag/v6.0.4

@davazp davazp deleted the ts-fix-non-root-files branch June 21, 2019 09:38
@davazp
Copy link
Contributor Author

davazp commented Jun 21, 2019

Awesome. Thank you @johnnyreilly and @andrewbranch for your help, responsiveness and the nice test suite 🙂

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.

None yet

3 participants