diff --git a/packages/gatsby-link/package.json b/packages/gatsby-link/package.json index eeaf8bef7f46b..a51045cf7ddf9 100644 --- a/packages/gatsby-link/package.json +++ b/packages/gatsby-link/package.json @@ -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", @@ -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/*" }, @@ -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", @@ -50,4 +54,4 @@ "engines": { "node": ">=14.15.0" } -} +} \ No newline at end of file diff --git a/packages/gatsby-link/src/index-cjs.js b/packages/gatsby-link/src/index-cjs.js new file mode 100644 index 0000000000000..30a04d45ec5dc --- /dev/null +++ b/packages/gatsby-link/src/index-cjs.js @@ -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, + }) +})