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

Incorrect Type in package.json, Breaks Webpack 5 #201

Closed
thequailman opened this issue Dec 3, 2020 · 5 comments
Closed

Incorrect Type in package.json, Breaks Webpack 5 #201

thequailman opened this issue Dec 3, 2020 · 5 comments

Comments

@thequailman
Copy link

Hello, this repo uses the wrong type specified in the package.json:

https://github.com/commonmark/commonmark.js/blob/master/package.json#L18

Webpack thinks it's commonjs, but it uses import/export syntax and breaks the loader. See this issue for a similar repo with the same problem and a workaround until it's fixed: webpack/webpack#11597

@jgm
Copy link
Member

jgm commented Dec 3, 2020

The intent was to preserve backwards-compatibility, so the package can still be used as commonjs.
If you've got a better way to do that, let us know. I don't know much about the JS ecosystem, and the person who did the PR for modules has been unresponsive.

@jgm
Copy link
Member

jgm commented Dec 3, 2020

As you can see from bin/commonmark, you can use ESM.

@jgm
Copy link
Member

jgm commented Dec 3, 2020

See #195 -- is this a dup or a distinct issue?

@thequailman
Copy link
Author

I think if you're using import/export syntax in /lib, you have to set the package.json "type": to "module". I fixed the issue by adding this rule:

			{
			  test: /\.js/,
			  include: /commonmark[\\/]lib[\\/]/,
			  type: "javascript/auto"
			},

@jgm
Copy link
Member

jgm commented Dec 4, 2020

This should be fixed by #203

@jgm jgm closed this as completed Dec 4, 2020
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

No branches or pull requests

2 participants