Skip to content

Commit eeca436

Browse files
DSchaupieh
authored andcommitted
fix(gatsby): add main field pointing to transpiled commonjs entry (#9123)
* fix: transpile gatsby to commonjs for better testability * chore: fix up main entry * fix: ignore tests too (thanks @pieh)
1 parent 1b1b1d1 commit eeca436

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/gatsby/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ node_modules
2828

2929
decls
3030
dist
31+
32+
# built files
33+
cache-dir/commonjs/

packages/gatsby/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@
160160
"website"
161161
],
162162
"license": "MIT",
163-
"main": "cache-dir/gatsby-browser-entry.js",
163+
"main": "cache-dir/commonjs/gatsby-browser-entry.js",
164+
"module": "cache-dir/gatsby-browser-entry.js",
164165
"peerDependencies": {
165166
"react": "^16.4.2",
166167
"react-dom": "^16.4.2"
@@ -173,9 +174,10 @@
173174
"graphql": "^0.13.2"
174175
},
175176
"scripts": {
176-
"build": "rimraf dist && npm run build:src && npm run build:internal-plugins && npm run build:rawfiles",
177+
"build": "rimraf dist && npm run build:src && npm run build:internal-plugins && npm run build:rawfiles && npm run build:cjs",
177178
"build:internal-plugins": "copyfiles -u 1 src/internal-plugins/**/package.json dist",
178179
"build:rawfiles": "copyfiles -u 1 src/internal-plugins/**/raw_* dist",
180+
"build:cjs": "babel cache-dir --out-dir cache-dir/commonjs --ignore **/__tests__",
179181
"build:src": "babel src --out-dir dist --source-maps --ignore **/gatsby-cli.js,**/raw_*,**/__tests__",
180182
"clean-test-bundles": "find test/ -type f -name bundle.js* -exec rm -rf {} +",
181183
"prepare": "cross-env NODE_ENV=production npm run build",

0 commit comments

Comments
 (0)