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

Empty TS_NODE_IGNORE defaults to node_modules/ #1301

Closed
inad9300 opened this issue May 1, 2021 · 1 comment · Fixed by #1483
Closed

Empty TS_NODE_IGNORE defaults to node_modules/ #1301

inad9300 opened this issue May 1, 2021 · 1 comment · Fixed by #1483
Labels
you can do this Good candidate for a pull request.
Milestone

Comments

@inad9300
Copy link

inad9300 commented May 1, 2021

Expected Behavior

Running TS_NODE_IGNORE= webpack should make ts-node (internally used by webpack) take into account references to TypeScript files contained in node_modules/.

Actual Behavior

It behaves the same as if TS_NODE_IGNORE was not defined at all. When setting TS_NODE_IGNORE to a dummy value, e.g. TS_NODE_IGNORE=/non-existent-directory webpack, things work as expected.

Steps to reproduce the problem

Clone https://github.com/inad9300/webpack-typescript-loader/tree/ts-node-ignore, run npm i and npm start. Compare this with npm run really-start.

Specifications

  • ts-node version: 9.1.1
  • node version: 14.16.0
  • TypeScript version: 4.2.4
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node"
  }
}
  • Operating system and version: latest macOS
@inad9300 inad9300 changed the title Empty TS_NODE_IGNORE defaults to node_modules/ Empty TS_NODE_IGNORE defaults to node_modules/ May 1, 2021
@cspotcode cspotcode added the you can do this Good candidate for a pull request. label May 12, 2021
@cspotcode
Copy link
Collaborator

cspotcode commented May 12, 2021

Marked as "help wanted" because this is a straightforward fix, a good first issue for an external contributor, and we already have TS_NODE_SKIP_IGNORE which achieves the same effect, so the severity is low.

If anyone wants to implement this feature, please also think about corner cases and documentation updates, if appropriate. TS_NODE_IGNORE is interpreted as a regexp. I think that technically an empty regexp means "match everything", but I'm not sure and I agree that's confusing.

Here are links to some relevant bits of code:

ts-node/src/index.ts

Lines 509 to 516 in 03355c1

const shouldIgnore = createIgnore(
ignoreBaseDir,
options.skipIgnore
? []
: (options.ignore || ['(?:^|/)node_modules/']).map(
(str) => new RegExp(str)
)
);

ignore: split(env.TS_NODE_IGNORE),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
you can do this Good candidate for a pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants