diff --git a/services/web/frontend/macros/cypress-cache-variant.js b/services/web/frontend/macros/cypress-cache-variant.js deleted file mode 100644 index c3fb316e3d..0000000000 --- a/services/web/frontend/macros/cypress-cache-variant.js +++ /dev/null @@ -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 diff --git a/services/web/frontend/macros/invalidate-babel-cache-if-needed.js b/services/web/frontend/macros/invalidate-babel-cache-if-needed.js index e65a8467f7..05a1071cfd 100644 --- a/services/web/frontend/macros/invalidate-babel-cache-if-needed.js +++ b/services/web/frontend/macros/invalidate-babel-cache-if-needed.js @@ -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 = '' diff --git a/services/web/webpack.config.dev.js b/services/web/webpack.config.dev.js index aa4c705691..f35123aa5c 100644 --- a/services/web/webpack.config.dev.js +++ b/services/web/webpack.config.dev.js @@ -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, diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index 6853e1a089..75a75f663d 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -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' &&