ts-loader: Project References won't work if extends config file
Background
ts-load
version: 6.2.1
webpack
version: 4.28.3
webpack-cli
version: 3.3.10
tyepscript
version: 3.7.2
Given the following config files:
- tsconfig.json:
{
"extends": "../tsconfig-global.json",
"compilerOptions": {
"outDir": "./dist",
"strictNullChecks": false,
"rootDir": "./src",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"references": [{ "path": "../typescript-common" }],
"include": ["./src"]
}
- tsconfig-web.json (extends the TS config file above):
{
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": [
"dom",
"es5",
"scripthost",
"es2015.core",
"es2015.promise",
"es2017"
]
}
}
- Webpack config (use
tsconfig-web.json
to build TS code):
const path = require("path");
const webpack = require("webpack");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const configFile = path.resolve(__dirname, "../tsconfig-web.json");
module.exports = {
entry: "./src/createTransformer.ts",
mode: "production",
output: {
filename: "createTransformerForBrowser.js",
path: path.join(__dirname, "..", "dist"),
library: "createTransformer"
},
devtool: "source-map",
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "ts-loader",
options: {
configFile,
projectReferences: true
}
}
]
},
resolve: {
plugins: [
new TsconfigPathsPlugin({
configFile
})
],
extensions: [".tsx", ".ts", ".js"]
},
node: {
fs: "empty"
}
};
Actual Behaviour
Project reference doesn’t work. And you will find the following errors:
ERROR in xx/xx.ts
[tsl] ERROR in /xx/typescript-common/src/xxxxxx.ts(9,30)
TS6059: File '/xx/typescript-common/src/xx/xx.ts' is not under 'rootDir' '/xx'. 'rootDir' is expected to contain all source files.
Expected Behaviour
Should build without error.
However, if you either:
- add
"references": [{ "path": "../typescript-common" }],
totsconfig-web.json
- Or modify
webpack.config.js
to usetsconfig.json
to build (instead oftsconfig-web.json
)
the build will complete with no error.
Steps to Reproduce the Problem
See: https://github.com/t83714/sample-repo-ts-loader
Location of a Minimal Repository that Demonstrates the Issue.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 17 (1 by maintainers)
Closing as stale. Please reopen if you’d like to work on this further.
Please reopen !
https://github.com/TypeStrong/ts-loader/issues/911
Dup of this (closed, but not resolved) issue. Linking so we have more reference info.