Skip to content

Commit c090710

Browse files
committed
Merge remote-tracking branch 'origin/main' into switch-to-c8
2 parents 6e056f4 + 97f9afd commit c090710

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1519
-1097
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Prettier formatting
2+
9d05cb684fc3a6e492832100a125ea07d1cc98c5
3+

.github/workflows/continuous-integration.yml

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,91 +51,72 @@ jobs:
5151
matrix:
5252
os: [ubuntu, windows]
5353
# Don't forget to add all new flavors to this list!
54-
flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
54+
flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
5555
include:
56-
# Node 12.15
57-
- flavor: 1
58-
node: 12.15
59-
nodeFlag: 12_15
60-
typescript: latest
61-
typescriptFlag: latest
62-
# Node 12.16
63-
# Earliest version that supports getFormat, etc hooks: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#12.16.0
64-
- flavor: 2
65-
node: 12.16
66-
nodeFlag: 12_16
67-
typescript: latest
68-
typescriptFlag: latest
69-
# Node 12
70-
- flavor: 3
71-
node: 12
72-
nodeFlag: 12
73-
typescript: latest
74-
typescriptFlag: latest
7556
# Node 14.13.0
7657
# To test ESM builtin module resolution immediately before a node behavioral change: https://github.com/TypeStrong/ts-node/issues/1130
77-
- flavor: 4
58+
- flavor: 1
7859
node: 14.13.0
7960
nodeFlag: 14_13_0
8061
typescript: latest
8162
typescriptFlag: latest
8263
# Node 14
83-
- flavor: 5
64+
- flavor: 2
8465
node: 14
8566
nodeFlag: 14
8667
typescript: latest
8768
typescriptFlag: latest
88-
- flavor: 6
69+
- flavor: 3
8970
node: 14
9071
nodeFlag: 14
91-
typescript: 2.7
92-
typescriptFlag: 2_7
93-
- flavor: 7
72+
typescript: 4.0
73+
typescriptFlag: 4_0
74+
- flavor: 4
9475
node: 14
9576
nodeFlag: 14
9677
typescript: next
9778
typescriptFlag: next
9879
# Node 16
9980
# Node 16.11.1
10081
# Earliest version that supports old ESM Loader Hooks API: https://github.com/TypeStrong/ts-node/pull/1522
101-
- flavor: 8
82+
- flavor: 5
10283
node: 16.11.1
10384
nodeFlag: 16_11_1
10485
typescript: latest
10586
typescriptFlag: latest
106-
- flavor: 9
87+
- flavor: 6
10788
node: 16
10889
nodeFlag: 16
10990
typescript: latest
11091
typescriptFlag: latest
11192
downgradeNpm: true
112-
- flavor: 10
93+
- flavor: 7
11394
node: 16
11495
nodeFlag: 16
115-
typescript: 2.7
116-
typescriptFlag: 2_7
96+
typescript: 4.0
97+
typescriptFlag: 4_0
11798
downgradeNpm: true
118-
- flavor: 11
99+
- flavor: 8
119100
node: 16
120101
nodeFlag: 16
121102
typescript: next
122103
typescriptFlag: next
123104
downgradeNpm: true
124105
# Node 18
125-
- flavor: 12
106+
- flavor: 9
126107
node: 18
127108
nodeFlag: 18
128109
typescript: latest
129110
typescriptFlag: latest
130111
downgradeNpm: true
131-
- flavor: 13
112+
- flavor: 10
132113
node: 18
133114
nodeFlag: 18
134115
typescript: next
135116
typescriptFlag: next
136117
downgradeNpm: true
137118
# Node nightly
138-
- flavor: 14
119+
- flavor: 11
139120
node: nightly
140121
nodeFlag: nightly
141122
typescript: latest

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ We publish using `np`: https://npm.im/np
109109
2. Rebuild the README (see instructions above, necessary because npmjs.com renders the readme)
110110
3. (optional) Update the api-extractor report; check for unexpected changes. See below
111111
4. Publish with `np`
112+
- `np --branch main --no-tests`
113+
- `--no-tests` because we must rely on CI to test ts-node. Even if you *did* run the tests locally, you would only be testing a single operating system, node version, and TypeScript version, so locally-run tests are insufficient.
112114
5. Add changelog to the Github Release; match formatting from previous releases
113115
6. Move `docs` branch to head of `main`
114116
- this rebuilds the website

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,14 +1057,18 @@ These tricks will make ts-node faster.
10571057

10581058
## Skip typechecking
10591059

1060-
It is often better to use `tsc --noEmit` to typecheck as part of your tests or linting. In these cases, ts-node can skip typechecking.
1060+
It is often better to typecheck as part of your tests or linting. You can run `tsc --noEmit` to do this. In these cases, ts-node can skip typechecking, making it much faster.
1061+
1062+
To skip typechecking in ts-node, do one of the following:
10611063

