-
Notifications
You must be signed in to change notification settings - Fork 3
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
Import issues in modern Node versions due to improperly declared package.json #11
Comments
Now this is a very useful issue! By the way it's not a bug because this library was mainly intended to work with Typescript and was supposed to work via umd with javascript. |
The bug label is auto-added by GitHub and I have no control over the labels. I also do consider this a bug since with certain server-side rendering implementations, ts-luxon would be directly imported on the server and not processed through a bundler which would mask this issue. I've actually originally filed this as a Remix bug here: remix-run/remix#9097 |
Interesting |
Working on this finally! Rough times... |
Published v 5.0.0-beta.1 (based on 4.6.0 that I published earlier, so we're aligned to the latest luxon developments that they haven't even published yet :D) The problem would seem solved. https://stackblitz.com/edit/stackblitz-starters-gulgmw?file=package.json,index.js Let me do some tests in the afternoon to see if it also solves the "CommonJS" problem in my other application... Then I can publish the official 5.0.0...but for now you can enjoy this beta. Thanks again for the help. |
@fire332 can I quote you in the thanks section of the readme? |
Published v5.0.0 |
Sure. Thanks for the update. |
Note that the fix in 5.0 still has the issue noted in the example where TS will allow a default import when it doesn't exist in the package. https://publint.dev/[email protected] Note how there are no TS errors in the stackblitz example but Node will complain about the default export not existing. Explanation of the issue and how to fix: https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md |
@fire332 ok since it worked in my scenario I needed to have this released. Luckily I don't need another major for this... Keep you posted. PS I already published now that I have the green light I'll mention you on next publish 😉 |
These links may be helpful: microsoft/TypeScript#54593 |
@fire332 man I can't do it.
Probably the way would be bundling with Webpack. I'm closing this for now. |
Ok I think I get it. I should rely on CJS. |
Mind if I take a crack at it? EDIT: tbh, it's probably easier to just drop support for the CJS bundle as |
@fire332 I agree that ts-luxon is intended for interop, the point is that I tried everything, including removing the umd bundle and leave it a module...it always resulted in ESM with CJS typings. If you want to give it a try you're welcome. There's really something I need to get over with that depended on the refactor being stable. But I'm open to bump directly to a pure ESM V6 if we find a way to make it working. Thanks again for your input. |
Describe the bug
ts-luxon needs to have a properly declared
exports
field inpackage.json
for Node to use the ESM bundle. Additionally, the exports need to have the correct file extension to avoid incorrect interpretation.Example:
Note that the example has this issue.
See: https://publint.dev/[email protected]
To Reproduce
https://stackblitz.com/edit/stackblitz-starters-gpzsez?file=index.js
Actual vs Expected behavior
No import errors.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: