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

Generator not compatible with "type": "module". #80

Closed
mrnossiom opened this issue Sep 4, 2021 · 3 comments · Fixed by #81
Closed

Generator not compatible with "type": "module". #80

mrnossiom opened this issue Sep 4, 2021 · 3 comments · Fixed by #81

Comments

@mrnossiom
Copy link
Contributor

Hello Ivan,

I switched to full ESM modules and everything works except the generated file i18n-util.ts.

The import statement isn't compatible with ESM, since it imports without the .js extension and tries to import a folder directly.

Maybe there is a way to add support via a flag. (like esmSupport)

Something like this at https://github.com/ivanhofer/typesafe-i18n/blob/main/packages/generator/src/files/generate-util.ts#L114

- import { initFormatters } from './${formattersTemplatePath}'
+ import { initFormatters } from './${formattersTemplatePath}${esmSupport ? '.js' : ''}'

I can make a pull request if you accept with all necessary types and code changes.

I'm at your disposal for any questions

MrNossiom
Thanks

@mrnossiom
Copy link
Contributor Author

This might be a duplicate of #71, but I wanted to create my own issue.

@ivanhofer
Copy link
Owner

Hi @mrnossiom,
sounds like a good solution! You can create a PR if you like.
I'm not so sure about #71, but we will see once the imports are updated

ivanhofer added a commit that referenced this issue Sep 15, 2021
* fix: add flag for esm support

Fix: #80

* docs: add documentation for esm support flag

* fix: remove space in import and modify README at types part

* test: add tests for esmImports flag

* refactor: change the flag esmSupport to esmImports

* checkout PR

* update changelog

* refactor(generator): add a relativeFileImportPath function

* test: add the tests for esmImports flag

* improve esmImports docs

Co-authored-by: Ivan Hofer <ivan.hofer@outlook.com>
@ivanhofer
Copy link
Owner

Fixed in version 2.39.0

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 a pull request may close this issue.

2 participants