10621064
* Enable [swc](#swc)
10631065
* This is by far the fastest option
10641066
* Enable [`transpileOnly`](#transpileonly) to skip typechecking without swc
10651067

10661068
## With typechecking
10671069

1070+
If you absolutely must typecheck in ts-node:
1071+
10681072
* Avoid dynamic `require()` which may trigger repeated typechecking; prefer `import`
10691073
* Try with and without `--files`; one may be faster depending on your project
10701074
* Check `tsc --showConfig`; make sure all executed files are included

api-extractor/ts-node.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface CreateOptions {
2929
esm?: boolean;
3030
experimentalReplAwait?: boolean;
3131
experimentalSpecifierResolution?: 'node' | 'explicit';
32+
experimentalTsImportSpecifiers?: boolean;
3233
// (undocumented)
3334
fileExists?: (path: string) => boolean;
3435
files?: boolean;

ava.config.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ module.exports = {
1515
NODE_PATH: ''
1616
},
1717
require: ['./src/test/remove-env-var-force-color.js'],
18-
nodeArguments: semver.gte(process.version, '14.0.0')
19-
? ['--loader', './src/test/test-loader.mjs', '--no-warnings']
20-
: [],
18+
nodeArguments: ['--loader', './src/test/test-loader.mjs', '--no-warnings'],
2119
timeout: '300s',
2220
concurrency: 1,
2321
};

dist-raw/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ in a factory function, we will not indent the function body, to avoid whitespace
1010

1111
One obvious problem with this approach: the code has been pulled from one version of node, whereas users of ts-node
1212
run multiple versions of node.
13-
Users running node 12 may see that ts-node behaves like node 14, for example.
13+
Users running node 14 may see that ts-node behaves like node 18, for example.
1414

1515
## `raw` directory
1616

dist-raw/node-internal-modules-cjs-helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ function addBuiltinLibsToObject(object, dummyModuleName) {
6363

6464
ObjectDefineProperty(object, name, {
6565
get: () => {
66-
// Node 12 hack; remove when we drop node12 support
67-
const lib = (dummyModule.require || require)(name);
66+
const lib = dummyModule.require(name);
6867

6968
// Disable the current getter/setter and set up a new
7069
// non-enumerable property.

dist-raw/node-internal-modules-cjs-loader.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,15 +471,11 @@ const Module_resolveFilename = function _resolveFilename(request, parent, isMain
471471
paths = Module._resolveLookupPaths(request, parent);
472472
}
473473

474-
// if (parent?.filename) {
475-
// node 12 hack
476-
if (parent != null && parent.filename) {
474+
if (parent?.filename) {
477475
if (request[0] === '#') {
478476
const pkg = readPackageScope(parent.filename) || {};
479477

480-
// if (pkg.data?.imports != null) {
481-
// node 12 hack
482-
if (pkg.data != null && pkg.data.imports != null) {
478+
if (pkg.data?.imports != null) {
483479
try {
484480
return finalizeEsmResolution(
485481
packageImportsResolve(request, pathToFileURL(parent.filename),
@@ -559,11 +555,15 @@ return {
559555
/**
560556
* copied from Module._extensions['.js']
561557
* https://github.com/nodejs/node/blob/v15.3.0/lib/internal/modules/cjs/loader.js#L1113-L1120
558+
559+
* Assert that script can be loaded as CommonJS when we attempt to require it.
560+
* If it should be loaded as ESM, throw ERR_REQUIRE_ESM like node does.
561+
*
562562
* @param {import('../src/index').Service} service
563563
* @param {NodeJS.Module} module
564564
* @param {string} filename
565565
*/
566-
function assertScriptCanLoadAsCJSImpl(service, module, filename) {
566+
function assertScriptCanLoadAsCJS(service, module, filename) {
567567
const pkg = readPackageScope(filename);
568568

569569
// ts-node modification: allow our configuration to override
@@ -588,6 +588,6 @@ function assertScriptCanLoadAsCJSImpl(service, module, filename) {
588588

589589
module.exports = {
590590
createCjsLoader,
591-
assertScriptCanLoadAsCJSImpl,
591+
assertScriptCanLoadAsCJS,
592592
readPackageScope
593593
};

dist-raw/node-options.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ function parseArgv(argv) {
3030
'--preserve-symlinks-main': Boolean,
3131
'--input-type': String,
3232
'--experimental-specifier-resolution': String,
33-
// Legacy alias for node versions prior to 12.16
34-
'--es-module-specifier-resolution': '--experimental-specifier-resolution',
3533
'--experimental-policy': String,
3634
'--conditions': [String],
3735
'--pending-deprecation': Boolean,

0 commit comments

Comments
 (0)