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: remove ESM package.json declaration (fixes 'Element' is not exported from '@prismicio/richtext') #122

Merged
merged 1 commit into from Feb 5, 2022

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Feb 5, 2022

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR removes the explicit ES Module declaration by removing "type": "module" from package.json.

Declaring the package as an ES Module has caused issues in the following circumstances:

  • Next.js on Vercel: The entry file must use the .mjs extension to resolve correctly during server-rendered requests. This causes issues in build systems that do not recognize .mjs (e.g. Create React App). This only happens when deployed to Vercel in production. (See Prismic preview crashing in Next.js production with 500 error #108)
  • Create React App 4: .mjs files are unsupported. It works with a .js file extension, which breaks Next.js support.
  • Create React App 5: .mjs with "type": "module" is supported, but breaks backwards compatibility with CRA 4.

The most straightforward solution that ensures everything works out-of-the-box is to remove "type": "module" from package.json. When the ecosystem is more aligned behind ESM, we can restore it to a proper ES Module.

Fixes #117

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🙃

@codecov-commenter
Copy link

Codecov Report

Merging #122 (1b16476) into master (27c502f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #122   +/-   ##
=======================================
  Coverage   92.25%   92.25%           
=======================================
  Files          16       16           
  Lines         271      271           
  Branches       60       60           
=======================================
  Hits          250      250           
  Misses          5        5           
  Partials       16       16           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27c502f...1b16476. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

size-limit report 📦

Path Size
dist/index.mjs 0 B (-100% 🔽)
dist/index.cjs 5.74 KB (0%)
dist/index.js 4.08 KB (+100% 🔺)

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.

'Element' is not exported from '@prismicio/richtext'.
2 participants