Unverified Commit 0cfe758f authored by Joe Haddad's avatar Joe Haddad Committed by GitHub
Browse files

Ensure files get purged when they should (#5054)

parent 74c4baeb
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 62 additions and 0 deletions
+62 -0
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
module.exports = function getCacheIdentifier(environment, packages) {
let cacheIdentifier = `${environment}`;
for (const packageName of packages) {
cacheIdentifier += `:${packageName}@`;
try {
cacheIdentifier += require(`${packageName}/package.json`).version;
} catch (_) {
// ignored
}
}
return cacheIdentifier;
};
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"evalSourceMapMiddleware.js", "evalSourceMapMiddleware.js",
"FileSizeReporter.js", "FileSizeReporter.js",
"formatWebpackMessages.js", "formatWebpackMessages.js",
"getCacheIdentifier.js",
"getCSSModuleLocalIdent.js", "getCSSModuleLocalIdent.js",
"getProcessForPort.js", "getProcessForPort.js",
"ignoredFiles.js", "ignoredFiles.js",
......
...@@ -20,6 +20,7 @@ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent') ...@@ -20,6 +20,7 @@ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent')
const getClientEnvironment = require('./env'); const getClientEnvironment = require('./env');
const paths = require('./paths'); const paths = require('./paths');
const ManifestPlugin = require('webpack-manifest-plugin'); const ManifestPlugin = require('webpack-manifest-plugin');
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
// Webpack uses `publicPath` to determine where the app is being served from. // Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier. // In development, we always serve from the root. This makes config easier.
...@@ -232,6 +233,17 @@ module.exports = { ...@@ -232,6 +233,17 @@ module.exports = {
// @remove-on-eject-begin // @remove-on-eject-begin
babelrc: false, babelrc: false,
presets: [require.resolve('babel-preset-react-app')], presets: [require.resolve('babel-preset-react-app')],
// Make sure we have a unique cache identifier, erring on the
// side of caution.
// We remove this when the user ejects because the default
// is sane and uses Babel options. Instead of options, we use
// the react-scripts and babel-preset-react-app versions.
cacheIdentifier: getCacheIdentifier('development', [
'babel-plugin-named-asset-import',
'babel-preset-react-app',
'react-dev-utils',
'react-scripts',
]),
// @remove-on-eject-end // @remove-on-eject-end
plugins: [ plugins: [
[ [
...@@ -280,6 +292,14 @@ module.exports = { ...@@ -280,6 +292,14 @@ module.exports = {
cacheDirectory: true, cacheDirectory: true,
// Don't waste time on Gzipping the cache // Don't waste time on Gzipping the cache
cacheCompression: false, cacheCompression: false,
// @remove-on-eject-begin
cacheIdentifier: getCacheIdentifier('development', [
'babel-plugin-named-asset-import',
'babel-preset-react-app',
'react-dev-utils',
'react-scripts',
]),
// @remove-on-eject-end
highlightCode: true, highlightCode: true,
}, },
}, },
......
...@@ -23,6 +23,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); ...@@ -23,6 +23,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
const paths = require('./paths'); const paths = require('./paths');
const getClientEnvironment = require('./env'); const getClientEnvironment = require('./env');
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
// Webpack uses `publicPath` to determine where the app is being served from. // Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path. // It requires a trailing slash, or the file assets will get an incorrect path.
...@@ -269,6 +270,17 @@ module.exports = { ...@@ -269,6 +270,17 @@ module.exports = {
// @remove-on-eject-begin // @remove-on-eject-begin
babelrc: false, babelrc: false,
presets: [require.resolve('babel-preset-react-app')], presets: [require.resolve('babel-preset-react-app')],
// Make sure we have a unique cache identifier, erring on the
// side of caution.
// We remove this when the user ejects because the default
// is sane and uses Babel options. Instead of options, we use
// the react-scripts and babel-preset-react-app versions.
cacheIdentifier: getCacheIdentifier('production', [
'babel-plugin-named-asset-import',
'babel-preset-react-app',
'react-dev-utils',
'react-scripts',
]),
// @remove-on-eject-end // @remove-on-eject-end
plugins: [ plugins: [
[ [
...@@ -310,6 +322,14 @@ module.exports = { ...@@ -310,6 +322,14 @@ module.exports = {
cacheDirectory: true, cacheDirectory: true,
// Save disk space when time isn't as important // Save disk space when time isn't as important
cacheCompression: true, cacheCompression: true,
// @remove-on-eject-begin
cacheIdentifier: getCacheIdentifier('production', [
'babel-plugin-named-asset-import',
'babel-preset-react-app',
'react-dev-utils',
'react-scripts',
]),
// @remove-on-eject-end
highlightCode: true, highlightCode: true,
}, },
}, },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment