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

Improved ESM Support #603

Merged
merged 1 commit into from Jan 1, 2020
Merged

Improved ESM Support #603

merged 1 commit into from Jan 1, 2020

Conversation

LJNeon
Copy link
Contributor

@LJNeon LJNeon commented Jan 1, 2020

ECMAScript modules can import CommonJS modules, however this is simply as a default export and can't take advantage of named exports. This PR adds named exports to Eris when imported by an ECMAScript module.

  • CommonJS support for Node.js 8+ (and for obsolete versions before 8).
  • Full ECMAScript support for Node.js 12+ (using an eris/esm import and/or flags).
  • Forwards compatibility with future versions of Node.js using conditional exports.

One side effect of this PR is that it prevents using subpath imports. Whether this is a good thing or not is worth discussion, but it causes no problems with normal use nor with TypeScript. An alternative method could be using the eris/esm.mjs subpath import, as while it's less appealing and lacks forwards compatibility it doesn't prevent use of subpaths.

@abalabahaha abalabahaha merged commit 3fd70d4 into abalabahaha:dev Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants