Skip to content

Commit b6dad0a

Browse files
lmiller1990flotwig
andauthored
fix: support type: module in Node.js 16.17.0+ and 18.6.0+ (#23637)
* chore: bump ts-node version * debugging * update tests with docker images and docker script * Update system-tests/scripts/bootstrap-docker-container.sh Co-authored-by: Zach Bloomquist <[email protected]> * use chown * Update system-tests/scripts/bootstrap-docker-container.sh Co-authored-by: Zach Bloomquist <[email protected]> * Update bootstrap-docker-container.sh * Update bootstrap-docker-container.sh Co-authored-by: Zach Bloomquist <[email protected]>
1 parent b5ba6d7 commit b6dad0a

File tree

10 files changed

+51
-31
lines changed

10 files changed

+51
-31
lines changed

npm/vite-dev-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"dedent": "^0.7.0",
2727
"mocha": "^9.2.2",
2828
"sinon": "^13.0.1",
29-
"ts-node": "^10.2.1",
29+
"ts-node": "^10.9.1",
3030
"vite": "3.0.3",
3131
"vite-plugin-inspect": "0.4.3"
3232
},

npm/webpack-dev-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"proxyquire": "2.1.3",
3838
"sinon": "^13.0.1",
3939
"snap-shot-it": "^7.9.6",
40-
"ts-node": "^10.2.1",
40+
"ts-node": "^10.9.1",
4141
"webpack": "npm:webpack@^5",
4242
"webpack-4": "npm:webpack@^4",
4343
"webpack-dev-server-3": "npm:webpack-dev-server@^3"

npm/webpack-preprocessor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"sinon": "^9.0.0",
5959
"sinon-chai": "^3.5.0",
6060
"snap-shot-it": "7.9.2",
61-
"ts-node": "^10.2.1",
61+
"ts-node": "^10.9.1",
6262
"webpack": "^4.44.2"
6363
},
6464
"peerDependencies": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
"through": "2.3.8",
215215
"through2": "^4.0.2",
216216
"tree-kill": "1.2.2",
217-
"ts-node": "^10.2.1",
217+
"ts-node": "^10.9.1",
218218
"typescript": "^4.7.4",
219219
"yarn-deduplicate": "3.1.0"
220220
},

