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(gatsby-link): Correctly export default for CJS #36312

Merged
merged 5 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/gatsby-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"source": "src/index.js",
"main": "dist/index.js",
"module": "dist/index.modern.mjs",
"types": "index.d.ts",
Expand All @@ -16,8 +15,12 @@
],
"sideEffects": false,
"scripts": {
"build": "microbundle -f cjs,modern --jsx React.createElement --generateTypes false",
"watch": "npm run build watch --no-compress",
"build": "npm-run-all --npm-path npm -s build:cjs build:esm",
"build:cjs": "microbundle -f cjs --jsx React.createElement --generateTypes false -i src/index-cjs.js -o dist/index.js",
"build:esm": "microbundle -f modern --jsx React.createElement --generateTypes false -o dist/index.mjs",
"watch": "npm-run-all --npm-path npm -p watch:cjs watch:esm",
"watch:cjs": "npm run build:cjs watch --no-compress",
"watch:esm": "npm run build:esm watch --no-compress",
"prepare": "cross-env NODE_ENV=production npm run clean && npm run build",
"clean": "del-cli dist/*"
},
Expand All @@ -30,7 +33,8 @@
"@testing-library/react": "^11.2.7",
"cross-env": "^7.0.3",
"del-cli": "^5.0.0",
"microbundle": "^0.15.0"
"microbundle": "^0.15.0",
"npm-run-all": "^4.1.5"
},
"peerDependencies": {
"@gatsbyjs/reach-router": "^1.3.5",
Expand All @@ -50,4 +54,4 @@
"engines": {
"node": ">=14.15.0"
}
}
}
10 changes: 10 additions & 0 deletions packages/gatsby-link/src/index-cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Link from "./index.js"

module.exports = Link.default

Object.getOwnPropertyNames(Link).forEach(key => {
Object.defineProperty(module.exports, key, {
value: Link[key],
enumerable: true,
})
})