Skip to content

Commit

Permalink
use the node --import option as suggested
Browse files Browse the repository at this point in the history
replacing --loader ts-node/esm/transpile-only, which gives the following warning:

(node:33248) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm/transpile-only", pathToFileURL("./"));'
  • Loading branch information
yaacovCR committed Nov 22, 2024
1 parent 1d98a6a commit e2f5a4d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,12 @@ module.exports = {
'import/no-commonjs': 'off',
},
},
{
files: 'resources/with-ts-node-esm.js',
parserOptions: {
sourceType: 'module',
},
},
{
files: '**/*.jsx',
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ check-leaks: true
extension:
- ts
node-option:
- 'loader=ts-node/esm/transpile-only'
- 'import=./resources/with-ts-node-esm.js'
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
},
"scripts": {
"preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'",
"version": "node --loader ts-node/esm resources/gen-version.ts && npm test && git add src/version.ts",
"version": "node --import ./resources/with-ts-node-esm.js resources/gen-version.ts && npm test && git add src/version.ts",
"fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts",
"changelog": "node --loader ts-node/esm resources/gen-changelog.ts",
"benchmark": "node --loader ts-node/esm resources/benchmark.ts",
"changelog": "node --import ./resources/with-ts-node-esm.js resources/gen-changelog.ts",
"benchmark": "node --import ./resources/with-ts-node-esm.js resources/benchmark.ts",
"test": "npm run lint && npm run check && npm run testonly:cover && npm run prettier:check && npm run check:spelling && npm run check:integrations",
"lint": "eslint --cache --max-warnings 0 --rulesdir resources/eslint-internal-rules/ .",
"check": "tsc --pretty",
Expand All @@ -47,10 +47,10 @@
"check:integrations": "mocha --full-trace resources/integration-test.ts",
"serve": "docusaurus serve --dir websiteDist/ --config website/docusaurus.config.cjs",
"start": "npm run build:website && npm run serve",
"build:website": "node --loader ts-node/esm resources/build-docusaurus.ts",
"build:npm": "node --loader ts-node/esm resources/build-npm.ts",
"build:deno": "node --loader ts-node/esm resources/build-deno.ts",
"diff:npm": "node --loader ts-node/esm resources/diff-npm-package.ts",
"build:website": "node --import ./resources/with-ts-node-esm.js resources/build-docusaurus.ts",
"build:npm": "node --import ./resources/with-ts-node-esm.js resources/build-npm.ts",
"build:deno": "node --import ./resources/with-ts-node-esm.js resources/build-deno.ts",
"diff:npm": "node --import ./resources/with-ts-node-esm.js resources/diff-npm-package.ts",
"gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist",
"gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist",
"prepare": "husky"
Expand Down
5 changes: 5 additions & 0 deletions resources/with-ts-node-esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// eslint-disable-next-line n/no-unsupported-features/node-builtins
import { register } from 'node:module';
import { pathToFileURL } from 'node:url';

register('ts-node/esm/transpile-only', pathToFileURL('./'));

0 comments on commit e2f5a4d

Please sign in to comment.