Open
Description
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 [email protected] No repository field.
npm WARN [email protected] 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)