Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible regression with ts-node 10.0.0: ts extension not registered? #1368

Closed
jayaddison opened this issue Jun 6, 2021 · 2 comments
Closed

Comments

@jayaddison
Copy link
Contributor

Expected Behavior

For this codebase, running make tests (essentially, npx mocha) runs unit tests over some TypeScript code, and completes successfully. The codebase has ts-node configured matching semver ^9.1.1.

After upgrading the package.json ts-node entry to 10.0.0 in package.json file, and running npm install --also=dev, unit tests should continue to pass.

Actual Behavior

After the upgrade, unit tests fail:

TS_NODE_IGNORE='node_modules/(?!document-prev)' npx mocha

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/jka/Documents/reciperadar/document/src/index.spec.ts
    at new NodeError (node:internal/errors:363:5)
    at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
    at Loader.getFormat (node:internal/modules/esm/loader:105:42)
    at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
    at Loader.import (node:internal/modules/esm/loader:177:17)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at formattedImport (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/esm-utils.js:7:14)
    at Object.exports.loadFilesAsync (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/esm-utils.js:55:20)
    at singleRun (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at Object.exports.handler (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/cli/run.js:362:5)
make: *** [Makefile:9: tests] Error 1

Steps to reproduce the problem

Update the devDependency entry for ts-node, reinstall dependencies (including dev), and then run make tests.

Minimal reproduction

I'll attempt to narrow this down and fill in the minimal repro case soon.

Specifications

  • ts-node version: 10.0.0
  • node version: v16.1.0.
  • TypeScript version: v4.3.2
  • tsconfig.json, if you're using one:
{
    "compilerOptions": {
        "resolveJsonModule": true,
        "target": "ES5"
    }
}
  • Operating system and version: Manjaro Linux
@cspotcode
Copy link
Collaborator

cspotcode commented Jun 6, 2021

Not a regression, it's an improvement in our behavior to more closely align with nodejs, which is forcing you to use our ESM loader when your project uses "type": "module".

Here is the relevant changelog entry:

See also: #1342 which is pending feedback from some other open-source maintainers.

Solutions for you in the short-term. You will have to decide which of these are viable:

I believe that covers all the bases. If you need anything else, I recommend either the TypeScript Community Discord or our discussion forum. Both are linked from the navigation bar of our website: https://typestrong.org/ts-node

@jayaddison
Copy link
Contributor Author

Thanks @cspotcode - and my apologies, I did read the changelog but I didn't catch that entry somehow. I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants