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
Sebastian Malton f8ac072df9 chore: fix some packages required prepare scripts
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-04-14 14:42:00 -04:00

73 lines
1.5 KiB
JavaScript

const ForkTsCheckerPlugin = require("fork-ts-checker-webpack-plugin");
const { MakePeerDependenciesExternalPlugin } = require("./plugins/make-peer-dependencies-external");
const { ProtectFromImportingNonDependencies } = require("./plugins/protect-from-importing-non-dependencies");
/**
*
* @returns {import("webpack").Configuration}
*/
module.exports = ({ entrypointFilePath, outputDirectory }) => ({
name: entrypointFilePath,
entry: { index: entrypointFilePath },
target: "node",
mode: "production",
performance: {
maxEntrypointSize: 100000,
hints: "error",
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
},
plugins: [
new MakePeerDependenciesExternalPlugin(),
new ProtectFromImportingNonDependencies(),
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`,
library: {
type: "commonjs2"
}
},
externalsPresets: { node: true },
node: {
__dirname: true,
__filename: true,
},
module: {
rules: [
{
test: /\.ts(x)?$/,
loader: "ts-loader",
},
],
},
});