Purge webpack

This commit is contained in:
Mats Jun Larsen
2025-07-01 14:41:37 +09:00
parent 37284b7cee
commit 91f2ec5df9
11 changed files with 68 additions and 2616 deletions

View File

@@ -52,7 +52,7 @@ jobs:
- name: Run checks
run: |
npm run ts-compile
npm run webpack
npm run build
build_dist:
if: github.repository_owner == 'compiler-explorer' && github.event_name == 'push'

View File

@@ -3,7 +3,7 @@
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Build & Test Commands
- Build: `npm run webpack`, `npm start`
- Build: `npm run build`, `npm start`
- Dev Mode: `make dev`, `make gpu-dev`
- Lint: `npm run lint` (auto-fix), `npm run lint-check` (check only)
- Type Check: `npm run ts-check`

View File

@@ -83,12 +83,12 @@ clean: ## Cleans up everything
.PHONY: prebuild
prebuild: prereqs scripts
$(NPM) run webpack
$(NPM) run build
$(NPM) run ts-compile
.PHONY: run-only
run-only: node-installed ## Runs the site like it runs in production without building it
env NODE_ENV=production $(NODE) $(NODE_ARGS) ./out/dist/app.js --static ./out/webpack/static $(EXTRA_ARGS)
env NODE_ENV=production $(NODE) $(NODE_ARGS) ./out/dist/app.js --static ./dist $(EXTRA_ARGS)
.PHONY: run
run: ## Runs the site like it runs in production

View File

