Skip to content

Suggest ESM support #327

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

Closed
AlbertAZ1992 opened this issue Aug 10, 2022 · 3 comments · Fixed by #331
Closed

Suggest ESM support #327

AlbertAZ1992 opened this issue Aug 10, 2022 · 3 comments · Fixed by #331

Comments

@AlbertAZ1992
Copy link
Contributor

domhandler has supported ESM since v5 fb55/domhandler@5582477

But html-dom-parser still imports commonjs format of domhandler with the latest version(v5.0.3) https://github.com/remarkablemark/html-dom-parser/blob/master/package.json#L45.

That will cause some TypeErrors when you try to build a package with html-dom-parser to ESM, as domhandler import as esm, the uses like require('domhandler').Text get undefined: https://github.com/remarkablemark/html-dom-parser/blob/master/lib/client/utilities.js#L9

So i think html-dom-parser should support ESM build

@remarkablemark
Copy link
Owner

Thanks for opening this issue @AlbertAZ1992! Would you be interested in opening a PR?

@AlbertAZ1992
Copy link
Contributor Author

Thanks for opening this issue @AlbertAZ1992! Would you be interested in opening a PR?

Yes. But since we cannot use ESM in CommonJS, i think that rewrite the lib/client with ESM and build to CommonJS is the only way.

@remarkablemark
Copy link
Owner

Can't we follow the same approach as html-react-parser? Only a single index.mjs was created and the require in the other files were untouched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants