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

Add modern entry point for npm package #4191

Merged
merged 1 commit into from Feb 2, 2021

Conversation

yyx990803
Copy link
Contributor

Many JavaScript bundlers nowadays support native ES modules syntax. In fact, ES modules syntax is preferred it is easier to statically analyze and allows tree-shaking to reduce bundle size.

Modern native ESM dev servers like vite or snowpack can also consume the native ESM version of the Phoenix client directly without having to convert it from cjs back to ESM again! However, this is only possible if the Phoenix package specifies the entry point to the file using modern syntax.

This PR adds:

  • The module field: de-facto standard supported by almost all ESM-supporting bundlers.
  • The exports field: as specified by Node.js. Many modern bundlers are also converging on using this field to conditionally resolve package entry points.

@Gazler
Copy link
Member

Gazler commented Feb 2, 2021

Thanks <3

@ohmree
Copy link

ohmree commented Jun 4, 2021

This commit doesn't seem to be included in 1.5.9, is that on purpose?
(Maybe for the same reason the sister-commit got reverted in LiveView?)

ATM Phoenix and LiveView are broken with Vite and while the error is too cryptic for me to understand I think there's a pretty good chance it has to do with this.

And even if this isn't the cause of my error (something about an undefined e in phoenix.js), with the proposed fixes I think phoenix.js should be debuggable in the browser, allowing me to pinpoint the error.

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