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

Optimize configuration for ESM exports (entry points for cjs / esm / typescript) #212

Merged
merged 2 commits into from Jan 30, 2023
Merged

Optimize configuration for ESM exports (entry points for cjs / esm / typescript) #212

merged 2 commits into from Jan 30, 2023

Conversation

michaelwittwer
Copy link

Optimise configuration for ESM exports (entry points for cjs: require / esm: import and also typescript: types)

BREAKING CHANGE: Imports from esm subpaths must be replaced by the non-esm path, since the runtime will pick the correct entry point depending on package.json#type property (commonjs vs. module).

Before: import {} from 'date-fns-tz/esm/format' -> after: import {} form 'date-fns-tz/format'

This superseeds the existing PR (#211 ) with additional configuration for types field.


Motivation: I was not able to use date-fns-tz with esm and jest without this patch being applied.

…d also typings)

BREAKING CHANGE: Imports from esm subpaths must be replaced by the non-esm path (e.g. date-fns-tz/esm/format -> date-fns-tz/format) since the runtime will pick the correct entry point depending on type property (commonjs vs. esm).
@michaelwittwer
Copy link
Author

@marnusw The test introduced in #169 seems to fail. I don't think this has something todo with my changes. Maybe @zkruw can help out, since he worked on the PR. Thanks for any help.

@michaelwittwer
Copy link
Author

@marnusw Happy new Year. Any chance you could merge this back any time soon? There is still the open task about the failing test.

@macstr1k3r
Copy link

@marnusw Another interested party here.

There's also an option to make this a non-breaking change ( to keep the "import from /esm if you want ESM code" philosophy). cc @michaelwittwer

We can just add the explicit typings to the /esm exports.

@marnusw
Copy link
Owner

marnusw commented Jan 24, 2023

@michaelwittwer I am finally taking a look at this, and it looks good. I'll see what else can be included in v1, and then I'll release v2 with this breaking change. It might still be a day or so though.

@marnusw marnusw merged commit 7b83b92 into marnusw:master Jan 30, 2023
@marnusw
Copy link
Owner

marnusw commented Jan 30, 2023

Released in v2.0.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 this pull request may close these issues.

None yet

3 participants