my code is like this:
Foo.ts:
export module Foo {
export function load() { }
}
Bar.ts:
export module Bar {
export function load() { }
}
webpack.config.js:
const path = require('path');
module.exports = {
entry: {
"FooBar": ['./Foo.ts', './Bar.ts']
},
mode: 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
devtool: 'source-map',
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: ['[name]'],
libraryTarget: "window"
}
};
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true
},
"exclude": [
"node_modules"
]
}
The result however is, that only "Bar" becomes visible on the window object.

If I switch the two paths of the FooBar entry point, than only "Foo" becomes visible. If I put both modules Foo and Bar into Bar.ts, also having ./Bar.ts as the last path of the entry point, than both modules become visble on the window object. Some unintended overwriting or "the last one wins" behauvior is happening here. How to achieve that both modules become visible on the window object without putting them into the same .ts file?
I originally included glob in my webpack.config.js, to have it as dynamics as possible:
var glob = require('glob');
...
module.exports = {
entry: {
"FooBar": glob.sync('./*.ts*')
...
I would like to have all my .ts files become bundled into a single .js output file, but of course including all my modules.