@@ -17,11 +17,10 @@ If you want to add a new language to the site, you should follow this steps:
}
```
- If the language is supported by Monaco Editor (You can find the list
[here](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)), you should add it to the list of
languages inside the `MonacoEditorWebpackPlugin` config in `webpack.config.esm.ts`
- If not, you should implement your own language mode; see `static/modes/asm-mode.ts` as an example. Don't forget to
_require_ your mode file in `static/modes/_all.ts`, in alphabetical order
- If the language is not supported by Monaco Editor (You can find the list
[here](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)), you should implement your own
language mode; see `static/modes/asm-mode.ts` as an example. Don't forget to import your mode file in
`static/modes/_all.ts`, in alphabetical order
- `language-key` is how your language will be referred internally by the code. In the rest of this document, replace
`{language-key}` by the corresponding value in the real files.
- Add a logo file to the `views/resources/logos/` folder and add its path to the `logoFilename{Dark}` key(s) in the

View File

@@ -25,9 +25,6 @@ Once you've finished setting it up, you can `cd` into the `compiler-explorer` di
```bat
npm install
npm install webpack -g
npm install webpack-cli -g
npm update webpack
npm start
```

View File

@@ -36,7 +36,7 @@ Copy-Item -Path "$ROOT/package*.json" -Destination . -Recurse
Remove-Item -Path "$ROOT/lib/storage/data" -Force -Recurse -ErrorAction Ignore
# Set up and build and webpack everything
# Set up and build vite
Set-Location -Path $ROOT
npm install --no-audit
@@ -44,9 +44,9 @@ if ($LASTEXITCODE -ne 0) {
throw "npm install exited with error $LASTEXITCODE"
}
npm run webpack
npm run build
if ($LASTEXITCODE -ne 0) {
throw "npm run webpack exited with error $LASTEXITCODE"
throw "npm run build exited with error $LASTEXITCODE"
}
npm run ts-compile
@@ -86,8 +86,8 @@ if ($IsWindows -or $ENV:OS) {
tar -Jcf "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.tar.xz" .
}
New-Item -Path $ROOT -Name "out/webpack" -Force -ItemType "directory"
Push-Location -Path "$ROOT/out/webpack"
New-Item -Path $ROOT -Name "dist" -Force -ItemType "directory"
Push-Location -Path "$ROOT/dist"
if ($IsWindows -or $ENV:OS) {
Compress-Archive -Path "static/*" -DestinationPath "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.static.zip"
} else {

View File

@@ -28,10 +28,10 @@ cp -R "${ROOT}"/etc \
.
rm -rf "${ROOT}"/lib/storage/data
# Set up and build and webpack everything
# Set up and build vite
cd "${ROOT}"
npm install --no-audit
npm run webpack
npm run build
npm run ts-compile
# Now install only the production dependencies in our output directory
@@ -53,7 +53,7 @@ rm -rf "${ROOT}/out/dist-bin"
mkdir -p "${ROOT}/out/dist-bin"
export XZ_OPT="-1 -T 0"
tar -Jcf "${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.tar.xz" .
pushd "${ROOT}/out/webpack"
pushd "${ROOT}/dist"
tar -Jcf "${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.static.tar.xz" --transform="s,^static/,," static/*
popd
echo "${HASH}" >"${ROOT}/out/dist-bin/${RELEASE_FILE_NAME}.txt"

2420
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,7 +38,6 @@
"clipboard": "^2.0.11",
"commander": "^14.0.0",
"compression": "^1.8.0",
"copy-webpack-plugin": "^13.0.0",
"cross-env": "^7.0.3",
"enhanced-ms": "^4.1.0",
"events": "^3.3.0",
@@ -100,39 +99,25 @@
"@types/response-time": "^2.3.9",
"@types/temp": "^0.9.4",
"@types/underscore": "^1.13.0",
"@types/webpack-env": "^1.18.8",
"@types/which": "^3.0.4",
"@types/ws": "^8.18.1",
"@vitest/coverage-v8": "^3.2.3",
"aws-sdk-client-mock": "^4.1.0",
"cheerio": "^1.1.0",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.2",
"cypress": "^14.4.1",
"file-loader": "^6.2.0",
"happy-dom": "^18.0.1",
"husky": "^9.1.7",
"lint-staged": "^16.1.0",
"mini-css-extract-plugin": "^2.9.2",
"mock-fs": "^5.5.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"nock": "^14.0.5",
"npm-run-all": "^4.1.5",
"patch-package": "^8.0.0",
"sass": "^1.89.2",
"sass-loader": "^16.0.5",
"source-map-loader": "^5.0.0",
"supertest": "^7.1.1",
"terser-webpack-plugin": "^5.3.14",
"ts-loader": "^9.5.2",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vitest": "^3.0.7",
"vitest-fetch-mock": "^0.4.5",
"webpack": "^5.99.9",
"webpack-cli": "^6.0.1",
"webpack-dev-middleware": "^7.4.2",
"webpack-manifest-plugin": "^5.0.1"
"vitest-fetch-mock": "^0.4.5"
},
"optionalDependencies": {
"@rollup/rollup-darwin-arm64": "*",
@@ -154,7 +139,7 @@
"dev": "cross-env NODE_ENV=DEV node --no-warnings=ExperimentalWarning --import=tsx app.ts",
"debugger": "cross-env NODE_ENV=DEV node --import=tsx --inspect-brk app.ts",
"debug": "cross-env NODE_ENV=DEV node --no-warnings=ExperimentalWarning --import=tsx app.ts --debug",
"start": "npm run webpack && cross-env NODE_ENV=LOCAL node --no-warnings=ExperimentalWarning --import=tsx app.ts",
"start": "npm run build && cross-env NODE_ENV=LOCAL node --no-warnings=ExperimentalWarning --import=tsx app.ts",
"sentry": "npx -p @sentry/cli sentry-cli",
"update-browserslist": "npx browserslist@latest -- --update-db",
"prepare": "husky",
@@ -165,8 +150,7 @@
"ts-check:tests": "tsc -p ./tsconfig.tests.json --noEmit",
"ts-check:frontend-tests": "tsc -p ./tsconfig.frontend.tests.json --noEmit",
"build": "vite build",
"postinstall": "patch-package",
"webpack": "node --no-warnings=ExperimentalWarning --import=tsx ./node_modules/webpack-cli/bin/cli.js --node-env=production --config webpack.config.esm.ts"
"postinstall": "patch-package"
},
"license": "BSD-2-Clause",
"packageManager": "npm@11.2.0"

View File

@@ -17,7 +17,6 @@
"compiler-args-app.ts",
"lib",
"examples",
"webpack.config.esm.ts",
"cypress",
"vite.config.ts",
"vite-plugin-hashed-pug.ts"

View File

@@ -1,203 +0,0 @@
// Copyright (c) 2020, Compiler Explorer Authors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import MonacoEditorWebpackPlugin from 'monaco-editor-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import Webpack from 'webpack';
import {WebpackManifestPlugin} from 'webpack-manifest-plugin';
const __dirname = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
const isDev = process.env.NODE_ENV !== 'production';
function log(message: string) {
console.log('webpack: ', message);
}
log(`compiling for ${isDev ? 'development' : 'production'}.`);
// Memory limits us in most cases, so restrict parallelism to keep us in a sane amount of RAM
const parallelism = Math.floor(os.totalmem() / (4 * 1024 * 1024 * 1024)) + 1;
log(`Limiting parallelism to ${parallelism}`);
const manifestPath = path.resolve(__dirname, 'out', 'dist');
const staticPath = path.resolve(__dirname, 'out', 'webpack', 'static');
const hasGit = fs.existsSync(path.resolve(__dirname, '.git'));
// Hack alert: due to a variety of issues, sometimes we need to change
// the name here. Mostly it's things like webpack changes that affect
// how minification is done, even though that's supposed not to matter.
const webpackJsHack = '.v59.';
const plugins: Webpack.WebpackPluginInstance[] = [
new MonacoEditorWebpackPlugin({
languages: [
'cpp',
'go',
'pascal',
'python',
'rust',
'swift',
'java',
'julia',
'kotlin',
'scala',
'ruby',
'csharp',
'fsharp',
'vb',
'dart',
'typescript',
'solidity',
'scheme',
'objective-c',
'elixir',
],
filename: isDev ? '[name].worker.js' : `[name]${webpackJsHack}worker.[contenthash].js`,
}),
new MiniCssExtractPlugin({
filename: isDev ? '[name].css' : `[name]${webpackJsHack}[contenthash].css`,
}),
new WebpackManifestPlugin({
fileName: path.resolve(manifestPath, 'manifest.json'),
publicPath: '',
}),
new Webpack.DefinePlugin({
'window.PRODUCTION': JSON.stringify(!isDev),
}),
new CopyWebpackPlugin({
patterns: [{from: './public', to: staticPath}],
}),
];
if (isDev) {
plugins.push(new Webpack.HotModuleReplacementPlugin());
}
export default {
mode: isDev ? 'development' : 'production',
entry: {
main: './static/main.ts',
noscript: './static/noscript.ts',
},
output: {
filename: isDev ? '[name].js' : `[name]${webpackJsHack}[contenthash].js`,
path: staticPath,
},
cache: {
type: 'filesystem',
buildDependencies: {
config: [
fileURLToPath(import.meta.url),
// Depend on the package.json to force a recache if something changes:
// this is only because something in Monaco upsets the cache if its version changes
path.resolve(__dirname, 'package.json'),
],
},
},
resolve: {
alias: {
'monaco-editor$': 'monaco-editor/esm/vs/editor/editor.api',
},
fallback: {
path: 'path-browserify',
},
modules: ['./static', './node_modules'],
extensions: ['.ts', '.js'],
extensionAlias: {
'.js': ['.ts', '.js'],
'.mjs': ['.mts', '.mjs'],
},
},
stats: 'normal',
devtool: 'source-map',
optimization: {
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendors: {
test: /[/\\]node_modules[/\\]/,
name: 'vendor',
chunks: 'all',
priority: -10,
},
},
},
moduleIds: 'deterministic',
minimizer: [
new CssMinimizerPlugin(),
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 5,
sourceMap: true,
},
}),
],
},
parallelism: parallelism,
module: {
rules: [
{
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './',
},
},
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
type: 'asset',
parser: {dataUrlCondition: {maxSize: 8192}},
},
{
test: /\.pug$/,
loader: './etc/scripts/parsed-pug/parsed_pug_file.js',
options: {
useGit: hasGit,
},
},
{
test: /\.ts$/,
loader: 'ts-loader',
},
{
test: /\.js$/,
loader: 'source-map-loader',
},
],
},
plugins: plugins,
} satisfies Webpack.Configuration;