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

Bug: Original source files are transformed to TS with .js references #413

Open
joscha opened this issue Jun 4, 2024 · 5 comments
Open

Comments

@joscha
Copy link
Contributor

joscha commented Jun 4, 2024

are transformed TS files in the output expected to have .js references?
E.g. TS code in npm/... all have imports ending in .js, but they don't resolve anymore. Is that a JSR specialty or an issue with dnt? I can't find any information on it.

@CompeyDev
Copy link

Facing this too - is there a config or something I need to toggle?

@dsherret
Copy link
Member

E.g. TS code in npm/... all have imports ending in .js, but they don't resolve anymore.

Yeah for the Node output, they're supposed to have .js in the module specifier because in the transpiled output they'll be referencing .js files and not .ts files. When are they not resolving?

@joscha
Copy link
Contributor Author

joscha commented Jun 18, 2024

is there a config or something I need to toggle?

I think this is coming from https://github.com/denoland/wasmbuild via

dnt/mod.ts

Line 350 in 00b9ab7

writeFile(outputFilePath, outputFileText);
but I am not 100% sure. I tried to find the exact spot.

When are they not resolving?

when skipSourceOutput is false, it writes the original Typescript files into the npm module, but all their imports are transformed to reference the respective .js file. As those files are in different folders, they don't resolve, but it doesn't make immediate sense to me anyway why the original source would be transformed.

Basically if you have:
foo.ts:

import './bla.ts';

then the result of foo.ts inside the src folder in the output folder (./npm/src or similar) is:

import './bla.js';

@joscha
Copy link
Contributor Author

joscha commented Jun 18, 2024

Example here: https://gist.github.com/joscha/49e26fb6a2e3b9cbae0f1f44b5879ec6

Run:

deno run -A build.ts 0.1.0
cat npm/src/foo.ts

@joscha joscha changed the title Question: TS witj .js references Bug: Original source files are transformed to TS with .js references Jun 18, 2024
@CompeyDev
Copy link

CompeyDev commented Jun 18, 2024

The ESM output is fine with the .js imports, but the typechecking fails when it tries to import the deno shim or similar with a .js extension within an npm/src directory.

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

No branches or pull requests

3 participants