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

Should not compile everything #646

Closed
tkrotoff opened this issue Sep 27, 2017 · 1 comment
Closed

Should not compile everything #646

tkrotoff opened this issue Sep 27, 2017 · 1 comment

Comments

@tkrotoff
Copy link

ts-loader compiles a lot more files than it should. ts-loader should only compile files known to webpack (e.g webpack.config.js entry + its children) (and/or files specified in tsconfig.json (*))

Setup:

  • webpack.config.js with an entry ./index.ts + ts-loader
  • a file fail.ts:
// Fail to compile with TypeScript with "'const' declarations must be initialized"
// + is not imported by index.ts
const fail;

Results:

  • Case 1 no tsconfig.json
ERROR in error TS18002: The 'files' list in config file 'tsconfig.json' is empty.

ERROR in ./index.ts
Module build failed: error while parsing tsconfig.json

=> KO, ts-loader should work without a file tsconfig.json (or at least the error message is incorrect and should be "error: no tsconfig.json")

  • Case 2 empty tsconfig.json without files and include
ERROR in /Users/tanguy/flex-wrap-layout/src/fail.ts
(1,7): error TS1155: 'const' declarations must be initialized.

=> KO, this is the main case, fail.ts is not specified anywhere (tsconfig.json and webpack.config.js) so ts-loader should not compile it.

  • Case 3 tsconfig.json with files (*)
    • Case 3.1 files with index.ts ("files": ["index.ts"]): no error => this is OK
    • Case 3.2 files with index.ts and fail.ts ("files": ["index.ts", "fail.ts"]): fail.ts error => this is OK



Comparison with rollup-plugin-typescript2:

  • Case 1: [!] Error: couldn't find 'tsconfig.json'
  • Case 2: does not compile fail.ts => OK
  • Case 3.1: does not compile fail.ts => OK
  • Case 3.2: does not compile fail.ts
  • Case 3.2bis "include": ["*.ts"]: does not compile fail.ts



(*) I even believe that ts-loader should totally ignore tsconfig.json files (but use compilerOptions of course) and only rely on webpack.config.js entry (and its imported children). This is what rollup-plugin-typescript2 does.

@johnnyreilly
Copy link
Member

Closing as duplicate of #267

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