Try to fix problems with seperate chunks

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-02-02 14:28:40 -05:00
1 parent 361591f640
commit ed36b46e01
17 files changed
+363 -216

No files matched your search

+21 -26
View File
@@ -6,32 +6,27 @@
import type webpack from "webpack";
import path from "path";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import webpackLensMain from "./main";
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"),
export const webpackLensCommon = (): webpack.Configuration => ({
...webpackLensMain(),
name: "lens-app-common",
entry: {
common: path.resolve(__dirname, "..", "src", "common", "library.ts"),
},
dependencies: [],
output: {
publicPath: "",
library: {
type: "commonjs2",
},
output: {
publicPath: "",
library: {
type: "commonjs2",
},
path: path.resolve(buildDir, "library"),
},
optimization: {
minimize: false,
},
plugins: [
new ForkTsCheckerPlugin({}),
],
};
};
export default webpackLensCommon;
path: path.resolve(buildDir, "library"),
},
optimization: {
minimize: false,
},
plugins: [
new ForkTsCheckerPlugin({}),
],
});
+2 -2
View File
@@ -3,8 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import webpackLensCommon from "./common";
import webpackLensMain from "./main";
import { webpackLensCommon } from "./common";
import { webpackLensMain } from "./main";
import { webpackLensRenderer } from "./renderer";
const config = [
+69 -64
View File
@@ -12,76 +12,81 @@ 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: {
common: {
import: path.resolve(__dirname, "..", "static", "build", "library", "common.js"),
},
output: {
library: {
type: "commonjs2",
main: {
import: path.resolve(__dirname, "..", "src", "main", "library.ts"),
dependOn: "common",
},
},
dependencies: [
"lens-app-common",
],
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,
},
},
},
}),
],
});
+89 -82
View File
@@ -14,97 +14,104 @@ import nodeExternals from "webpack-node-externals";
import { isDevelopment, buildDir, sassCommonVars } from "./vars";
import { platform } from "process";
export function webpackLensRenderer(): webpack.Configuration {
return {
target: "electron-renderer",
name: "lens-app-renderer",
mode: isDevelopment ? "development" : "production",
// https://webpack.js.org/configuration/devtool/ (see description of each option)
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
renderer: path.resolve(__dirname, "..", "src", "renderer", "library.ts"),
export const webpackLensRenderer = (): webpack.Configuration => ({
target: "electron-renderer",
name: "lens-app-renderer",
mode: isDevelopment ? "development" : "production",
// https://webpack.js.org/configuration/devtool/ (see description of each option)
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
common: {
import: path.resolve(__dirname, "..", "static", "build", "library", "common.js"),
},
output: {
library: {
type: "commonjs2",
},
path: path.resolve(buildDir, "library"),
renderer: {
import: path.resolve(__dirname, "..", "src", "renderer", "library.ts"),
dependOn: "common",
},
watchOptions: {
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
},
dependencies: [
"lens-app-common",
],
output: {
library: {
type: "commonjs2",
},
ignoreWarnings: [
/Critical dependency: the request of a dependency is an expression/,
/require.extensions is not supported by webpack./, // handlebars
/\[ReactRefreshPlugin] .*?HMR.*? is not enabled/, // enabled in webpack.dev-server
path: path.resolve(buildDir, "library"),
},
watchOptions: {
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
},
ignoreWarnings: [
/Critical dependency: the request of a dependency is an expression/,
/require.extensions is not supported by webpack./,
/\[ReactRefreshPlugin] .*?HMR.*? is not enabled/, // enabled in webpack.dev-server
],
resolve: {
extensions: [
".js", ".jsx", ".json",
".ts", ".tsx",
],
resolve: {
extensions: [
".js", ".jsx", ".json",
".ts", ".tsx",
],
},
externals: [
nodeExternals(),
],
optimization: {
minimize: false,
},
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
},
externals: [
nodeExternals(),
],
optimization: {
minimize: false,
},
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
declaration: true,
sourceMap: false,
},
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
declaration: true,
sourceMap: false,
},
},
},
cssModulesWebpackRule(),
...iconsAndImagesWebpackRules(),
...fontsLoaderWebpackRules(),
],
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(renderer|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
new ForkTsCheckerPlugin({}),
new CircularDependencyPlugin({
cwd: __dirname,
exclude: /node_modules/,
failOnError: true,
}) as unknown as WebpackPluginInstance,
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
},
cssModulesWebpackRule(),
...iconsAndImagesWebpackRules(),
...fontsLoaderWebpackRules(),
],
};
}
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(renderer|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
new ForkTsCheckerPlugin({}),
new CircularDependencyPlugin({
cwd: __dirname,
exclude: /node_modules/,
failOnError: true,
}) as unknown as WebpackPluginInstance,
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
});
/**
* Import icons and image files.