[web] rm unnecessary webpack configuration (#33587)

GitOrigin-RevId: d9f305e59af2585db096a83c4cbd41ba5f785184
This commit is contained in:
Kristina
2026-05-13 10:22:59 +02:00
committed by Copybot
parent bc2f5ae746
commit d8df893593
4 changed files with 3 additions and 52 deletions

View File

@@ -1,23 +0,0 @@
const path = require('path')
// Returns the cache subdirectory name for the current Cypress CT variant,
// or null when CYPRESS_RESULTS is not set.
// Throws if the derived basename is unsafe to prevent path traversal or
// absolute-path escapes.
function cypressCacheVariant() {
if (!process.env.CYPRESS_RESULTS) return null
const variant = path.basename(process.env.CYPRESS_RESULTS)
if (
!variant ||
variant === '.' ||
variant === '..' ||
path.isAbsolute(variant)
) {
throw new Error(
`CYPRESS_RESULTS must resolve to a safe basename; got "${process.env.CYPRESS_RESULTS}"`
)
}
return variant
}
module.exports = cypressCacheVariant

View File

@@ -1,13 +1,9 @@
const fs = require('fs')
const Path = require('path')
const Settings = require('@overleaf/settings')
const cypressCacheVariant = require('./cypress-cache-variant')
module.exports = function invalidateBabelCacheIfNeeded() {
// Use a unique subdirectory per Cypress CT variant to avoid parallel jobs
// racing on the shared babel cache and state file.
const suffix = cypressCacheVariant() ?? ''
const cacheDir = Path.join(__dirname, '../../node_modules/.cache', suffix)
const cacheDir = Path.join(__dirname, '../../node_modules/.cache')
const cachePath = Path.join(cacheDir, 'babel-loader')
const statePath = Path.join(cacheDir, 'last-overleafModuleImports.json')
let lastState = ''

View File

@@ -5,9 +5,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
const base = require('./webpack.config')
const cypressCacheVariant = require('./frontend/macros/cypress-cache-variant')
const cypressVariant = cypressCacheVariant()
// if WEBPACK_ENTRYPOINTS is defined, remove any entrypoints that aren't included
if (process.env.WEBPACK_ENTRYPOINTS) {
@@ -29,17 +26,6 @@ module.exports = merge(base, {
cache: {
type: 'filesystem',
// Use a unique cache directory per Cypress CT variant to avoid
// parallel jobs corrupting the shared PackFileCacheStrategy pack files.
...(cypressVariant
? {
cacheDirectory: path.resolve(
__dirname,
'node_modules/.cache/webpack',
cypressVariant
),
}
: {}),
buildDependencies: {
config: [
__filename,

View File

@@ -10,18 +10,10 @@ const {
const PackageVersions = require('./app/src/infrastructure/PackageVersions.js')
const invalidateBabelCacheIfNeeded = require('./frontend/macros/invalidate-babel-cache-if-needed')
const cypressCacheVariant = require('./frontend/macros/cypress-cache-variant')
// Make sure that babel-macros are re-evaluated after changing the modules config
invalidateBabelCacheIfNeeded()
// Use a unique babel-loader cache directory per Cypress CT variant to avoid
// parallel jobs corrupting the shared cache.
const cypressVariant = cypressCacheVariant()
const babelCacheDirectory = cypressVariant
? path.join(__dirname, 'node_modules/.cache', cypressVariant, 'babel-loader')
: true
// Generate a hash of entry points, including modules
const entryPoints = {
bootstrap: './frontend/js/bootstrap.ts',
@@ -131,7 +123,7 @@ module.exports = {
{
loader: 'babel-loader',
options: {
cacheDirectory: babelCacheDirectory,
cacheDirectory: true,
configFile: path.join(__dirname, './babel.config.json'),
},
},
@@ -164,7 +156,7 @@ module.exports = {
options: {
// Configure babel-loader to cache compiled output so that
// subsequent compile runs are much faster
cacheDirectory: babelCacheDirectory,
cacheDirectory: true,
configFile: path.join(__dirname, './babel.config.json'),
plugins: [
process.env.REACT_REFRESH_ENABLED === 'true' &&