Skip to content

.js file extensions missing in imports in ccf-app package #2446

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
letmaik opened this issue Apr 9, 2021 · 0 comments · Fixed by #2447
Closed

.js file extensions missing in imports in ccf-app package #2446

letmaik opened this issue Apr 9, 2021 · 0 comments · Fixed by #2447
Labels

Comments

@letmaik
Copy link
Member

letmaik commented Apr 9, 2021

The TypeScript compiler does not add .js to import paths when it transpiles files, which in my opinion is a bug but is declared as by-design from the TypeScript team. This can be an issue depending on how exactly the package is consumed (outside TypeScript, which bundler etc.). See also https://stackoverflow.com/q/62619058.

The proposed solution in the linked issue above is to add .js to imports in source code. TypeScript apparently knows to look for the .ts file if it sees .js...

I found this which at least is one more reference:
https://blog.logrocket.com/publishing-node-modules-typescript-es-modules/

Note that this is specifically for libraries and not for applications. The latter are processed with a bundler, in our case rollup (see forum sample), which does add the .js extensions automatically when generating output files. But using a bundler for things that shouldn't be bundled or tree-shaken doesn't make much sense and would only complicate things.

It's all a bit sad but I think I'll just go ahead and add the extensions together with a new DEVELOPMENT.md under js/ccf-app explaining it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant