mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[web] rm unnecessary webpack configuration (#33587)
GitOrigin-RevId: d9f305e59af2585db096a83c4cbd41ba5f785184
This commit is contained in:
@@ -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
|
||||
@@ -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 = ''
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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' &&
|
||||
|
||||
Reference in New Issue
Block a user