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

Use separate exports for ES and CommonJS modules #30

Open
wants to merge 67 commits into
base: master
Choose a base branch
from

Conversation

rejc2
Copy link

@rejc2 rejc2 commented Jan 23, 2023

Following the approach recommended in the Node.js documentation:

https://nodejs.org/api/packages.html#approach-1-use-an-es-module-wrapper

Reason for change

Currently if you import the 'wavefile' package from an ES module in Node, Node will use the CommonJS module in dist/wavefile.js and treat the object exported there as the default export.
This means that in order to get the WaveFile class, you will need to do:

import waveFileModule from 'wavefile';
const { WaveFile } = waveFileModule;

rather than the expected pattern of:

import { WaveFile } from 'wavefile';

The change in this PR re-exports WaveFile in a ESM wrapper module.

@rejc2 rejc2 force-pushed the rejc2/esm-wrapper branch from a3d3839 to fd962d8 Compare January 24, 2023 02:21
rejc2 and others added 3 commits January 23, 2023 20:22
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