Skip to content

Commit 51fcbba

Browse files
chore: add clarifying comments in webpack config
1 parent 63b7d83 commit 51fcbba

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

webpack.config.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@ module.exports = {
1313
output: {
1414
path: path.resolve(__dirname, "dist"),
1515
filename: "[name].cjs",
16+
// For both cli and lib, we want to output CommonJS modules because
17+
// vscode extension unfortunately still uses classic node module
18+
// resolution and to be able to use our mcp exports there we need to
19+
// compile to CommonJS.
20+
//
21+
// The CLI entrypoint does not care if its CommonJS
22+
// or ESM so to keep configuration simple we compile both to CommonJS.
1623
libraryTarget: "commonjs2",
1724
clean: {
25+
// We emit types separately so if they are in the output directory
26+
// we want to keep them.
1827
keep: "types",
1928
},
2029
},
2130
resolve: {
2231
extensions: [".ts", ".js"],
32+
// This is necessary because our repo is a module and that requires us
33+
// to write complete path imports. This however does not resolve
34+
// correctly when inside the bundler which is why we use the
35+
// extensionAlias.
2336
extensionAlias: {
2437
".js": [".ts", ".js"],
2538
".mjs": [".mts", ".mjs"],

0 commit comments

Comments
 (0)