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

ProjectReferences: ts-loader doesnt build dependent projects #1005

Open
jleider opened this issue Sep 17, 2019 · 28 comments
Open

ProjectReferences: ts-loader doesnt build dependent projects #1005

jleider opened this issue Sep 17, 2019 · 28 comments
Labels
pinned don't let probot-stale close

Comments

@jleider
Copy link

jleider commented Sep 17, 2019

Expected Behaviour

Based on this highly anticipated and recently merged PR: #935 by @sheetalkamat I would expect ts-loader to build dependent projects if projectReferences: true.

Actual Behaviour

Dependent project reference is not built when building project.

The test projectReferencesNotBuilt referenced in the "steps to reproduce" section seems to account for the fact that the dependent project may not already be built. However, the expected output of that test is just the TypeScript error saying the project hasn't been built and to run tsc --build to build the dependent project. I would expect the projectReferences config option to basically run the API equivalent of tsc --build.

Actual application error:

Module build failed (from ../node_modules/ts-loader/index.js):
Error: Could not find output JavaScript file for input assets/scripts/api/api.ts (looked at assets/scripts/lib/api/api.js).
The input file is part of a project reference located at tsconfig.json, so ts-loader is looking for the project’s pre-built output on disk. Try running `tsc --build` to build project references.
    at successLoader (/src/node_modules/ts-loader/dist/index.js:46:19)
    at Object.loader (/src/node_modules/ts-loader/dist/index.js:22:12)
 @ ./portal/assets/scripts/actions/Dashboard.tsx 28:0-129 42:15-37 43:19-37 44:23-45 45:16-41
 @ ./portal/assets/scripts/router.ts
 @ ./portal/assets/scripts/index.tsx
./assets/scripts/api/methods.ts

Steps to Reproduce the Problem

Typescript: v3.6.3
ts-loader: v6.1.0

yarn run comparison-tests --single-test projectReferencesNotBuilt                                                    09/17 15:40:15 121.372s
yarn run v1.17.3
$ tsc --project "./test/comparison-tests" && npm link ./test/comparison-tests/testLib && node test/comparison-tests/run-tests.js --single-test projectReferencesNotBuilt
npm WARN lib@0.0.1 No repository field.
npm WARN lib@0.0.1 No license field.

up to date in 0.276s
found 0 vulnerabilities

/Users/justin/.fnm/node-versions/v12.3.1/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib
/src/ts-loader/node_modules/lib -> /Users/justin/.fnm/node-versions/v12.3.1/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib

-------------------------------------------------------------------------

