1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/infrastructure/webpack/src/get-node-config.js
Janne Savolainen 9d5461dd81
Make builds of TS-declarations more deterministic (#7248)
The cause for this was unknown, and was fixed by using "fork-ts-checker-webpack-plugin" instead of
"ts-loader".

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Co-authored-by: Iku-turso <mikko.aspiala@gmail.com>
2023-03-01 13:39:03 +02:00

79 lines
1.4 KiB
JavaScript

const ForkTsCheckerPlugin = require("fork-ts-checker-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const path = require("path");
module.exports = ({ entrypointFilePath, outputDirectory }) => ({
name: entrypointFilePath,
entry: { index: entrypointFilePath },
target: "node",
mode: "production",
performance: {
maxEntrypointSize: 100000,
hints: "error",
},
resolve: {
extensions: [".ts", ".tsx"],
},
plugins: [
new ForkTsCheckerPlugin({
typescript: {
mode: "write-dts",
configOverwrite: {
include: [entrypointFilePath],
compilerOptions: {
declaration: true,
declarationDir: outputDirectory,
},
},
},
}),
],
output: {
path: outputDirectory,
filename: (pathData) =>
pathData.chunk.name === "index"
? "index.js"
: `${pathData.chunk.name}/index.js`,
libraryTarget: "commonjs2",
},
externals: [
nodeExternals({ modulesFromFile: true }),
nodeExternals({
modulesDir: path.resolve(
__dirname,
"..",
"..",
"..",
"..",
"node_modules"
),
}),
],
externalsPresets: { node: true },
node: {
__dirname: true,
__filename: true,
},
module: {
rules: [
{
test: /\.ts(x)?$/,
loader: "ts-loader",
},
],
},
});