Skip to content

Commit b6e89f0

Browse files
authored
Don't build CJS for pretest or while watching (#6820)
It's important that when we're doing a full build for distribution (eg, `postinstall`) that we build both CJS and ESM. But when we're just doing development, building for both outputs just wastes CPU and makes errors show up twice. So in the places designed for development (the `pretest` script and the VSCode watch task), link in the ESM versions of dual-build projects (as well as all test suites). Also, align `npm run watch` with the VSCode watch task (ie, make it watch tests too).
1 parent 5a57f4b commit b6e89f0

6 files changed

Lines changed: 41 additions & 10 deletions

File tree

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "TypeScript watch",
66
"type": "typescript",
7-
"tsconfig": "tsconfig.json",
7+
"tsconfig": "tsconfig.esm.json",
88
"option": "watch",
99
"problemMatcher": ["$tsc-watch"],
1010
"presentation": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"precompile": "node scripts/precompile.mjs",
1010
"compile": "tsc --build tsconfig.build.json",
1111
"postcompile": "node scripts/postcompile.mjs",
12-
"watch": "tsc --build tsconfig.build.json --watch",
12+
"watch": "tsc --build tsconfig.esm.json --watch",
1313
"install-with-npm-8.5": "npm i -g npm@^8.5.0 && npm i",
1414
"postinstall": "npm run compile",
15-
"pretest": "tsc --build tsconfig.json",
15+
"pretest": "tsc --build tsconfig.esm.json",
1616
"test": "jest --verbose",
1717
"test:clean": "jest --clearCache",
1818
"test:watch": "jest --verbose --watchAll",

tsconfig.build.cjs.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true
4+
},
5+
"files": [],
6+
"include": [],
7+
"references": [
8+
{ "path": "./packages/plugin-landing-page-graphql-playground/tsconfig.cjs.json" },
9+
{ "path": "./packages/plugin-response-cache/tsconfig.cjs.json" },
10+
{ "path": "./packages/server/tsconfig.cjs.json" },
11+
]
12+
}

tsconfig.build.esm.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true
4+
},
5+
"files": [],
6+
"include": [],
7+
"references": [
8+
{ "path": "./packages/integration-testsuite/" },
9+
{ "path": "./packages/plugin-landing-page-graphql-playground" },
10+
{ "path": "./packages/plugin-response-cache" },
11+
{ "path": "./packages/server" },
12+
]
13+
}

tsconfig.build.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
"files": [],
66
"include": [],
77
"references": [
8-
{ "path": "./packages/integration-testsuite/" },
9-
{ "path": "./packages/plugin-landing-page-graphql-playground" },
10-
{ "path": "./packages/plugin-landing-page-graphql-playground/tsconfig.cjs.json" },
11-
{ "path": "./packages/plugin-response-cache" },
12-
{ "path": "./packages/plugin-response-cache/tsconfig.cjs.json" },
13-
{ "path": "./packages/server" },
14-
{ "path": "./packages/server/tsconfig.cjs.json" },
8+
{ "path": "./tsconfig.build.esm.json" },
9+
{ "path": "./tsconfig.build.cjs.json" },
1510
]
1611
}

tsconfig.esm.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true
4+
},
5+
"files": [],
6+
"include": [],
7+
"references": [
8+
{ "path": "./tsconfig.build.esm.json" },
9+
{ "path": "./tsconfig.test.json" },
10+
]
11+
}

0 commit comments

Comments
 (0)