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

Distribute package as both ESM and CJS #25

Merged
merged 1 commit into from
May 5, 2024
Merged

Distribute package as both ESM and CJS #25

merged 1 commit into from
May 5, 2024

Conversation

zidhuss
Copy link
Contributor

@zidhuss zidhuss commented Feb 6, 2024

  • Verified compatibility and non-breaking changes with the example project.

Description

This PR introduces dual module support for kysely-d1, enabling it to export as both ESM and CommonJS modules. This enhancement is in line with the current module strategy adopted by kysely.

Before and After Impact

Previously, when importing kysely-d1 alongside kysely in a project that prefers ESM, kysely-d1 would still import the CJS version of kysely, leading to inefficiencies and a larger bundle size. The dependency tree prior to this change is illustrated below:

Before ESM and CJS Support

With the introduction of both ESM and CJS exports, projects can now import the ESM version of kysely, optimizing the bundle size and improving loading times. The updated dependency tree, showcasing the more efficient structure, is shown here:

After ESM and CJS Support

This change has led to a 60% reduction in the size of kysely within the bundle, decreasing from 286KB to 114KB.

@johnpyp
Copy link

johnpyp commented Apr 6, 2024

Bump, this is affecting me as well.

@aidenwallis could this PR be merged?

@aidenwallis aidenwallis merged commit 1cabfec into aidenwallis:main May 5, 2024
@zidhuss zidhuss deleted the esm branch May 5, 2024 10:44
@ekcom
Copy link

ekcom commented Aug 16, 2024

Are there plans to make a new release so that I can use these changes in npm?

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.

4 participants