No useful logging, it still insist on using tsconfig.json
randre70 opened this issue · comments
No matter how I write the webpack config or the references tsconfig.src.json, it just logs about a tsconfig.json file which does not even exists.
Error message/log:
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
ts-loader: Using typescript@3.8.3
Hash: 680b9ad10fb721c48d9c
Version: webpack 4.41.6
Time: 94ms
Built at: 03/01/2020 00:00:12
Asset Size Chunks Chunk Names
index.js 8.91 KiB main [emitted] main
Entrypoint main = index.js
chunk {main} index.js (main) 275 bytes [entry] [rendered]
> main
[0] multi ./src/index.ts 28 bytes {main} [depth 0] [built]
multi entry
[./src/index.ts] 247 bytes {main} [depth 1] [built] [failed] [2 errors]
single entry ./src/index.ts [0] multi ./src/index.ts main[0]
LOG from webpack.buildChunkGraph.visitModules
<t> prepare: 0.5461ms
<t> visiting: 0.1703ms
ERROR in ./src/index.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json
at Object.loader (c:\Users\rene\Documents\git\tests\color-picker\node_modules\ts-loader\dist\index.js:19:18)
@ multi ./src/index.ts main[0]
ERROR in [tsl] ERROR
TS18002: The 'files' list in config file 'tsconfig.json' is empty.
@ multi ./src/index.ts main[0]
The npm script I use
...
"scripts": {
"build": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --config webpack.config.ts --display verbose",
...
My webpack config
...
export default <webpack.Configuration>{
bail: true,
context: process.cwd(),
stats: "verbose",
devtool: 'inline-cheap-source-map',
mode: 'development',
target: 'web',
entry: [
'./src/index.ts'
],
externals: [],
module: {
rules: [
{
test: /\.tsx?$/,
include: path.resolve(__dirname, 'src'),
// include: /src\/preload/,
use: {
loader: 'ts-loader',
options: <tsl.Options> {
silent: false,
logLevel: "INFO",
logInfoToStdOut: true,
colors: true,
configFile: './tsconfig.src.json',
transpileOnly: true,
allowTsInNodeModules: true
} as tsl.Options
}
}
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
resolve: {
plugins: [
new TsconfigPathsPlugin({
// baseUrl: './src',
configFile: './tsconfig.src.json',
logInfoToStdOut: true,
logLevel: 'INFO',
silent: false
})
]
}
};
My tsconfig.src.json
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"module": "commonjs",
"noImplicitAny": true,
"outDir": "dist/",
"declaration": true,
"declarationDir": "dist/",
"paths": {
"*": ["./node_modules/*"]
},
"lib": [
"es2017",
"DOM"
],
"types": [
],
"extendedDiagnostics": true,
"listEmittedFiles": true,
"listFiles": true,
"sourceMap": false,
"inlineSourceMap": true,
"inlineSources": true
},
"files": [
"./src/index.ts"
],
"exclude": [
"dist",
"node_modules",
"test"
]
}
My tsconfig.webpack.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"esModuleInterop": true
}
}
what else can I do?
Got it.
tsconfig-paths module always evaluates TS_NODE_PROJECT env variable which is already present to have a webpack config in typescript.
So tsconfig-paths is to blame, since it doesn't log that it didn't find "./tsconfig.src.json/tsconfig.webpack.json" and that it falls back to "tsconfig.json" which doesn't exist and it doesn't log about that as well ...
BTW:
To solve the issue I added at beginning of webpack.config.ts:
delete process.env["TS_NODE_PROJECT"];