Bug with extends property in tsconfig
See original GitHub issueIssue
Right now, when I use a tsconfig file that extends another config file, the paths defined in the base config file are not recognized by tsconfig-paths-webpack-plugin. Sample config files:
// tsconfig.browser.json
{
"compilerOptions": {
...
"baseUrl": "../",
"paths": {
"@injector/*": ["src/browser/injector/*"],
"@records/*": ["src/browser/records/*"],
"@services/*": ["src/browser/services/*"],
"@shared-components/*": ["src/browser/shared-components/*"],
"@signals/*": ["src/browser/signals/*"],
"*": [
"*",
"src/browser/@types/*"
]
}
},
"include": [
"../src/browser/**/*"
],
"exclude": [
"../src/electron/**/*"
]
}
// tsconfig.test
{
"extends": "./tsconfig.browser",
"compilerOptions": {
"outDir": "../build-test",
"types": ["reflect-metadata", "webpack-env", "mocha"]
}
}
Output when using tsconfig-paths-webpack-plugin:
Failed to load tsconfig.json: Missing baseUrl in compilerOptions tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
Expected behavior
tsconfig-paths-webpack-plugin should read the extends
property to build the compiler options object so it can properly determine the proper values for baseUrl
and paths
in projects that utilize the extends
propert in their config files. See more detailed description here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html.
Possible solution
I think this is a bug with the loadTsConfig method in tsconfig-loader.ts. It’s assuming that config files mentioned in the extends
property will include a .json
file extension. However, that extension isn’t required by typescript. My suggestion would be to add .json
to the end of any string found in the extends
property that doesn’t already end in .json
.
EDIT: It looks like the guys who maintain tsconfig are working on the extends property right now (see https://github.com/TypeStrong/tsconfig/issues/21). It might be easier to bring in their project so you don’t have to do the tsconfig file parsing yourself.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
Just bumped into this issue. It doesn’t seem to be a missing
.json
suffix in my case – myextends
clause reads"extends": "../tsconfig.base.json"
, but I still getFailed to load tsconfig.json: Missing baseUrl in compilerOptions tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
@lostfictions If you could setup a sample repo that demonstrates the problem that would be very helpful.