Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to webpack@5 #4725

Merged
merged 37 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f4f937d
attempt to upgrade webpack@5 and all relevant packages to latest vers…
ixrock Jan 20, 2022
ab7781f
debugging webpack@5 usage -- part 1
ixrock Jan 22, 2022
3782204
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-at…
ixrock Jan 24, 2022
2f382d4
- attempt to use "react-refresh-typescript" with webpack@5 thingy
ixrock Jan 24, 2022
3267978
more fixes, updating webpack loaders
ixrock Jan 25, 2022
55eebf3
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-at…
ixrock Jan 26, 2022
f7a53e6
merge-fixes, using internal webpack@5 asset handlers (type: "asset/*")
ixrock Jan 26, 2022
cae1848
fix: raw-loader / <Icon svg="./*">, updated mocked types for importin…
ixrock Jan 26, 2022
398af8c
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-at…
ixrock Jan 28, 2022
faaa803
removing webpack-dev-server, clean up
ixrock Jan 31, 2022
c0559bf
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-at…
ixrock Jan 31, 2022
aa63143
fix master-merge conflict
ixrock Jan 31, 2022
08acddf
fix/reverted: use sourceMap for styles
ixrock Jan 31, 2022
ad31d3e
fix lint
ixrock Feb 1, 2022
98b516f
fix: loading svg icons inline as data-url (workaround for "?raw" as i…
ixrock Feb 1, 2022
92a5c78
attempt to use webpack-dev-server via node-api -- part 1
ixrock Feb 4, 2022
f1efed4
attempt to use webpack-dev-server via node-api -- part 2
ixrock Feb 7, 2022
5b88f23
fix: incorrect parsing svg-icon xml-content by <HotbarEntityIcon/>
ixrock Feb 7, 2022
81560d5
fix: more random fixes related to incorrect parsing svg-icon content,…
ixrock Feb 8, 2022
662b906
attempt to fix: "Uncaught (in promise) DOMException: A network error …
ixrock Feb 8, 2022
8a6ef6c
Merge remote-tracking branch 'origin/master' into webpack5-upgrade-at…
ixrock Feb 8, 2022
2ef9861
fix: loading cluster frame + error in loading terminal default font (…
ixrock Feb 8, 2022
29c75e1
fix: wait lensProxy.listen() to obtain lensProxy.port for webpack-dev…
ixrock Feb 8, 2022
c5379ad
fix lint
ixrock Feb 8, 2022
10124ab
fix unit tests
ixrock Feb 9, 2022
00214fc
reverted auto-formatted imports with 2 lines (.idea/webstorm)
ixrock Feb 10, 2022
844d49d
fix: handle warnings in main-process compilation files
ixrock Feb 10, 2022
5d24c4e
fix: handle warnings in "renderer" compilation
ixrock Feb 10, 2022
939b46c
fix: move app fonts preloading into html/css files, clean up
ixrock Feb 10, 2022
0336e5f
update "webpack@5", "[email protected]" in bundled extensions / attempt …
ixrock Feb 10, 2022
4c9da2f
fix: handle errors in bundled extensions compilation process
ixrock Feb 11, 2022
95b4990
fix: "webpack" not found in production
ixrock Feb 11, 2022
ae2c937
fix: removed preloading fonts in template via <link preload> since it…
ixrock Feb 11, 2022
7d892d0
apply HMR at least for css/styles and use manual page reload on app/s…
ixrock Feb 14, 2022
37667e7
use `react-refresh-typescript` and `@pmmmwh/react-refresh-webpack-plu…
ixrock Feb 14, 2022
be0090d
responding to comments
ixrock Feb 14, 2022
4576236
revered extension version in package-lock.json (autoupdated on `make …
ixrock Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
"@sentry/types": "^6.14.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^11.2.7",
Expand All @@ -292,12 +292,11 @@
"@types/lodash": "^4.14.177",
"@types/marked": "^4.0.1",
"@types/md5-file": "^4.0.2",
"@types/mini-css-extract-plugin": "^0.9.1",
"@types/mini-css-extract-plugin": "^2.4.0",
"@types/mock-fs": "^4.13.1",
"@types/node": "14.17.33",
"@types/node-fetch": "^2.5.12",
"@types/npm": "^2.0.32",
"@types/progress-bar-webpack-plugin": "^2.1.2",
"@types/proper-lockfile": "^4.1.2",
"@types/randomcolor": "^0.5.6",
"@types/react": "^17.0.34",
Expand All @@ -320,10 +319,10 @@
"@types/triple-beam": "^1.3.2",
"@types/url-parse": "^1.4.5",
"@types/uuid": "^8.3.3",
"@types/webpack": "^4.41.32",
"@types/webpack-dev-server": "^3.11.6",
"@types/webpack": "^5.28.0",
"@types/webpack-dev-server": "^4.7.2",
"@types/webpack-env": "^1.16.3",
"@types/webpack-node-externals": "^1.7.1",
"@types/webpack-node-externals": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"ansi_up": "^5.1.0",
Expand All @@ -348,23 +347,22 @@
"eslint-plugin-unused-imports": "^1.1.5",
"file-loader": "^6.2.0",
"flex.box": "^3.4.4",
"fork-ts-checker-webpack-plugin": "^5.2.1",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"hoist-non-react-statics": "^3.3.2",
"html-webpack-plugin": "^4.5.2",
"html-webpack-plugin": "^5.5.0",
"include-media": "^1.4.9",
"jest": "26.6.3",
"jest-canvas-mock": "^2.3.1",
"jest-fetch-mock": "^3.0.3",
"jest-mock-extended": "^1.0.18",
"make-plural": "^6.2.2",
"mini-css-extract-plugin": "^1.6.2",
"mini-css-extract-plugin": "^2.5.2",
"node-gyp": "7.1.2",
"node-loader": "^1.0.3",
"nodemon": "^2.0.14",
"playwright": "^1.17.1",
"postcss": "^8.4.5",
"postcss-loader": "^4.3.0",
"progress-bar-webpack-plugin": "^2.1.0",
"randomcolor": "^0.6.2",
"raw-loader": "^4.0.2",
"react-beautiful-dnd": "^13.1.0",
Expand All @@ -385,15 +383,15 @@
"type-fest": "^1.0.2",
"typed-emitter": "^1.4.0",
"typedoc": "0.22.10",
"typedoc-plugin-markdown": "^3.11.3",
"typedoc-plugin-markdown": "^3.11.12",
"typeface-roboto": "^1.1.13",
"typescript": "^4.5.2",
"typescript-plugin-css-modules": "^3.4.0",
"url-loader": "^4.1.1",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.3",
"webpack-node-externals": "^1.7.2",
"webpack": "^5.66.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.7.3",
"webpack-node-externals": "^3.0.0",
"xterm": "^4.15.0",
"xterm-addon-fit": "^0.5.0"
}
Expand Down
28 changes: 15 additions & 13 deletions src/main/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type http from "http";
import path from "path";
import { readFile } from "fs-extra";
import type { Cluster } from "../common/cluster/cluster";
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
import { apiPrefix, appName, publicPath } from "../common/vars";
import { HelmApiRoute, KubeconfigRoute, MetricsRoute, PortForwardRoute, ResourceApplierApiRoute, VersionRoute } from "./routes";
import logger from "./logger";

Expand Down Expand Up @@ -110,7 +110,7 @@ export class Router {
};
}

