Closed Rotzbua closed 3 months ago
This also has to play with the generate-locales
npm script which gets run during the build process. I tried converting the requires
statements in the files in the scripts-directory to import
, but I'm still getting weird errors.
$ npx ts-node scripts/generate-locales.ts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for C:\Users\gustav\w3c\website\scripts\generate-locales.ts
at new NodeError (node:internal/errors:406:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
at defaultGetFormat (node:internal/modules/esm/get_format:142:36)
at defaultLoad (node:internal/modules/esm/load:120:20)
at ModuleLoader.load (node:internal/modules/esm/loader:396:13)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:56)
at new ModuleJob (node:internal/modules/esm/module_job:65:26)
at ModuleLoader.#createModuleJob (node:internal/modules/esm/loader:290:17)
at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:248:34)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:229:17) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Trying with node --loader ts-node/esm:
$ node --loader ts-node/esm scripts/generate-locales.ts
(node:30028) 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"; registe
r("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
[Object: null prototype] {
[Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}
Node.js v20.9.0
Ah yeah, that ERR_UNKNOWN_FILE_EXTENSION
bug https://github.com/TypeStrong/ts-node/issues/1997 . Seems still not fixed.
If we skip the module declaration in package.json the PR should be fine, I think.
Changes
Reference
Followup to #734