Skip to content

Commit 3b97b34

Browse files
committed
feat: add support for importing ts-node-maintained
1 parent 01322b9 commit 3b97b34

File tree

8 files changed

+49
-36
lines changed

8 files changed

+49
-36
lines changed

eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { configPkg } from '@adonisjs/eslint-config'
2+
export default configPkg()

package.json

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"scripts": {
2121
"pretest": "npm run lint",
2222
"test": "c8 npm run quick:test",
23-
"lint": "eslint . --ext=.ts",
23+
"lint": "eslint .",
2424
"clean": "del-cli build",
2525
"typecheck": "tsc --noEmit",
2626
"precompile": "npm run lint && npm run clean",
@@ -31,54 +31,54 @@
3131
"sync-labels": "github-label-sync --labels .github/labels.json adonisjs/assembler",
3232
"format": "prettier --write .",
3333
"prepublishOnly": "npm run build",
34-
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --loader=ts-node/esm bin/test.ts"
34+
"quick:test": "cross-env NODE_DEBUG=adonisjs:assembler node --enable-source-maps --import=ts-node-maintained/register/esm bin/test.ts"
3535
},
3636
"devDependencies": {
3737
"@adonisjs/application": "^8.3.1",
38-
"@adonisjs/eslint-config": "^1.3.0",
39-
"@adonisjs/prettier-config": "^1.3.0",
40-
"@adonisjs/tsconfig": "^1.3.0",
41-
"@commitlint/cli": "^19.3.0",
42-
"@commitlint/config-conventional": "^19.2.2",
38+
"@adonisjs/eslint-config": "^2.0.0-beta.6",
39+
"@adonisjs/prettier-config": "^1.4.0",
40+
"@adonisjs/tsconfig": "^1.4.0",
41+
"@commitlint/cli": "^19.4.1",
42+
"@commitlint/config-conventional": "^19.4.1",
4343
"@japa/assert": "^3.0.0",
4444
"@japa/file-system": "^2.3.0",
4545
"@japa/runner": "^3.1.4",
4646
"@japa/snapshot": "^2.0.5",
47-
"@swc/core": "^1.5.24",
48-
"@types/node": "^20.13.0",
49-
"@types/picomatch": "^2.3.3",
47+
"@swc/core": "^1.7.22",
48+
"@types/node": "^22.5.1",
49+
"@types/picomatch": "^3.0.1",
5050
"@types/pretty-hrtime": "^1.0.3",
51-
"c8": "^9.1.0",
51+
"c8": "^10.1.2",
5252
"cross-env": "^7.0.3",
5353
"del-cli": "^5.1.0",
54-
"eslint": "^8.57.0",
54+
"eslint": "^9.9.1",
55+
"execa": "^9.3.1",
5556
"github-label-sync": "^2.3.1",
5657
"hot-hook": "^0.2.6",
57-
"husky": "^9.0.11",
58+
"husky": "^9.1.5",
5859
"p-event": "^6.0.1",
59-
"prettier": "^3.3.0",
60-
"release-it": "^17.3.0",
61-
"ts-node": "^10.9.2",
62-
"tsup": "^8.0.2",
63-
"typescript": "^5.4.5"
60+
"prettier": "^3.3.3",
61+
"release-it": "^17.6.0",
62+
"ts-node-maintained": "^10.9.4",
63+
"tsup": "^8.2.4",
64+
"typescript": "^5.5.4"
6465
},
6566
"dependencies": {
6667
"@adonisjs/env": "^6.1.0",
67-
"@antfu/install-pkg": "^0.3.3",
68+
"@antfu/install-pkg": "^0.4.1",
6869
"@poppinss/chokidar-ts": "^4.1.4",
6970
"@poppinss/cliui": "^6.4.1",
7071
"@poppinss/hooks": "^7.2.3",
7172
"@poppinss/utils": "^6.7.3",
72-
"cpy": "^11.0.1",
73+
"cpy": "^11.1.0",
7374
"dedent": "^1.5.3",
74-
"execa": "^8.0.1",
7575
"fast-glob": "^3.3.2",
7676
"get-port": "^7.1.0",
7777
"junk": "^4.0.1",
7878
"picomatch": "^4.0.2",
7979
"pretty-hrtime": "^1.0.3",
8080
"slash": "^5.1.0",
81-
"ts-morph": "^22.0.0"
81+
"ts-morph": "^23.0.0"
8282
},
8383
"peerDependencies": {
8484
"typescript": "^4.0.0 || ^5.0.0"
@@ -98,9 +98,6 @@
9898
"build",
9999
"ts"
100100
],
101-
"eslintConfig": {
102-
"extends": "@adonisjs/eslint-config/package"
103-
},
104101
"prettier": "@adonisjs/prettier-config",
105102
"commitlint": {
106103
"extends": [

src/assets_dev_server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import type { ExecaChildProcess } from 'execa'
10+
import type { ResultPromise } from 'execa'
1111
import { type Logger, cliui } from '@poppinss/cliui'
1212

1313
import { run } from './helpers.js'
@@ -33,7 +33,7 @@ export class AssetsDevServer {
3333
#cwd: URL
3434
#logger = ui.logger
3535
#options?: AssetsBundlerOptions
36-
#devServer?: ExecaChildProcess<string>
36+
#devServer?: ResultPromise
3737

3838
/**
3939
* Getting reference to colors library from logger

src/dev_server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { relative } from 'node:path'
1212
import type tsStatic from 'typescript'
1313
import prettyHrtime from 'pretty-hrtime'
1414
import { fileURLToPath } from 'node:url'
15-
import { type ExecaChildProcess } from 'execa'
15+
import { type ResultPromise } from 'execa'
1616
import { cliui, type Logger } from '@poppinss/cliui'
1717
import type { Watcher } from '@poppinss/chokidar-ts'
1818

@@ -75,7 +75,7 @@ export class DevServer {
7575
/**
7676
* Reference to the child process
7777
*/
78-
#httpServer?: ExecaChildProcess<string>
78+
#httpServer?: ResultPromise
7979

8080
/**
8181
* Reference to the watcher
@@ -223,7 +223,7 @@ export class DevServer {
223223
this.#httpServer
224224
.then((result) => {
225225
if (mode === 'nonblocking') {
226-
this.#onClose?.(result.exitCode)
226+
this.#onClose?.(result.exitCode!)
227227
this.#watcher?.close()
228228
this.#assetsServer?.stop()
229229
} else {

src/helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import debug from './debug.js'
2828
*/
2929
const DEFAULT_NODE_ARGS = [
3030
// Use ts-node/esm loader. The project must install it
31-
'--loader=ts-node/esm',
31+
process.versions.tsNodeMaintained
32+
? '--import=ts-node-maintained/register/esm'
33+
: '--loader=ts-node/esm',
3234
// Enable source maps, since TSNode source maps are broken
3335
'--enable-source-maps',
3436
]
@@ -77,6 +79,7 @@ export function runNode(cwd: string | URL, options: RunOptions) {
7779
windowsHide: false,
7880
localDir: cwd,
7981
cwd,
82+
reject: options.reject ?? false,
8083
buffer: false,
8184
stdio: options.stdio || 'inherit',
8285
env: {

src/test_runner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import picomatch from 'picomatch'
1111
import type tsStatic from 'typescript'
12-
import { type ExecaChildProcess } from 'execa'
12+
import { type ResultPromise } from 'execa'
1313
import { cliui, type Logger } from '@poppinss/cliui'
1414
import type { Watcher } from '@poppinss/chokidar-ts'
1515

@@ -87,7 +87,7 @@ export class TestRunner {
8787
/**
8888
* Reference to the test script child process
8989
*/
90-
#testScript?: ExecaChildProcess<string>
90+
#testScript?: ResultPromise
9191

9292
/**
9393
* Reference to the watcher
@@ -236,7 +236,7 @@ export class TestRunner {
236236
this.#testScript
237237
.then((result) => {
238238
if (mode === 'nonblocking') {
239-
this.#onClose?.(result.exitCode)
239+
this.#onClose?.(result.exitCode!)
240240
this.close()
241241
}
242242
})

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export type RunOptions = {
3737
* Environment variables to pass to the child process
3838
*/
3939
env?: NodeJS.ProcessEnv
40+
41+
/**
42+
* Whether or not to reject the promise. Defaults
43+
* false
44+
*/
45+
reject?: boolean
4046
}
4147

4248
/**

tests/run.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test.group('Child process', () => {
6969
assert.equal(childProcess.exitCode, 0)
7070
assert.deepEqual(payload, {
7171
args: [
72-
'--loader=ts-node/esm',
72+
'--import=ts-node-maintained/register/esm',
7373
'--enable-source-maps',
7474
process.allowedNodeEnvironmentFlags.has('--disable-warning')
7575
? '--disable-warning=ExperimentalWarning'
@@ -116,7 +116,12 @@ test.group('Child process', () => {
116116
`
117117
)
118118

119-
const childProcess = runNode(fs.basePath, { script: 'foo.ts', scriptArgs: [], nodeArgs: [] })
119+
const childProcess = runNode(fs.basePath, {
120+
script: 'foo.ts',
121+
scriptArgs: [],
122+
nodeArgs: [],
123+
reject: true,
124+
})
120125
try {
121126
await childProcess
122127
} catch {

0 commit comments

Comments
 (0)