Monorepo: actualize loaders paths filtering for better Webpack performance. (#49714)

This commit is contained in:
Vladimir Reznichenko 2024-07-29 15:20:17 +02:00 committed by GitHub
parent a8b560a03f
commit 07a71106dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 14 deletions

View File

@ -21,7 +21,11 @@ module.exports = {
rules: [ rules: [
{ {
test: /\.s?css$/, test: /\.s?css$/,
exclude: [ /storybook\/wordpress/, /build-style\/*\/*.css/ ], exclude: [
/storybook\/wordpress/,
/build-style\/*\/*.css/,
/[\/\\](changelog|bin|docs|build|build-module|build-types|vendor|tests|test)[\/\\]/,
],
use: [ use: [
MiniCssExtractPlugin.loader, MiniCssExtractPlugin.loader,
'css-loader', 'css-loader',

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Monorepo: tweak Webpack loaders paths filtering for better build perfromance.

View File

@ -1,5 +1,6 @@
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' ); const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
const path = require( 'path' );
module.exports = { module.exports = {
...defaultConfig, ...defaultConfig,
@ -13,7 +14,7 @@ module.exports = {
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: 'ts-loader', use: 'ts-loader',
exclude: /node_modules/, include: [ path.resolve( __dirname, './src/' ) ],
}, },
{ {
test: /\.(png|jp(e*)g|svg|gif)$/, test: /\.(png|jp(e*)g|svg|gif)$/,

View File

@ -126,8 +126,8 @@ const webpackConfig = {
amd: false, amd: false,
}, },
exclude: [ exclude: [
// Exclude node_modules/.pnpm /[\/\\]node_modules[\/\\]\.pnpm[\/\\]/,
/node_modules(\/|\\)\.pnpm(\/|\\)/, /[\/\\](changelog|bin|build|docs|test)[\/\\]/,
], ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Monorepo: tweak Webpack loaders paths filtering for better build perfromance.

View File

@ -1,5 +1,6 @@
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' ); const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
const path = require( 'path' );
module.exports = { module.exports = {
...defaultConfig, ...defaultConfig,
@ -15,7 +16,7 @@ module.exports = {
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: 'ts-loader', use: 'ts-loader',
exclude: /node_modules/, include: [ path.resolve( __dirname, './src/' ) ],
}, },
], ],
}, },

View File

@ -43,7 +43,7 @@ const getSharedPlugins = ( {
[ [
CHECK_CIRCULAR_DEPS === 'true' && checkCircularDeps !== false CHECK_CIRCULAR_DEPS === 'true' && checkCircularDeps !== false
? new CircularDependencyPlugin( { ? new CircularDependencyPlugin( {
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
cwd: process.cwd(), cwd: process.cwd(),
failOnError: 'warn', failOnError: 'warn',
} ) } )
@ -94,7 +94,9 @@ const getCoreConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(t|j)sx?$/, test: /\.(t|j)sx?$/,
exclude: /node_modules/, exclude: [
/[\/\\](node_modules|build|docs|bin|storybook|tests|test)[\/\\]/,
],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -208,7 +210,7 @@ const getMainConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -349,7 +351,7 @@ const getFrontConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -471,7 +473,7 @@ const getPaymentsConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -582,7 +584,7 @@ const getExtensionsConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -693,7 +695,7 @@ const getSiteEditorConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -856,6 +858,7 @@ const getStylingConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -976,7 +979,7 @@ const getInteractivityAPIConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: [ use: [
{ {
loader: require.resolve( 'babel-loader' ), loader: require.resolve( 'babel-loader' ),
@ -1062,7 +1065,7 @@ const getCartAndCheckoutFrontendConfig = ( options = {} ) => {
rules: [ rules: [
{ {
test: /\.(j|t)sx?$/, test: /\.(j|t)sx?$/,
exclude: /node_modules/, exclude: [ /[\/\\](node_modules|build|docs|vendor)[\/\\]/ ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Monorepo: tweak Webpack loaders paths filtering for better build perfromance.