-
Notifications
You must be signed in to change notification settings - Fork 363
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
Split TS declaration files are not compatible with nodenext module resolution #1019
Comments
There's an easy fix: // src/index.ts
-export * from "./foo";
+export * from "./foo.js"; Longer answer: This really isn't a Microbundle issue, but a TS issue. You'll run into this same behavior using The TS team have drawn a line in the sand and refuse to rewrite module specifiers as there's no TS features there; instead, you're supposed to use While merging declaration files could be nice, it's not without it's own complexities and it would be a move away from |
Holy moly, I read about that but still couldn't understand the fix applied to this situation.
Thanks for explaining! |
No problem, it's certainly a weird one. Using |
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output.
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output.
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output. Depends on donmccurdy/property-graph#70 and donmccurdy/KTX-Parse#55 Fixes donmccurdy#824
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output. Depends on donmccurdy/property-graph#70 and donmccurdy/KTX-Parse#55 Fixes donmccurdy#824
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output. Depends on donmccurdy/property-graph#70 and donmccurdy/KTX-Parse#55 Fixes donmccurdy#824
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output.
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output.
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output. Depends on donmccurdy/property-graph#70 and donmccurdy/KTX-Parse#55 Fixes donmccurdy#824
When importing this library in a project using moduleResolution nodenext, the types would give errors because the import paths were missing the file extension which is required for moduleResolution nodenext. Therefore we have to add .js to all imports of local files. See developit/microbundle#1019 (comment) and the issues that comment links to for some more detailed explanation of this. I also changed moduleResolution to nodenext in the tsconfig because when it's set to node, typescript won't give errors for missing file extensions which means they are easy to forget. With it set to nodenext, you will get an error if an import is missing the file extension. As far as I can see, changing this doesn't change the build output. Depends on donmccurdy/property-graph#70 and donmccurdy/KTX-Parse#55 Fixes #824
TLDR: Microbundle should output a single
.d.ts
per output module file, ornodenext
is too unstable to target at all.Background
This issue is a funky mixture of a few other issues:
nodenext
(akanode16
) uses modules: A Proposal For Module Resolution microsoft/TypeScript#50152nodenext
compat: Guidance around exports.types config when authoring in TS #990.d.ts
files for a single.*js
output: [Typescript] Typings files not concatenated? #239Reproducing
I forked the code from #239 and updated it to highlight the problem with nodenext: https://github.com/ssangervasi/microbundle-typings.
In this example, you can see:
exports.types
pointing to the module's types,dist/index.d.ts
, as suggested by microbundle's readme.tsc 4.9.4
withnodenext
. (This is the thing I want the users of my package to be able to do.)Proposed solution
My instinct is that generating multiple
.d.ts
files for a single output module is going to cause problems in general. In this case, if the build process could merge them (the same way it merges the JS into a single file), the TS resolution problem would go away. Basically reopening #239.On the other hand, TS's
moduleResolution
is madenning*, and it's possible this relative lookup will go away in later versions. Microbundle's readme could be updated to note this incompatibility for now. As far as I can tell, there isn't a way to get these split.d.ts
files to work, except maybe package.json redirects which I'm not willing to try or publish.* On par with how complex JS's dependency system is.
The text was updated successfully, but these errors were encountered: