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

Type checking module build fails when consuming TS files from an npm linked package #96

Closed
ceszare opened this issue Feb 23, 2018 · 2 comments

Comments

@ceszare
Copy link

ceszare commented Feb 23, 2018

First of all, thank you so much for providing a very useful loader. For the most part it works really well, and has boosted my productivity substantially. I am having a problem, and would definitely appreciate your input in trying to figure out a fix/workaround, or guidance in the case I may be doing something wrong.

I have an npm package (A) that hosts an app that is bundled via webpack. When adding tslint-loader to my webpack builds, it works nicely.

Separately, I have a library as an npm package (B) that A consumes. Oftentimes, I may do development with both of them at the same time. I will use npm link to create a symlink between B and its independency inside A's node_modules folder. This workflow does not work for tslint-loader, as I get the following error:

ERROR in ../relative/path/to/failing/typescript/file.ts
Module build failed: FatalError:
Invalid source file: /Absolute/path/to/failing/typescript/file.ts. Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.

    at new FatalError (/Absolute/path/to/package/A/node_modules/tslint/lib/error.js:27:28)
    at Linter.getSourceFile (/Absolute/path/to/package/A/node_modules/tslint/lib/linter.js:222:23)
    at Linter.lint (/Absolute/path/to/package/A/node_modules/tslint/lib/linter.js:96:31)
    at lint (/Absolute/path/to/package/A/node_modules/tslint-loader/index.js:70:10)
    at Object.module.exports (/Absolute/path/to/package/A/node_modules/tslint-loader/index.js:140:3)
 @ ../relative/path/to/failing/typescript/file.ts 22:0-45

The error in the linters only happens when I have type-checking enabled.

The error doesn't happen if I run the tslint command directly, i.e.

tslint -c tslint.json -p tsconfig.json \"src/**/*.ts\"

The loader is using the same tslint.json and tsconfig.json files.

Let me know if I could provide more information.

@andrew0r
Copy link

andrew0r commented May 24, 2018

I just ran into this same situation. I found the hint to solve it at palantir/tslint#2208

The fix that I found was to add to my tsconfig.json a section that looked like:

"include": [
  "./src/**/*",
  "../my-linked-module/src/**/*"
],

Good luck!

@ceszare
Copy link
Author

ceszare commented Jun 4, 2018

This makes a lot of sense. Thanks for the tip! 👍

@ceszare ceszare closed this as completed Jun 4, 2018
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