-
-
Notifications
You must be signed in to change notification settings - Fork 431
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 importing buildt ts files with allowJs #667
Comments
Please try upgrading to ts-loader v3 |
Sorry, I forgot to specify that this is with ts-loader v3. |
Okay - please could you supply a minimal repo that illustrates the issue? We need that so we can work on resolving the issue. Thanks. |
Here is one https://github.com/Pajn/ts-loader-repro Running
Running |
First of all: thanks for the repro - I really appreciate it. However since this isn't the same error as the one you initially reported I'm a little hesitant to take a look. I have opened it up to take a look and this looked a little strange to me:
I'm not totally sure what behaviour you would expect here as you're moving up past the root of the typescript project. I'm not totally clear what the valid behaviour would be. Do you want to tweak the project so it works by using file references in the I think if you use that approach you might be able to come up with a repo that illustrates the issue. Failing that, maybe Thanks again! |
I can probably produce a repro with the same error as well, but it might be more convoluted when taken out of context. File references does not work for us as we develop both modules simultaneously and can't reinstall the modules for every simple change. Plain Typescript deals with it without issues, so I can not see why it should not work with By the behavior and errors (without diving into the code) it seems to me that the error is that |
FWIW I think the general issue is probably connected with this part of the ts-loader code: https://github.com/TypeStrong/ts-loader/blob/master/src/servicesHost.ts#L219 Bearing in mind what you said I tried to have a quick play but I'm afraid the repro repo seems to be problematic. I get the following error when I try to
You might want to take a look and refine the repo... |
Thinking some more I wonder if this is actually the issue: https://github.com/TypeStrong/ts-loader/blob/master/src/servicesHost.ts#L187
|
I dug a bit in the code. Long story short, by changing the regex in Long story: I'll submit a PR to discuss it |
Awesome - thanks so much! I'll try and take a look tomorrow. 🌻 |
We have a subproject that is built separately so that it produces
.js
and.d.ts
files. With"allowJs": true
I get the following error when importing a module from it:TS2306: File /path/to/file.js is not a module.
This can be fixed by setting
entryFileCannotBeJs: true
but as that is going away I think this issue must be fixed first.I have not looked deeper into it but the feeling I get is that
ts-loader
prefer the.js
file over the.d.ts
and thus errors. Plain TypeScript have not errors with this setup.The text was updated successfully, but these errors were encountered: