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

The esm files inside dist/es6 folder should end with .mjs #178

Open
viceice opened this issue Mar 19, 2024 · 4 comments
Open

The esm files inside dist/es6 folder should end with .mjs #178

viceice opened this issue Mar 19, 2024 · 4 comments
Labels
common Includes: Common queries, bug and features

Comments

@viceice
Copy link
Contributor

viceice commented Mar 19, 2024

The esm files inside dist/es6 folder should end with .mjs, otherwise those files are not correctly resolved by test runner, because they assume cjs by default.

Alternate is to add a simple package.json:

{ "type": "module" }

so nodejs based resolvers know that those files are esm.

@viceice viceice changed the title The esm files dist/es6 folder should end with .mjs The esm files inside dist/es6 folder should end with .mjs Mar 19, 2024
@viceice
Copy link
Contributor Author

viceice commented Mar 19, 2024

maybe better add "type": "module" to the root package.json and add cjs extension to the umd files.

@gsumankumar gsumankumar added the common Includes: Common queries, bug and features label Mar 26, 2024
@Mohamed7Imran
Copy link

Hi Viceice,

Thank you for sharing your concern with us. We've carefully considered your feedback regarding the file extensions within the dist/es6 folder.

Based on your concern, we'd like to provide some insight into our implementation approach. Our components are designed to support multiple targets, accommodating both ES5 and ES6 specifications. After careful consideration, when changing the module's extension to (.mjs), we may face potential compatibility issues that arise with older versions of Node.js. Specifically, Node.js version 11 and earlier may encounter challenges with the use of ES6 modules (.mjs files). In such cases, adhering to CommonJS modules (.js files) is the best way for us to provide optimal stability and compatibility for our packages across different specifications.

Please feel free to reach out if you have any further concerns.

Best regards,
Mohamed

@viceice
Copy link
Contributor Author

viceice commented May 2, 2024

ok, alternatively add a package.json with this content to the es6 folder:

{ "type": "module" }

this will inform newer nodejs versions that those files are esm instead of commonjs files

@Mohamed7Imran
Copy link

Hi Viceice,

Thank you for getting back to us.

We appreciate your suggestion regarding adding { "type": "module" } to the package.json file in the es6 folder to indicate that the files are ECMAScript Modules (ESM). We value your input.

However, we need to consider potential compatibility issues with our packages in older versions of Node.js, particularly versions 11 and earlier. Before Node.js version 12, full support for ECMAScript Modules (ESM) was not available. While Node.js 12 introduced experimental support for ESM, it only became fully stable in Node.js 13 and later versions. Older versions of Node.js may not properly interpret the type: "module" declaration in the package.json and could encounter issues when executing the ES modules.

Given that our components need to support a wide range of Node.js versions, including older ones, it's crucial for us to consider the potential impact of using ECMAScript Modules (ESM) across different environments.

If you have any further concerns or questions, please don't hesitate to reach out to us. We're here to help!

Best regards,
Mohamed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Includes: Common queries, bug and features
Projects
None yet
Development

No branches or pull requests

3 participants