Fix crashes with usages of @k8slens/core/common

- Only observable with extensions

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-02-02 09:54:24 -05:00
1 parent 5002b450fd
commit 7c18c2a23b
13 files changed
+95 -129

No files matched your search

-37
View File
@@ -1,37 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type webpack from "webpack";
import path from "path";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import webpackLensMain from "./main";
import { buildDir } from "./vars";
const webpackLensCommon = (): webpack.Configuration => {
const mainConfig = webpackLensMain();
return {
...mainConfig,
name: "lens-app-common",
entry: {
common: path.resolve(__dirname, "..", "src", "common", "library.ts"),
},
output: {
publicPath: "",
library: {
type: "commonjs2",
},
path: path.resolve(buildDir, "library"),
},
optimization: {
minimize: false,
},
plugins: [
new ForkTsCheckerPlugin({}),
],
};
};
export default webpackLensCommon;
+1 -3
View File
@@ -3,14 +3,12 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import webpackLensCommon from "./common";
import webpackLensMain from "./main";
import { webpackLensMain } from "./main";
import { webpackLensRenderer } from "./renderer";
const config = [
webpackLensMain(),
webpackLensRenderer(),
webpackLensCommon(),
];
export default config;
+60 -64
View File
@@ -12,76 +12,72 @@ import { DefinePlugin } from "webpack";
import { buildDir, isDevelopment } from "./vars";
import { platform } from "process";
const webpackLensMain = (): webpack.Configuration => {
return {
name: "lens-app-main",
context: __dirname,
target: "electron-main",
mode: isDevelopment ? "development" : "production",
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
main: path.resolve(__dirname, "..", "src", "main", "library.ts"),
export const webpackLensMain = (): webpack.Configuration => ({
name: "lens-app-main",
context: __dirname,
target: "electron-main",
mode: isDevelopment ? "development" : "production",
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
main: path.resolve(__dirname, "..", "src", "main", "library.ts"),
},
output: {
library: {
type: "commonjs2",
},
output: {
library: {
type: "commonjs2",
path: path.resolve(buildDir, "library"),
},
optimization: {
minimize: false,
},
resolve: {
extensions: [".json", ".js", ".ts"],
},
externals: [
nodeExternals(),
],
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
path: path.resolve(buildDir, "library"),
},
optimization: {
minimize: false,
},
resolve: {
extensions: [".json", ".js", ".ts"],
},
externals: [
nodeExternals(),
],
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
sourceMap: false,
},
},
},
},
...iconsAndImagesWebpackRules(),
],
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(main|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
new ForkTsCheckerPlugin({
typescript: {
mode: "write-dts",
configOverwrite: {
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
declaration: true,
sourceMap: false,
},
},
},
}),
},
...iconsAndImagesWebpackRules(),
],
};
};
export default webpackLensMain;
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(main|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
new ForkTsCheckerPlugin({
typescript: {
mode: "write-dts",
configOverwrite: {
compilerOptions: {
declaration: true,
},
},
},
}),
],
});