-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
59 lines (57 loc) · 1.45 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { readFile } from 'fs/promises';
import * as path from 'path';
import { default as ModuleFederationPlugin } from 'webpack/lib/container/ModuleFederationPlugin.js';
// @ts-ignore TS2691 ts-node/esm loader fails when missing extension here
import { modulesDirectory } from './build.config.ts';
import { BundleJson } from './src/lib/bundle-json';
const bundleJson: BundleJson = JSON.parse(await readFile('vaadin-bundle.json', { encoding: 'utf8' }));
const exposes = Object.entries(bundleJson.packages)
.flatMap(([packageName, packageInfo]) =>
Object.keys(packageInfo.exposes).map((modulePath) => `${packageName}${modulePath.substring(1)}`)
)
.reduce<Record<string, string>>((exposes, moduleSpecifier) => {
exposes[`./node_modules/${moduleSpecifier}`] = `${modulesDirectory}/${moduleSpecifier}`;
return exposes;
}, {});
export default {
mode: 'development',
entry: {
vaadin: './src/vaadin.js'
},
resolve: {
symlinks: false,
conditionNames: [
'development'
]
},
module: {
rules: [
{
test: /\.m?js$/,
resolve: {
fullySpecified: false
}
}
]
},
devtool: 'source-map',
experiments: {
outputModule: true
},
output: {
path: path.resolve(''),
filename: '[name].js',
library: {
type: 'module'
}
},
plugins: [
new ModuleFederationPlugin({
name: 'vaadin',
library: {
type: 'module'
},
exposes
})
]
};