Skip to content

Commit

Permalink
Enable babel-loader cache
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Jun 4, 2024
1 parent f93547b commit e488302
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .changeset/fast-ads-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'sku': patch
---

Enable `babel-loader` cache

Sku's webpack configuration now emits a `babel-loader` cache to `node_modules/.cache/babel-loader`.
This cache can speed up local development in situations where the webpack cache is invalidated.
It can also be used during production builds to speed up the build process.
8 changes: 8 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ jobs:
path: ${{ steps.set-puppeteer-cache.outputs.PUPPETEER_CACHE_DIR }}
key: puppeteer-${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml') }}

- name: Cache babel-loader
id: babel-loader-cache
uses: actions/cache@v3
with:
path: 'fixtures/*/node_modules/.cache/babel-loader'
key: babel-loader-${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml') }}
restore-keys: babel-loader-${{ runner.os }}-

- name: Install Puppeteer
if: steps.puppeteer-cache.outputs.cache-hit != 'true'
run: pnpm puppeteer browsers install chrome
Expand Down
7 changes: 7 additions & 0 deletions packages/sku/config/babel/babelConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ module.exports = ({
return {
babelrc: false,
sourceType: isBrowser ? 'unambiguous' : 'module',
// `babel-jest` does not support the `cacheDirectory` option.
// It is only used by `babel-loader`.
...(!isJest
? {
cacheDirectory: true,
}
: {}),
presets,
plugins,
};
Expand Down
1 change: 1 addition & 0 deletions packages/sku/config/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const makeWebpackConfig = ({
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
cacheDirectory: true,
presets: [
[
require.resolve('@babel/preset-env'),
Expand Down
1 change: 1 addition & 0 deletions packages/sku/config/webpack/webpack.config.ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const makeWebpackConfig = ({
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
cacheDirectory: true,
presets: [
[
require.resolve('@babel/preset-env'),
Expand Down

0 comments on commit e488302

Please sign in to comment.