I have the minimal Typescript+Webpack setup from the doc, with the following files :
Files
- src/
- index.ts // only a console.log in here
- unused.ts // only a console.log + type error in here
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
}
}
webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};
Problem
When I run a webpack build
, it fails and show the type error in unused.ts
even though it isn't an entrypoint nor in the descending import tree from one.
This is very problematic in my context as the real, huge, project is beneath a Perforce versionning server... which... leave the workspace in an unstable state when we switch streams (old files aren't cleaned and can contain no-more-revelant typings which fails the build)
=> Do you know any way to tell webpack "only parse the import tree from entrypoints"? (or any workaround to clean all unused files before build?)