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

[Javascript] Fix broken package entrypoints #4411

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

Codex-
Copy link
Contributor

@Codex- Codex- commented Sep 6, 2023

Currently as of 4.13.1 the entrypoint for browser is invalid, and main specifies the esm build instead of the commonjs one.

This results in commonjs based sources attempting to load esm syntax when addressing the sources using main.

The error in browser causes this error when attempting to bundle the sources:

[commonjs--resolver] Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.
error during build:
Error: Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.

Fixes

  • browser field updated to fix the extension
    • "dist/antlr4.web.js" -> "dist/antlr4.web.mjs"
  • main field updated to point to the commonjs bundle
    • "dist/antlr4.node.mjs"->"dist/antlr4.node.cjs"`

Added

  • module field to point to the esm bundle
    • "module": "dist/antlr4.node.mjs"

More information on main vs module can be found here: https://nodejs.org/api/packages.html#dual-commonjses-module-packages

@ericvergnaud
Copy link
Contributor

Thanks for this
@parrt blessed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants