I'm using webpack 1.13.3, and in reply to this question I provided my tsconfig.json at bottom.
My loader is always including the node_modules packages no matter if I use include, exclude or combination of both.
webpack config:
var path = require("path");
module.exports = {
entry: "./src/bootstrap.tsx",
output: {
filename: "./public/dist/bundle.js",
},
// Enable sourcemaps for debugging webpack's output.
devtool: "cheap-module-source-map",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
},
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{ include: path.resolve(__dirname, "src"), exclude: /node_modules/, test: /\.tsx?$/, loader: "ts-loader" }
],
preLoaders: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, loader: "source-map-loader" }
]
},
};
I've tried all sorts of combination:
1) Only include with regex /src/ or with direct path.resolve(__dirname, "src")
2) Only exclude using regex /node_modules/ or with direct path.resolve(__dirname, "node_modules")
3) I've tried using both at same time include and exclude.
I'm always getting error from my ts-loader for files inside node_modules, i.e:
ERROR in /path/to/prj/node_modules/@types/enzyme/index.d.ts
(337,22): error TS2304: Cannot find name 'ComponentClass'.
Not sure what to do, from what I can understand the exclude/include in loader config is suppose to indicate to webpack to include or exclude file to be transformed, how can node_modules files are always included?
EDIT 1: In case it matter, this is my tsconfig.json
{
"compilerOptions": {
"outDir": "./public/dist",
"target": "es5",
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"sourceMap": true,
"jsx": "react"
},
"include": [
"./src/**/*.tsx",
"./src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
"skipLibCheck": trueand"skipDefaultLibCheck": true? - Mouneer