-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Tooling: Configure Webpack to watch only build files #21489
Conversation
Size Change: +13.1 kB (1%) Total Size: 903 kB
ℹ️ View Unchanged
|
Considering an alternative: we could just have the pattern match any file within
I'd need to test if
|
Yes, the proposed alternative is quite nice. If it works it will cover the majority of cases 👍 |
It seems to work pretty well:
Note: One thing I want to follow-up on is: I seem to recall we have some packages that have files in the root of the package. The pattern above only matches files in a subfolder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, my hope is that all packages that aren't transpiled don't use src
subfolder at all. As discussed already, we started using lib
only recently for better code organization and easier publishing process with files
section in package.json
file.
Nothing relevant for this pull request. const { join } = require( 'path' );
const { readdirSync, statSync, existsSync } = require( 'fs' );
const PACKAGES_DIR = join( __dirname, '../packages' );
const packages = readdirSync( PACKAGES_DIR ).filter( ( candidate ) =>
statSync( join( PACKAGES_DIR, candidate ) ).isDirectory()
);
console.log(
'unnecessary src',
packages.filter(
( dir ) =>
! require( join( PACKAGES_DIR, dir, 'package.json' ) ).module &&
existsSync( join( PACKAGES_DIR, dir, 'src' ) )
)
);
console.log(
'absent src',
packages.filter(
( dir ) =>
require( join( __dirname, '../package.json' ) ).dependencies[
'@wordpress/' + dir
] &&
! require( join( PACKAGES_DIR, dir, 'package.json' ) ).module &&
! (
require( join( PACKAGES_DIR, dir, 'package.json' ) ).main || ''
).startsWith( 'lib/' )
)
);
|
Interesting, I was wrong. Fortunately, it doesn't have any impact because it doesn't contain any production code. |
Should it be merged? |
I think it can be. I'm planning to do a wave of merges tomorrow. |
This pull request seeks to revise the Webpack configuration to instruct the watcher to ignore all files which are outside a package's build output directories. The project is built in such a way that Webpack is responsible only for the part of the build where package output is transformed to be run in a browser. The package build (Babel, etc) is handled separately, where the output is directed to a package's
build
,build-module
, andbuild-style
folder, and then "handed off" to Webpack. Thus, it should be safe to assume that Webpack is only concerned with changes within these files.The intention with these changes is to resolve cases where an operating system may have limited resources to watch files, either hitting a limit or maxing processor usage.
Related:
Implementation Notes:
Credit to @draganescu for identifying
watchOptions.ignored
as the configuration for addressing the underlying issue.Webpack uses
anymatch
under the hood, which in turn usesmicromatch
. Refer to documentation for more detail about the syntax of the glob patterns:Testing Instructions:
Verify there are no regressions in watch behavior. Changing a source file within a package should trigger a Webpack rebuild.