packages/data-context/src/data/ProjectConfigIpc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ export class ProjectConfigIpc extends EventEmitter {
271271
// ts-node for CommonJS
272272
// ts-node/esm for ESM
273273
if (hasTypeScriptInstalled(this.projectRoot)) {
274+
debug('found typescript in %s', this.projectRoot)
274275
if (isProjectUsingESModules) {
276+
debug(`using --experimental-specifier-resolution=node with --loader ${tsNodeEsm}`)
275277
// Use the ts-node/esm loader so they can use TypeScript with `"type": "module".
276278
// The loader API is experimental and will change.
277279
// The same can be said for the other alternative, esbuild, so this is the
@@ -294,6 +296,8 @@ export class ProjectConfigIpc extends EventEmitter {
294296
// so we need to load and evaluate the hook first using the `--require` module API.
295297
const tsNodeLoader = `--require "${tsNode}"`
296298

299+
debug(`using cjs with --require ${tsNode}`)
300+
297301
if (childOptions.env.NODE_OPTIONS) {
298302
childOptions.env.NODE_OPTIONS += ` ${tsNodeLoader}`
299303
} else {
@@ -303,6 +307,7 @@ export class ProjectConfigIpc extends EventEmitter {
303307
} else {
304308
// Just use Node's built-in ESM support.
305309
// TODO: Consider using userland `esbuild` with Node's --loader API to handle ESM.
310+
debug(`no typescript found, just use regular Node.js`)
306311
}
307312

308313
return fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions)

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"tough-cookie": "4.0.0",
117117
"trash": "5.2.0",
118118
"tree-kill": "1.2.2",
119-
"ts-node": "^10.2.1",
119+
"ts-node": "^10.9.1",
120120
"tslib": "2.3.1",
121121
"underscore.string": "3.3.5",
122122
"url-parse": "1.5.9",

packages/ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"debug": "^4.3.2",
15-
"ts-node": "^10.2.1",
15+
"ts-node": "^10.9.1",
1616
"tslib": "2.3.1",
1717
"typescript-cached-transpile": "^0.0.6"
1818
},

system-tests/scripts/bootstrap-docker-container.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export CYPRESS_CACHE_FOLDER=/tmp/CYPRESS_CACHE_FOLDER/
3636
export npm_config_cache=/tmp/npm_config_cache/
3737
export npm_config_package_lock=false
3838

39+
mkdir $npm_config_cache
40+
chown -R 1000:1000 $npm_config_cache
41+
3942
npx npm@latest install --unsafe-perm --allow-root --force file:$CLI_PATH
4043

4144
PATH=$PATH:./node_modules/.bin
@@ -52,4 +55,4 @@ set -e
5255
cd -
5356
rm -rf $TEST_PROJECT_DIR
5457

55-
exit $EXIT_CODE
58+
exit $EXIT_CODE

system-tests/test-binary/node_versions_spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,20 @@ describe('binary node versions', () => {
3232
'cypress/base:17.3.0',
3333
].forEach(smokeTestDockerImage)
3434
})
35+
36+
describe('type: module', () => {
37+
[
38+
'cypress/base:16.17.0',
39+
'cypress/base:18.6.0',
40+
].forEach((dockerImage) => {
41+
systemTests.it(`can run in ${dockerImage}`, {
42+
withBinary: true,
43+
project: 'config-cjs-and-esm/config-with-ts-module',
44+
dockerImage,
45+
testingType: 'e2e',
46+
spec: 'app.cy.js',
47+
browser: 'electron',
48+
expectedExitCode: 0,
49+
})
50+
})
51+
})

yarn.lock

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,17 +2293,12 @@
22932293
resolved "https://registry.yarnpkg.com/@coolaj86/urequest/-/urequest-1.3.7.tgz#66a1d66378dd6534e9c8e68948bf09acf32bab77"
22942294
integrity sha512-PPrVYra9aWvZjSCKl/x1pJ9ZpXda1652oJrPBYy5rQumJJMkmTBN3ux+sK2xAUwVvv2wnewDlaQaHLxLwSHnIA==
22952295

2296-
"@cspotcode/[email protected]":
2297-
version "0.8.0"
2298-
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"
2299-
integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==
2300-
2301-
"@cspotcode/[email protected]":
2302-
version "0.7.0"
2303-
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5"
2304-
integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==
2296+
"@cspotcode/source-map-support@^0.8.0":
2297+
version "0.8.1"
2298+
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
2299+
integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==
23052300
dependencies:
2306-
"@cspotcode/source-map-consumer" "0.8.0"
2301+
"@jridgewell/trace-mapping" "0.3.9"
23072302

23082303
"@csstools/convert-colors@^1.4.0":
23092304
version "1.4.0"
@@ -4150,10 +4145,10 @@
41504145
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.10.tgz#baf57b4e2a690d4f38560171f91783656b7f8186"
41514146
integrity sha512-Ht8wIW5v165atIX1p+JvKR5ONzUyF4Ac8DZIQ5kZs9zrb6M8SJNXpx1zn04rn65VjBMygRoMXcyYwNK0fT7bEg==
41524147

4153-
"@jridgewell/trace-mapping@^0.3.0":
4154-
version "0.3.4"
4155-
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz#f6a0832dffd5b8a6aaa633b7d9f8e8e94c83a0c3"
4156-
integrity sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==
4148+
"@jridgewell/trace-mapping@0.3.9", "@jridgewell/trace-mapping@^0.3.0":
4149+
version "0.3.9"
4150+
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9"
4151+
integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==
41574152
dependencies:
41584153
"@jridgewell/resolve-uri" "^3.0.3"
41594154
"@jridgewell/sourcemap-codec" "^1.4.10"
@@ -32749,12 +32744,12 @@ ts-log@^2.2.3:
3274932744
resolved "https://registry.yarnpkg.com/ts-log/-/ts-log-2.2.3.tgz#4da5640fe25a9fb52642cd32391c886721318efb"
3275032745
integrity sha512-XvB+OdKSJ708Dmf9ore4Uf/q62AYDTzFcAdxc8KNML1mmAWywRFVt/dn1KYJH8Agt5UJNujfM3znU5PxgAzA2w==
3275132746

32752-
ts-node@^10.2.1:
32753-
version "10.7.0"
32754-
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5"
32755-
integrity sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==
32747+
ts-node@^10.9.1:
32748+
version "10.9.1"
32749+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
32750+
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
3275632751
dependencies:
32757-
"@cspotcode/source-map-support" "0.7.0"
32752+
"@cspotcode/source-map-support" "^0.8.0"
3275832753
"@tsconfig/node10" "^1.0.7"
3275932754
"@tsconfig/node12" "^1.0.7"
3276032755
"@tsconfig/node14" "^1.0.0"
@@ -32765,7 +32760,7 @@ ts-node@^10.2.1:
3276532760
create-require "^1.1.0"
3276632761
diff "^4.0.1"
3276732762
make-error "^1.1.1"
32768-
v8-compile-cache-lib "^3.0.0"
32763+
v8-compile-cache-lib "^3.0.1"
3276932764
yn "3.1.1"
3277032765

3277132766
ts-node@^9:
@@ -33656,10 +33651,10 @@ uuid@^3.0.0, uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0:
3365633651
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
3365733652
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
3365833653

33659-
v8-compile-cache-lib@^3.0.0:
33660-
version "3.0.0"
33661-
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
33662-
integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==
33654+
v8-compile-cache-lib@^3.0.1:
33655+
version "3.0.1"
33656+
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"
33657+
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==
3366333658

3366433659
v8-compile-cache@^2.0.2, v8-compile-cache@^2.0.3:
3366533660
version "2.0.3"

0 commit comments

Comments
 (0)