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) fix dual package hazard #3200

Closed
wants to merge 1 commit into from

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented May 19, 2021

To avoid dual package hazard in Node.js, it's important that the instance of hljs is shared across CJS and ESM modules.

Refs: #3188

Changes

This PR is disabling use of ESM for the core module in Node.js, as ESM is able to import CJS modules but not the oother way around.

@aduh95 aduh95 mentioned this pull request May 19, 2021
@@ -119,7 +119,10 @@ async function buildPackageJSON(options) {
".": dual("./lib/index.js"),
"./package.json": "./package.json",
"./lib/common": dual("./lib/common.js"),
"./lib/core": dual("./lib/core.js"),
"./lib/core": {
get node() { return this.require; },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa. Does JSON.stringify automatically loop over getters or how does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it loops over all enumerable keys, and read its value by calling the getter in this case.

@joshgoebel
Copy link
Member

Closing, as mentioned elsewhere our cdn package is where "web-ready" build assets should live, not our primary NPM. So this is not a relevant issue.

@joshgoebel joshgoebel closed this May 30, 2021
@aduh95 aduh95 deleted the dual-package-hazard branch May 30, 2021 08:14
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