Starting to run test suites...



  projectReferencesNotBuilt
    1) should have the correct output
    ✓ should work with transpileOnly (292ms)


  1 passing (2s)
  1 failing

  1) projectReferencesNotBuilt
       should have the correct output:

      Uncaught AssertionError [ERR_ASSERTION]: bundle.js is different between actual and expected
      + expected - actual

       /*!**********!*/
         !*** ./lib/index.ts ***!
         /**********/
       /*! no static exports found */
      -/***/ (function(module, exports, __webpack_require__) {
      -"use strict";
      -eval("
      -exports.__esModule = true;
      -exports.lib = {
      -    one: 1,
      -    two: 2,
      -    three: 3
      -};
      +/***/ (function(module, exports) {
      +eval("throw new Error(/"Module build failed (fromts-loader):/nError: Could not find output JavaScript file for input lib/index.ts (looked at lib/index.js)./nThe input file is part of a project reference located at lib/tsconfig.json, so ts-loader is looking for the project’s pre-built output on disk. Try running `tsc --build` to build project references./n    at successLoader (ts-loader)/n    at Object.loader (ts-loader)/");
       /# sourceURL=webpack://./lib/index.ts?");
       /***/ })
       /******/ });

      at compareActualAndExpected (test/comparison-tests/create-and-execute-test.js:467:16)
      at /src/ts-loader/test/comparison-tests/create-and-execute-test.js:333:13
      at Array.forEach (<anonymous>)
      at compareFiles (test/comparison-tests/create-and-execute-test.js:329:31)
      at Watching.handler (test/comparison-tests/create-and-execute-test.js:194:9)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:100:9
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._done (node_modules/webpack/lib/Watching.js:99:28)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:73:19
      at Compiler.emitRecords (node_modules/webpack/lib/Compiler.js:366:39)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:54:20
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:352:14
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:349:27
      at done (node_modules/neo-async/async.js:2854:11)
      at /src/ts-loader/node_modules/neo-async/async.js:2805:7
      at /src/ts-loader/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.oncomplete (fs.js:137:23)
@johnnyreilly
Copy link
Member

There's work in progress by @sheetalkamat here:

#1003

It might be worth testing her PR and seeing if that fixes you. We'd love to hear back if it does

@johnnyreilly
Copy link
Member

Should be fixed with V6.1.1

@jleider
Copy link
Author

jleider commented Sep 20, 2019

I see that the tests have been updated: https://github.com/TypeStrong/ts-loader/pull/1003/files#diff-18ab58ce03516261da5fb32ec3f05984R108 and I dont get that error anymore but I also still get all the other definition files have not been built from source errors from referenced projects. Is there a new config option I'm missing?

Output file 'assets/scripts/lib/util/exhaustive.d.ts' has not been built from source file '/assets/scripts/util/exhaustive.ts'.

@johnnyreilly @sheetalkamat this still seems to be an issue with v6.1.1. Could you please reopen?

@jleider
Copy link
Author

jleider commented Sep 20, 2019

I pulled down the latest updates locally and ran the tests again. I am still getting the following test failures.

Additionally, one thing I have noticed about the tests is that they are missing the declaration: true option that is specified as required for project references: https://www.typescriptlang.org/docs/handbook/project-references.html#composite

yarn run comparison-tests --single-test projectReferencesNotBuilt                                                                09/20 12:50:32 7.927s
yarn run v1.17.3
$ git clean -xfd test/comparison-tests && tsc --project "./test/comparison-tests" && npm link ./test/comparison-tests/testLib && node test/comparison-tests/run-tests.js --single-test projectReferencesNotBuilt
npm WARN lib@0.0.1 No repository field.
npm WARN lib@0.0.1 No license field.

up to date in 0.574s
found 0 vulnerabilities

/Users/justin/.fnm/node-versions/v11.15.0/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib
/src/ts-loader/node_modules/lib -> /Users/justin/.fnm/node-versions/v11.15.0/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib

-------------------------------------------------------------------------

Starting to run test suites...



  projectReferencesNotBuilt
    1) should have the correct output
    2) should work with transpileOnly


  0 passing (2s)
  2 failing

  1) projectReferencesNotBuilt
       should have the correct output:

      Uncaught AssertionError [ERR_ASSERTION]: output.txt is different between actual and expected
      + expected - actual

           Asset     Size  Chunks             Chunk Names
      -bundle.js A-NUMBER-OF KiB main  [emitted]  main
      +                  bundle.js A-NUMBER-OF KiB main  [emitted]  main
      +          ../lib/index.d.ts A-NUMBER-OF bytes [emitted]
      +../lib/tsconfig.tsbuildinfo A-NUMBER-OF KiB [emitted]
       Entrypoint main = bundle.js
       [./app.ts] A-NUMBER-OF bytes {main} [built]
      -[./lib/index.ts] A-NUMBER-OF bytes {main} [built]
      -ERROR in tsconfig.json
      -[tsl] ERROR
      -      TS6305: Output file 'index.d.ts' has not been built from source file 'index.ts'.
      +[./lib/index.ts] A-NUMBER-OF bytes {main} [built]

      at compareActualAndExpected (test/comparison-tests/create-and-execute-test.js:470:16)
      at /src/ts-loader/test/comparison-tests/create-and-execute-test.js:338:13
      at Array.forEach (<anonymous>)
      at compareFiles (test/comparison-tests/create-and-execute-test.js:334:31)
      at Watching.handler (test/comparison-tests/create-and-execute-test.js:199:9)
      at compiler.hooks.done.callAsync (node_modules/webpack/lib/Watching.js:100:9)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._done (node_modules/webpack/lib/Watching.js:99:28)
      at compiler.emitRecords.err (node_modules/webpack/lib/Watching.js:73:19)
      at Compiler.emitRecords (node_modules/webpack/lib/Compiler.js:366:39)
      at compiler.emitAssets.err (node_modules/webpack/lib/Watching.js:54:20)
      at hooks.afterEmit.callAsync.err (node_modules/webpack/lib/Compiler.js:352:14)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at asyncLib.forEach.err (node_modules/webpack/lib/Compiler.js:349:27)
      at done (node_modules/neo-async/async.js:2854:11)
      at /src/ts-loader/node_modules/neo-async/async.js:2805:7
      at /src/ts-loader/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.args [as oncomplete] (fs.js:145:20)

  2) projectReferencesNotBuilt
       should work with transpileOnly:

      Uncaught AssertionError [ERR_ASSERTION]: bundle.js is different between actual and expected
      + expected - actual

       /*!**********!*/
         !*** ./lib/index.ts ***!
         /**********/
       /*! no static exports found */
      -/***/ (function(module, exports) {
      -eval("throw new Error(/"Module build failed (fromts-loader):/nError: Could not find output JavaScript file for input lib/index.ts (looked at lib/index.js)./nThe input file is part of a project reference located at lib/tsconfig.json, so ts-loader is looking for the project’s pre-built output on disk. Try running `tsc --build` to build project references./n    at successLoader (ts-loader)/n    at Object.loader (ts-loader)/");
      +/***/ (function(module, exports, __webpack_require__) {
      +"use strict";
      +eval("
      +Object.defineProperty(exports, /"__esModule/", { value: true });
      +exports.lib = {
      +    one: 1,
      +    two: 2,
      +    three: 3
      +};
       /# sourceURL=webpack://./lib/index.ts?");
       /***/ })
       /******/ });

      at compareActualAndExpected (test/comparison-tests/create-and-execute-test.js:470:16)
      at /src/ts-loader/test/comparison-tests/create-and-execute-test.js:338:13
      at Array.forEach (<anonymous>)
      at compareFiles (test/comparison-tests/create-and-execute-test.js:334:31)
      at Watching.handler (test/comparison-tests/create-and-execute-test.js:199:9)
      at compiler.hooks.done.callAsync (node_modules/webpack/lib/Watching.js:100:9)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._done (node_modules/webpack/lib/Watching.js:99:28)
      at compiler.emitRecords.err (node_modules/webpack/lib/Watching.js:73:19)
      at Compiler.emitRecords (node_modules/webpack/lib/Compiler.js:366:39)
      at compiler.emitAssets.err (node_modules/webpack/lib/Watching.js:54:20)
      at hooks.afterEmit.callAsync.err (node_modules/webpack/lib/Compiler.js:352:14)
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at asyncLib.forEach.err (node_modules/webpack/lib/Compiler.js:349:27)
      at done (node_modules/neo-async/async.js:2854:11)
      at /src/ts-loader/node_modules/neo-async/async.js:2805:7
      at /src/ts-loader/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.args [as oncomplete] (fs.js:145:20)

@johnnyreilly johnnyreilly reopened this Sep 20, 2019
@johnnyreilly
Copy link
Member

Thanks for the details - @sheetalkamat it seems there might still be some issues.

@jleider what os are you running? Our CI runs on Linux and Windows so I'm kind of surprised you still have failing tests..

@sheetalkamat
Copy link
Contributor

@jleider the lib folder in that test has composite set which is referenced in the project. What is your typescript version that you are using. Are you at master and latest commit for ts-loader

@jleider
Copy link
Author

jleider commented Sep 20, 2019

I am using MacOS v10.14.6. I tested with both Node v11.15 and v12.8. TypeScript version v3.6.3 for my own project and whatever ts-loader requires for the tests. I sync'ed my own fork of ts-loader from the upstream TypeStrong/ts-loader and pulled the latest master then ran yarn install --force right before running the tests locally.

@jleider
Copy link
Author

jleider commented Sep 20, 2019

Also, I suspected that fork-ts-checker-webpack-plugin could be causing issues in my own project so I removed that from my webpack config and tried with transpileOnly: false and get this TypeScript error which seems like an actual TSC compiler bug when I google for the error.

[12:40:11] Error: Debug Failure. False expression.
    at Object.getOutputDeclarationFileName (/src/node_modules/typescript/lib/typescript.js:86168:18)
    at getOutputFileNames (/src/node_modules/ts-loader/dist/instances.js:262:43)
    at /src/node_modules/ts-loader/dist/instances.js:281:13
    at worker (/src/node_modules/ts-loader/dist/instances.js:211:32)
    at forEachResolvedProjectReference (/src/node_modules/ts-loader/dist/instances.js:198:12)
    at getOutputFilesFromReference (/src/node_modules/ts-loader/dist/instances.js:273:12)
    at Object.getEmitOutput (/src/node_modules/ts-loader/dist/instances.js:302:37)
    at provideDeclarationFilesToWebpack (/src/node_modules/ts-loader/dist/after-compile.js:185:41)
    at /src/node_modules/ts-loader/dist/after-compile.js:24:9
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/src/web/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)

@sheetalkamat
Copy link
Contributor

The assert is fixed by #1015

@jleider
Copy link
Author

jleider commented Sep 23, 2019

@sheetalkamat I have three things to report:

  1. Between the 6.1.1 and 6.2.2 changes this is mostly working! However, there is still one issue that seems to be a race condition. The first time a project is built which contains a project reference, the referenced project will be built on the first run but the exported .d.ts files are not "present" for the compile of the parent project until the second run.

  2. If there are any .tsbuildinfo files hanging around from a previous build but there are no exported files due to being removed from the file system the .d.ts files will never be rebuilt. I am not sure if this is a ts-loader issue or if that is expected behavior of the tsc compiler in which case a user must tsc --force, tsc --clean the project or remove the .tsbuildinfo files first.

  3. There is an unexpected behavior of the placement of the .tsbuildinfo file. By default according to the ts compiler options, the .tsbuildinfo file should be located in the same directory as the tsconfig file. However, I see it being written to disk one level up from my rootDir or two directories up from my outDir. For example, if rootDir: "./assets/scripts and outDir: "./assets/scripts/lib" then the .tsbuildinfo file is written to ./assets/tsconfig.tsbuildinfo instead of what I would expect to be ./tsconfig.tsbuildinfo. Setting the tsBuildInfoFile: "./tsconfig.tsbuildinfo" directly gets around this issue but I don't think should be necessary.

@sheetalkamat
Copy link
Contributor

1> Repro is needed since I don't see this when I run test locally
2> As you guessed that is working as intended and same as what tsc does.
3> Again repro is needed to investigate.

@jleider
Copy link
Author

jleider commented Sep 23, 2019

The repro for 1> is the existing test which fails: yarn run comparison-tests --single-test projectReferencesNotBuilt

yarn run comparison-tests --single-test projectReferencesNotBuilt                                                                                         09/23 13:36:23 115.637s
yarn run v1.17.3
$ git clean -xfd test/comparison-tests && tsc --project "./test/comparison-tests" && npm link ./test/comparison-tests/testLib && node test/comparison-tests/run-tests.js --single-test projectReferencesNotBuilt
npm WARN lib@0.0.1 No repository field.
npm WARN lib@0.0.1 No license field.

up to date in 0.353s
found 0 vulnerabilities

/Users/justin/.fnm/node-versions/v12.3.1/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib
/src/ts-loader/node_modules/lib -> /Users/justin/.fnm/node-versions/v12.3.1/installation/lib/node_modules/lib -> /src/ts-loader/test/comparison-tests/testLib

-------------------------------------------------------------------------

Starting to run test suites...



  projectReferencesNotBuilt
    1) should have the correct output
    2) should work with transpileOnly


  0 passing (2s)
  2 failing

  1) projectReferencesNotBuilt
       should have the correct output:

      Uncaught AssertionError [ERR_ASSERTION]: output.txt is different between actual and expected
      + expected - actual

           Asset     Size  Chunks             Chunk Names
      -bundle.js A-NUMBER-OF KiB main  [emitted]  main
      +                  bundle.js A-NUMBER-OF KiB main  [emitted]  main
      +          ../lib/index.d.ts A-NUMBER-OF bytes [emitted]
      +../lib/tsconfig.tsbuildinfo A-NUMBER-OF KiB [emitted]
       Entrypoint main = bundle.js
       [./app.ts] A-NUMBER-OF bytes {main} [built]
      -[./lib/index.ts] A-NUMBER-OF bytes {main} [built]
      -ERROR in tsconfig.json
      -[tsl] ERROR
      -      TS6305: Output file 'index.d.ts' has not been built from source file 'index.ts'.
      +[./lib/index.ts] A-NUMBER-OF bytes {main} [built]

      at compareActualAndExpected (test/comparison-tests/create-and-execute-test.js:470:16)
      at /src/ts-loader/test/comparison-tests/create-and-execute-test.js:338:13
      at Array.forEach (<anonymous>)
      at compareFiles (test/comparison-tests/create-and-execute-test.js:334:31)
      at Watching.handler (test/comparison-tests/create-and-execute-test.js:199:9)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:100:9
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._done (node_modules/webpack/lib/Watching.js:99:28)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:73:19
      at Compiler.emitRecords (node_modules/webpack/lib/Compiler.js:366:39)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:54:20
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:352:14
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:349:27
      at done (node_modules/neo-async/async.js:2854:11)
      at /src/ts-loader/node_modules/neo-async/async.js:2805:7
      at /src/ts-loader/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.oncomplete (fs.js:137:23)

  2) projectReferencesNotBuilt
       should work with transpileOnly:

      Uncaught AssertionError [ERR_ASSERTION]: bundle.js is different between actual and expected
      + expected - actual

       /*!**********!*/
         !*** ./lib/index.ts ***!
         /**********/
       /*! no static exports found */
      -/***/ (function(module, exports) {
      -eval("throw new Error(/"Module build failed (fromts-loader):/nError: Could not find output JavaScript file for input lib/index.ts (looked at lib/index.js)./nThe input file is part of a project reference located at lib/tsconfig.json, so ts-loader is looking for the project’s pre-built output on disk. Try running `tsc --build` to build project references./n    at successLoader (ts-loader)/n    at Object.loader (ts-loader)/");
      +/***/ (function(module, exports, __webpack_require__) {
      +"use strict";
      +eval("
      +Object.defineProperty(exports, /"__esModule/", { value: true });
      +exports.lib = {
      +    one: 1,
      +    two: 2,
      +    three: 3
      +};
       /# sourceURL=webpack://./lib/index.ts?");
       /***/ })
       /******/ });

      at compareActualAndExpected (test/comparison-tests/create-and-execute-test.js:470:16)
      at /src/ts-loader/test/comparison-tests/create-and-execute-test.js:338:13
      at Array.forEach (<anonymous>)
      at compareFiles (test/comparison-tests/create-and-execute-test.js:334:31)
      at Watching.handler (test/comparison-tests/create-and-execute-test.js:199:9)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:100:9
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at Watching._done (node_modules/webpack/lib/Watching.js:99:28)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:73:19
      at Compiler.emitRecords (node_modules/webpack/lib/Compiler.js:366:39)
      at /src/ts-loader/node_modules/webpack/lib/Watching.js:54:20
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:352:14
      at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
      at AsyncSeriesHook.lazyCompileHook (node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
      at /src/ts-loader/node_modules/webpack/lib/Compiler.js:349:27
      at done (node_modules/neo-async/async.js:2854:11)
      at /src/ts-loader/node_modules/neo-async/async.js:2805:7
      at /src/ts-loader/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqCallback.oncomplete (fs.js:137:23)

@sheetalkamat
Copy link
Contributor

But the test doesn't fail either on CI or on my machine so that's not a repro at my end....

@jleider
Copy link
Author

jleider commented Sep 23, 2019

Looks like I hadn't rebuilt the src before running the tests. That test passes now. However, I don't have a repro for you at this moment since our code base is private but it is still an issue. I will try to come up with a repro in the next couple days.

One other thing to note is that even when the referenced projects are built, our compile time increases from ~30s to ~1m20s. Maybe its related to this? #988 Although we use react, not vue.

@johnnyreilly
Copy link
Member

Thanks for reporting this stuff in detail @jleider - it's super helpful

@zoltanbedi
Copy link

I've tried this new projectReferences option and while it builds the references projects for the first time it does not pick up changes when I change something in a referenced project. Is this the desired behavior?

@johnnyreilly
Copy link
Member

Doesn't sound like it - minimal repro repos are helpful. Could you provide one please? cc @andrewbranch @sheetalkamat

@zoltanbedi
Copy link

zoltanbedi commented Sep 30, 2019

Repro:

  1. git clone -b ts-loader-repro https://github.com/SenseNet/sn-client.git
  2. run yarn install in the root
  3. run yarn build
  4. run yarn snapp start
  5. add a console.log to packages/sn-hooks-react/src/context/logger.tsx (this is where I would expect that webpack will build again)

@johnnyreilly
Copy link
Member

Thanks @B3zo0! Hopefully someone can take a look at this now you've put this together

@niba
Copy link

niba commented Oct 1, 2019

I've just migrated to the latest ts-loader to test a new project references and I have the same problem as @jleider.

My fresh build always throws a few "Output file [NAME] has not been built from source file [NAME]". I don't have this problem when I use tsc directly. To fix the errors I need to do a manual build using tsc compiler before executing webpack.
Tested on Windows with typescript 3.6.3, ts-loader 6.2.0 and node 12.11.0

Unfortunately, the project is private so I can't share it

@johnnyreilly
Copy link
Member

Thanks for reporting @niba. I appreciate you can't share the private repo, but I'm afraid without a minimal repro repo it's hard to make progress.

Just in terms of expectation management, I'm presently snowed with other work and so can't look at this. If @sheetalkamat or @andrewbranch (or anyone else who is so minded) is able to I'll be hugely grateful. However, I'm mindful that everyone has a day job and this is open source; we rely on people pitching in to keep going.

@sheetalkamat
Copy link
Contributor

@B3zo0 Thank you for repro, I could see that change in mentioned file didn't restart compilation. However your project is too large for me to investigate this in limited time. Can you or someone on this thread create small repro so I can look into it? Someone somewhere mentioned it has to do with transpileOnly option so in your config I removed that and still see the issue. So its definitely not just transpileOnly (also we have tests that work correctly for both transpile and non transpile modes)

@Juraj-Masiar
Copy link

Hi, I have a problem after upgrading from 6.0.4 to 6.2.1 and from what I can see in the @jleider comment #1005 (comment), I would say it's related.
This is my stack trace:

(node:17092) UnhandledPromiseRejectionWarning: Error: invalid relative path: ../../../addons/GroupSpeedDial/tsconfig.tsbuildinfo
    at validateMetadataPath (C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\yazl\index.js:368:59)
    at ZipFile.addBuffer (C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\yazl\index.js:62:18)
    at C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\zip-webpack-plugin\index.js:46:12
    at _next6 (eval at create (C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:29:1)
    at eval (eval at create (C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:45:1)
    at C:\Users\Juraj\git\addons\GroupSpeedDial\node_modules\html-webpack-plugin\index.js:224:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

Even though the error seems to originate from zip-webpack-plugin library, the problem itself is the misplaced tsconfig.tsbuildinfo file, which I don't have in my repository, definitely not at root path /GroupSpeedDial/tsconfig.tsbuildinfo.
Downgrade to 6.0.4 fixes the problem.

@johnnyreilly
Copy link
Member

johnnyreilly commented Nov 4, 2019

cc @sheetalkamat for info - suspect this may be related to recent project references work.

@stale
Copy link

stale bot commented Jan 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 3, 2020
@johnnyreilly johnnyreilly added pinned don't let probot-stale close and removed wontfix labels Jan 3, 2020
@andrewhathaway
Copy link

andrewhathaway commented Jan 11, 2021

Hi all - Not just wanting to +1 this, but I am also seeing this with ts-loader@8.0.14, webpack@5.12.3, typescript@4.1.3 and fork-ts-checker-webpack-plugin@6.0.5. Are there any updated recommendations on this?

Update 16/01/21:
Turns out that extends also excludes references, as well as other fields which was causing my problem due to my tsconfig.development.json and tsconfig.production.json files incase this helps anyone else!

@leppaott
Copy link

For me only 2nd webpack build works, first one doesn't find the project reference build/src directory when importing the files. It's the ForkTsCheckerPlugin, without it works fine. We also removed extend tsconfigs so wasn't it. We're working to remove project references as they cause so much headache.

@damiangreen
Copy link

damiangreen commented Nov 15, 2022

I removed this plugin and still get the error. Is there a workaround at all for this? should i somehow manually build each reference project?
I'm using
"fork-ts-checker-notifier-webpack-plugin": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^7.2.13",
"typescript": "^4.8.4",
"ts-loader": "^9.4.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned don't let probot-stale close
Projects
None yet
Development

No branches or pull requests

9 participants