Skip to content

Commit abb0baa

Browse files
wardpeetpiehLekoArts
authoredAug 4, 2022
fix(gatsby-link): Correctly export default for CJS (#36312)
Co-authored-by: pieh <misiek.piechowiak@gmail.com> Co-authored-by: LekoArts <lekoarts@gmail.com>
1 parent d8efbc2 commit abb0baa

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed
 

‎packages/gatsby-link/package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"bugs": {
77
"url": "https://github.com/gatsbyjs/gatsby/issues"
88
},
9-
"source": "src/index.js",
109
"main": "dist/index.js",
1110
"module": "dist/index.modern.mjs",
1211
"types": "index.d.ts",
@@ -16,8 +15,12 @@
1615
],
1716
"sideEffects": false,
1817
"scripts": {
19-
"build": "microbundle -f cjs,modern --jsx React.createElement --generateTypes false",
20-
"watch": "npm run build watch --no-compress",
18+
"build": "npm-run-all --npm-path npm -s build:cjs build:esm",
19+
"build:cjs": "microbundle -f cjs --jsx React.createElement --generateTypes false -i src/index-cjs.js -o dist/index.js",
20+
"build:esm": "microbundle -f modern --jsx React.createElement --generateTypes false -o dist/index.mjs",
21+
"watch": "npm-run-all --npm-path npm -p watch:cjs watch:esm",
22+
"watch:cjs": "npm run build:cjs watch --no-compress",
23+
"watch:esm": "npm run build:esm watch --no-compress",
2124
"prepare": "cross-env NODE_ENV=production npm run clean && npm run build",
2225
"clean": "del-cli dist/*"
2326
},
@@ -30,7 +33,8 @@
3033
"@testing-library/react": "^11.2.7",
3134
"cross-env": "^7.0.3",
3235
"del-cli": "^5.0.0",
33-
"microbundle": "^0.15.0"
36+
"microbundle": "^0.15.0",
37+
"npm-run-all": "^4.1.5"
3438
},
3539
"peerDependencies": {
3640
"@gatsbyjs/reach-router": "^1.3.5",
@@ -50,4 +54,4 @@
5054
"engines": {
5155
"node": ">=14.15.0"
5256
}
53-
}
57+
}

‎packages/gatsby-link/src/index-cjs.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Link from "./index.js"
2+
3+
module.exports = Link.default
4+
5+
Object.getOwnPropertyNames(Link).forEach(key => {
6+
Object.defineProperty(module.exports, key, {
7+
value: Link[key],
8+
enumerable: true,
9+
})
10+
})

0 commit comments

Comments
 (0)
Please sign in to comment.