I'm currently facing a challenge while attempting to consolidate all the files in my Typescript project, along with their dependencies from node_modules, into a single file using Webpack. Despite trying multiple options, it seems that only the entry file is being included in the output:
Below are examples of some Typescript files with dependencies:
app/test1.ts:
import {x} from 'app/test2';
let y = x + 1;
app/test2.ts:
export let x = 123;
The configuration in the Webpack file is as follows:
module.exports = {
entry: {
'app/startup' : './app/test1'
},
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
},
resolve: {
modules: [
'node_modules'
],
extensions: ['.ts', '.js']
},
};
Moreover, here is an excerpt from the tsconfig.json file:
{
"atom": {
"rewriteTsconfig": false
},
"compilerOptions": {
** Compiler options described **
},
"filesGlob": [
"app/**/*.ts",
],
"exclude": [
"node_modules",
],
"files": [
]
}
Despite including the standard content at the beginning of the bundle, it appears that "app/test2" is missing:
System.register(["app/test2"], function (exports_1, context_1) {
** Code block mentioned **
});
I'm unsure why Test2 is not getting bundled. What could possibly be going wrong here? How can I ensure that all node_module dependencies are also included?
In an attempt to resolve this issue, I tried replicating the settings from this sample project without success: https://github.com/blacksonic/typescript-webpack-tree-shaking