Skip to content

Commit

Permalink
fix: correct cache directory for babel-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
idevat committed Nov 10, 2024
1 parent 39e9e67 commit ab451e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
28 changes: 16 additions & 12 deletions packages/app/.bin/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ module.exports = ({
publicPath,
// Point sourcemap entries to original disk location.
devtoolModuleFilenameTemplate: info =>
path
.relative(srcDir, info.absoluteResourcePath)
.replace(/\\/g, "/"),
path.relative(srcDir, info.absoluteResourcePath).replace(/\\/g, "/"),
},
cache: {
type: "filesystem",
Expand Down Expand Up @@ -155,10 +153,16 @@ module.exports = ({
? {generator: {publicPath: "../../"}}
: {},
),
rules.scripts({plugins: [], compact: true, include: srcDir}),
rules.scripts({
plugins: [],
compact: true,
include: srcDir,
cacheDirectory,
}),
rules.outsideScripts({
sourceMaps: shouldUseSourceMap,
inputSourceMap: shouldUseSourceMap,
cacheDirectory,
}),
rules.css({
// css is located in `static/css`, use '../../' to locate
Expand All @@ -177,14 +181,14 @@ module.exports = ({
plugins: [
plugins.environmentVariables,
plugins.miniCssExtract,
plugins.forkTsChecker({
async: false,
sourceMap: shouldUseSourceMap,
nodeModules,
configFile: tsConfig,
tsBuildInfoFile,
tsConfigPathsContext,
}),
plugins.forkTsChecker({
async: false,
sourceMap: shouldUseSourceMap,
nodeModules,
configFile: tsConfig,
tsBuildInfoFile,
tsConfigPathsContext,
}),
],
// Turn off performance processing because we utilize
// our own hints via the FileSizeReporter
Expand Down
19 changes: 11 additions & 8 deletions packages/app/.bin/config/webpack.rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ module.exports = {

// Process application JS with Babel. The preset includes JSX, Flow,
// TypeScript, and some ESnext features.
scripts: ({plugins, compact, include} = {
plugins: [],
compact: true,
include: "",
}) => ({
scripts: (
{plugins, compact, include, cacheDirectory} = {
plugins: [],
compact: true,
include: "",
cacheDirectory: "./node_modules/.cache",
},
) => ({
test: /\.(js|jsx|ts|tsx)$/,
include,
loader: require.resolve("babel-loader"),
Expand All @@ -44,7 +47,7 @@ module.exports = {
// itself). It enables caching results in
// ./node_modules/.cache/babel-loader/ directory for faster
// rebuilds.
cacheDirectory: true,
cacheDirectory: `${cacheDirectory}/babel-loader`,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,
compact,
Expand All @@ -54,7 +57,7 @@ module.exports = {
// Process any JS outside of the app with Babel.
// Unlike the application JS, we only compile the standard ES
// features.
outsideScripts: ({sourceMaps, inputSourceMap}) => ({
outsideScripts: ({sourceMaps, inputSourceMap, cacheDirectory}) => ({
test: /\.(js)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve("babel-loader"),
Expand All @@ -68,7 +71,7 @@ module.exports = {
{helpers: true},
],
],
cacheDirectory: true,
cacheDirectory: `${cacheDirectory}/babel-loader`,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,

Expand Down

0 comments on commit ab451e0

Please sign in to comment.