diff --git a/.github/actions/setup-woocommerce-monorepo/action.yml b/.github/actions/setup-woocommerce-monorepo/action.yml index a391a2e7350..20fe342c70f 100644 --- a/.github/actions/setup-woocommerce-monorepo/action.yml +++ b/.github/actions/setup-woocommerce-monorepo/action.yml @@ -54,6 +54,13 @@ runs: path: "${{ env.PNPM_STORE_PATH }}" key: "${{ runner.os }}-pnpm-${{ inputs.pull-package-deps }}-${{ hashFiles( 'pnpm-lock.yaml' ) }}" restore-keys: '${{ runner.os }}-pnpm-${{ inputs.pull-package-deps }}-' + - name: 'Cache: node cache' + if: ${{ inputs.pull-package-deps != 'false' }} + uses: 'actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319' + with: + path: './node_modules/.cache' + key: "${{ runner.os }}-node-cache-${{ inputs.pull-package-deps }}-${{ hashFiles( 'pnpm-lock.yaml' ) }}" + restore-keys: '${{ runner.os }}-node-cache-${{ inputs.pull-package-deps }}-' - name: 'Cache Composer Dependencies' if: ${{ inputs.pull-package-deps != 'false' }} uses: 'actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319' diff --git a/packages/js/internal-js-tests/changelog/dev-babel-loader-jest-caching b/packages/js/internal-js-tests/changelog/dev-babel-loader-jest-caching new file mode 100644 index 00000000000..49889afff8e --- /dev/null +++ b/packages/js/internal-js-tests/changelog/dev-babel-loader-jest-caching @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Monorepo: enable Jest caching. diff --git a/packages/js/internal-js-tests/jest-preset.js b/packages/js/internal-js-tests/jest-preset.js index 451e1373986..f3ad011aaab 100644 --- a/packages/js/internal-js-tests/jest-preset.js +++ b/packages/js/internal-js-tests/jest-preset.js @@ -5,7 +5,7 @@ const path = require( 'path' ); // These modules need to be transformed because they are not transpiled to CommonJS. // The top-level keys are the names of the packages and the values are the file -// regexes that need to be transformed. Note that these are relative to the +// regexes that need to be transformed. Note that these are relative to the // package root and should be treated as such. const transformModules = { 'is-plain-obj': { @@ -76,4 +76,8 @@ module.exports = { testEnvironment: 'jest-environment-jsdom', timers: 'modern', verbose: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/jest' + ), }; diff --git a/plugins/woo-ai/changelog/dev-babel-loader-jest-caching b/plugins/woo-ai/changelog/dev-babel-loader-jest-caching new file mode 100644 index 00000000000..49889afff8e --- /dev/null +++ b/plugins/woo-ai/changelog/dev-babel-loader-jest-caching @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Monorepo: enable Jest caching. diff --git a/plugins/woo-ai/tests/js/jest.config.js b/plugins/woo-ai/tests/js/jest.config.js index 5314da3e1d7..89c316038a5 100644 --- a/plugins/woo-ai/tests/js/jest.config.js +++ b/plugins/woo-ai/tests/js/jest.config.js @@ -17,6 +17,7 @@ module.exports = { '/node_modules/', '/build/', '/.*/build/', + '/vendor', '/tests', ], transformIgnorePatterns: [ diff --git a/plugins/woocommerce-admin/webpack.config.js b/plugins/woocommerce-admin/webpack.config.js index 36008e9c793..a82c5f86b60 100644 --- a/plugins/woocommerce-admin/webpack.config.js +++ b/plugins/woocommerce-admin/webpack.config.js @@ -153,6 +153,11 @@ const webpackConfig = { isHot && require.resolve( 'react-refresh/babel' ), ].filter( Boolean ), + cacheDirectory: path.resolve( + __dirname, + '../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, diff --git a/plugins/woocommerce-blocks/bin/webpack-configs.js b/plugins/woocommerce-blocks/bin/webpack-configs.js index 936ab7a8cfd..21e0fdccb4a 100644 --- a/plugins/woocommerce-blocks/bin/webpack-configs.js +++ b/plugins/woocommerce-blocks/bin/webpack-configs.js @@ -103,6 +103,11 @@ const getCoreConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ], + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -217,7 +222,11 @@ const getMainConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), - cacheDirectory: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -366,7 +375,11 @@ const getFrontConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), - cacheDirectory: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -484,7 +497,11 @@ const getPaymentsConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), - cacheDirectory: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -591,7 +608,11 @@ const getExtensionsConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), - cacheDirectory: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -674,7 +695,7 @@ const getSiteEditorConfig = ( options = {} ) => { test: /\.(j|t)sx?$/, exclude: /node_modules/, use: { - loader: 'babel-loader?cacheDirectory', + loader: 'babel-loader', options: { presets: [ [ @@ -697,6 +718,11 @@ const getSiteEditorConfig = ( options = {} ) => { : false, '@babel/plugin-proposal-optional-chaining', ].filter( Boolean ), + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -831,7 +857,7 @@ const getStylingConfig = ( options = {} ) => { { test: /\.(j|t)sx?$/, use: { - loader: 'babel-loader?cacheDirectory', + loader: 'babel-loader', options: { presets: [ '@wordpress/babel-preset-default' ], plugins: [ @@ -843,6 +869,11 @@ const getStylingConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, @@ -950,8 +981,6 @@ const getInteractivityAPIConfig = ( options = {} ) => { { loader: require.resolve( 'babel-loader' ), options: { - cacheDirectory: - process.env.BABEL_CACHE_DIRECTORY || true, babelrc: false, configFile: false, presets: [ @@ -969,6 +998,11 @@ const getInteractivityAPIConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ], + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, ], @@ -1054,7 +1088,11 @@ const getCartAndCheckoutFrontendConfig = ( options = {} ) => { '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties', ].filter( Boolean ), - cacheDirectory: true, + cacheDirectory: path.resolve( + __dirname, + '../../../node_modules/.cache/babel-loader' + ), + cacheCompression: false, }, }, }, diff --git a/plugins/woocommerce-blocks/tests/js/jest.config.json b/plugins/woocommerce-blocks/tests/js/jest.config.json index c91bf754a0d..e6a18306fee 100644 --- a/plugins/woocommerce-blocks/tests/js/jest.config.json +++ b/plugins/woocommerce-blocks/tests/js/jest.config.json @@ -45,9 +45,12 @@ "/tests/js/setup-after-env.ts" ], "testPathIgnorePatterns": [ - "/tests/", + "/bin/", + "/build/", + "/docs/", "/node_modules/", - "/vendor/" + "/vendor/", + "/tests/" ], "transformIgnorePatterns": [ "node_modules/?!(simple-html-tokenizer|is-plain-obj|is-plain-object|memize)" ], "testEnvironment": "jsdom", @@ -55,5 +58,6 @@ "transform": { "^.+\\.(js|ts|tsx)$": "/tests/js/jestPreprocess.js" }, - "verbose": true + "verbose": true, + "cacheDirectory": "/../../node_modules/.cache/jest" } diff --git a/plugins/woocommerce/changelog/dev-babel-loader-jest-caching b/plugins/woocommerce/changelog/dev-babel-loader-jest-caching new file mode 100644 index 00000000000..f20da6b1dba --- /dev/null +++ b/plugins/woocommerce/changelog/dev-babel-loader-jest-caching @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Monorepo: enable Jest and babel-loader caching.