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

Fix non-default ESM imports #175

Closed
wants to merge 1 commit into from
Closed

Fix non-default ESM imports #175

wants to merge 1 commit into from

Conversation

heypiotr
Copy link

esm/index.js currently does:

import nhp from '../dist/index.js'

This is importing the default export from ../dist/index.js AKA src/index.ts, which is the parse function:

export { default as parse, default } from './parse';
                           ^^^^^^^

... which means when esm/index.js later tries to do this:

export const CommentNode = nhp.CommentNode;

... nhp is actually the parse function, which means nhp.CommentNode is undefined.

@nonara
Copy link
Collaborator

nonara commented Nov 16, 2021

Thanks for your submission!

Unfortunately, ESM has caused a lot of confusion and issues for many of us. One of the primary reasons behind this is the fundamentally different way that ESM handles import / export.

The pattern we've followed to enable ESM is a standard technique, as described here: https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1

Please see this comment in a similar PR for more detail on why the syntax we've used is correct:

The thread may also help in getting it working for you. Best of luck!

@nonara nonara closed this Nov 16, 2021
@heypiotr
Copy link
Author

Oh, interesting! Thanks for sharing ❤️

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

2 participants