Skip to content

fix: support importing via ES modules#220

Closed
aminya wants to merge 2 commits intoparcel-bundler:masterfrom
aminya:esm
Closed

fix: support importing via ES modules#220
aminya wants to merge 2 commits intoparcel-bundler:masterfrom
aminya:esm

Conversation

@aminya
Copy link

@aminya aminya commented Jul 1, 2022

This allows using parcel-css from ES modules. Some build tools (e.g. Astro) require ES modules.

@aminya

This comment was marked as resolved.

}
}

export default default_export;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some of the above logic could be deduplicated with the index.js file?

import {createRequire} from 'module';
const require = createRequire(import.meta.url);

export default require('./index.js');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the reverse? Generating the old commonjs file from the mjs file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could be, but it would just be CommonJS to load the native module regardless.

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.

2 participants