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

chore: set type to module in package.json #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vursen
Copy link

@vursen vursen commented Jan 25, 2022

The type property of package.json may be used by frontend tooling (e.g Webpack, Vite) in determining whether the package's entry point is a CJS or ES module. If no property is specified, the entry point may be treated as a CJS module. As an illustration, here is a warning that Vite shows when you import the construct-style-sheets polyfill:

construct-style-sheets-polyfill doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

This PR explicitly sets the type property to module to avoid possible misinterpretation.

Related to vaadin/flow#12574

@Lodin
Copy link
Collaborator

Lodin commented Jan 28, 2022

Unfortunately, that doesn't seem possible since it breaks all the configuration for Rollup and Karma. While Rollup can be fixed by migrating to ES2015+, Karma doesn't allow it since it doesn't support ESM.

The only choice I can see is to provide additional .mjs file that is described in exports field of package.json. That would fix the Vite issue (and issue for all the modern development stack) along with preserving the current configuration.

I'm going to take care of it.

@Lodin Lodin mentioned this pull request Jan 31, 2022
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