protected static async handleStaticFile({ params, response, raw: { req }}: LensApiRequest): Promise<void> {
protected static async handleStaticFile({ params, response }: LensApiRequest): Promise<void> {
let filePath = params.path;

for (let retryCount = 0; retryCount < 5; retryCount += 1) {
Expand All @@ -124,18 +124,20 @@ export class Router {
}

try {
const filename = path.basename(req.url);
// const filename = path.basename(req.url);
// redirect requests to [appName].js, [appName].html /sockjs-node/ to webpack-dev-server (for hot-reload support)
const toWebpackDevServer = filename.includes(appName) || filename.includes("hot-update") || req.url.includes("sockjs-node");

if (isDevelopment && toWebpackDevServer) {
const redirectLocation = `http://localhost:${webpackDevServerPort}${req.url}`;

response.statusCode = 307;
response.setHeader("Location", redirectLocation);

return response.end();
}
// const toWebpackDevServer = filename.includes(appName) || filename.includes("hot-update") || req.url.includes("sockjs-node");
//
// if (isDevelopment /*&& toWebpackDevServer*/) {
// const redirectLocation = `http://0.0.0.0:${webpackDevServerPort}${req.url}`;
//
// logger.info(`[ROUTER]: redirecting to dev-server url: ${redirectLocation}`);
//
// response.statusCode = 307;
// response.setHeader("Location", redirectLocation);
//
// return response.end();
// }

const data = await readFile(asset);

Expand Down
52 changes: 10 additions & 42 deletions webpack.extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

import path from "path";
import type webpack from "webpack";
import { sassCommonVars, isDevelopment, isProduction } from "./src/common/vars";
import * as vars from "./src/common/vars";
import {
cssModulesWebpackRule,
filesAndIconsWebpackRule,
fontsLoaderWebpackRule,
} from "./webpack.renderer";

export default function generateExtensionTypes(): webpack.Configuration {
const { isDevelopment, isProduction } = vars;
ixrock marked this conversation as resolved.
Show resolved Hide resolved
const entry = "./src/extensions/extension-api.ts";
const outDir = "./src/extensions/npm/extensions/dist";

Expand Down Expand Up @@ -48,47 +54,9 @@ export default function generateExtensionTypes(): webpack.Configuration {
},
},
},
// for src/renderer/components/fonts/roboto-mono-nerd.ttf
// in src/renderer/components/dock/terminal.ts 95:25-65
{
test: /\.(ttf|eot|woff2?)$/,
use: {
loader: "url-loader",
options: {
name: "fonts/[name].[ext]",
},
},
},
{
test: /\.(jpg|png|svg|map|ico)$/,
use: {
loader: "file-loader",
options: {
name: "images/[name]-[hash:6].[ext]",
esModule: false, // handle media imports in <template>, e.g <img src="../assets/logo.svg"> (react)
},
},
},
// for import scss files
{
test: /\.s?css$/,
use: [
"style-loader",
"css-loader",
"postcss-loader",
{
loader: "sass-loader",
options: {
additionalData: `@import "${path.basename(sassCommonVars)}";`,
sassOptions: {
includePaths: [
path.dirname(sassCommonVars),
],
},
},
},
],
},
fontsLoaderWebpackRule(),
filesAndIconsWebpackRule(),
cssModulesWebpackRule({ styleLoader: "style-loader" }),
],
},
resolve: {
Expand Down
6 changes: 2 additions & 4 deletions webpack.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import path from "path";
import type webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars";
import nodeExternals from "webpack-node-externals";
import ProgressBarPlugin from "progress-bar-webpack-plugin";
import * as vars from "./src/common/vars";
import getTSLoader from "./src/common/getTSLoader";
import CircularDependencyPlugin from "circular-dependency-plugin";
Expand All @@ -17,12 +15,13 @@ const configs: { (): webpack.Configuration }[] = [];

configs.push((): webpack.Configuration => {
console.info("WEBPACK:main", vars);
const { isProduction, mainDir, buildDir, isDevelopment } = vars;

return {
context: __dirname,
target: "electron-main",
mode: isProduction ? "production" : "development",
devtool: isProduction ? "source-map" : "cheap-eval-source-map",
devtool: isDevelopment ? "hidden-source-map" : "source-map",
cache: isDevelopment,
entry: {
main: path.resolve(mainDir, "index.ts"),
Expand All @@ -47,7 +46,6 @@ configs.push((): webpack.Configuration => {
],
},
plugins: [
new ProgressBarPlugin(),
new ForkTsCheckerPlugin(),

new CircularDependencyPlugin({
Expand Down
Loading