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: exports file extensions #1

Merged
merged 4 commits into from
Jul 10, 2024
Merged

fix: exports file extensions #1

merged 4 commits into from
Jul 10, 2024

Conversation

serkodev
Copy link
Contributor

@serkodev serkodev commented Jul 10, 2024

Changes

  • Rename index.cjs.js, index.esm.js to index.cjs and index.mjs
  • Update version and links from README

This changes follow the official document of Node.js for .mjs and .cjs file extension to let Node to interpret the package is an ES module or CJS.

Authors can tell Node.js to interpret JavaScript as an ES module via the .mjs file extension, the package.json "type" field with a value "module", the --input-type flag with a value of "module", or the --experimental-default-type flag with a value of "module". These are explicit markers of code being intended to run as an ES module.

Inversely, authors can tell Node.js to interpret JavaScript as CommonJS via the .cjs file extension, the package.json "type" field with a value "commonjs", the --input-type flag with a value of "commonjs", or the --experimental-default-type flag with a value of "commonjs".

Reference

Fix

It can fix the following errors from Node.js build.

ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and './node_modules/is-apng/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

@vHeemstra vHeemstra merged commit d2cd735 into vHeemstra:main Jul 10, 2024
3 checks passed
@vHeemstra
Copy link
Owner

@serkodev Thank you for your PR 👍

@serkodev serkodev deleted the fix/exports-file-ext branch July 10, 2024 15:00
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.

2 participants