-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Build: Move the build tool to a dedicated package #72743
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@fabiankaegy Would love some thoughts / testing when you have time. |
|
Size Change: 0 B Total Size: 2.37 MB ℹ️ View Unchanged
|
7305904 to
034c803
Compare
|
Flaky tests detected in c701079. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18882004794
|
034c803 to
831f4a1
Compare
|
Hey @youknowriad 👋 This is exciting! Will definitely give this a go this week! Question from just glancing through the code 🤔 Will all scripts that are automatically enqueued through this be enqueued globally or what's the plan for more granular control over where / when a script should load? 🤔 |
This doesn't handle script enqueing at the moment. Only registration. |
| // Step 7: Build packages | ||
| console.log( '\n📦 Building packages (production mode)...' ); | ||
| await exec( 'node', [ './bin/packages/build.mjs' ], { | ||
| await exec( 'wp-build', [], { |
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.
I'm surprised this doesn't need to be executed through npm exec / npx ? How is wp-build on the PATH ?
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.
My guess is that since it's a dependency in the root package.json it gets added to the "bin" folder in node_modules which is in the path when run through npm scripts?
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.
Hm, you're probably right about that, but it also means we can't run the file directly. I'm not sure about this script, but I've been running bin/packages/build.mjs directly to help keep a tight feedback loop with changes on it.
Not a deal-breaker.
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.
Should this folder be named build? For alignment to packages/[folder-name] directory placement -> @wordpress/[folder-name] package name. Also similar to wp-env being in packages/env.
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.
The reason I did that is to avoid conflicts with global .gitignore build folder. Granted an exception is possible but I was hesitant.
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.
Yeah I can see that being tricky, not only with .gitignore, but other configurations which target build directory patterns (e.g. linter ignore patterns). Doesn't feel great and I think we could manage with the exceptions, but it'll probably be a nuisance if we did.
|
One thing I realized is that this build tool assumes all wpScript: true package should result in |
| ); | ||
|
|
||
| console.log( '\n📄 Generating PHP registration files...\n' ); | ||
| const phpReplacements = await getPhpReplacements( ROOT_DIR ); |
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.
To my comment at #72740 (comment) , did you move it here because it's async ? I think it's okay, though passing around the arguments is pretty noisy.
Alternatively:
- Top-level async could be okay, though it might add some delay to the initial import (okay if we expect it'll be used)
- The top-level constant could be a shared promise value that's referenced in the individual functions
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.
Yes, mostly because of the async.
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.
I agree it's a bit noisy but I'm also not fully convinced about the alternatives.
| } | ||
| const resolved = import.meta.resolve( `${ fullPackageName }/package.json` ); | ||
| const result = getPackageInfoFromFile( fileURLToPath( resolved ) ); | ||
| packageJsonCache.set( fullPackageName, result ); |
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.
This cache kinda feels unnecessary? What's the bottleneck if we don't have this cache? import.meta.resolve ?
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.
yes, my assumption is that node resolution is probably a bit expensive.
Refs #72032
What?
Really excited about this PR, it brings the build tool that we iterated on lately to a new dedicated
@wordpress/buildscripts that plugins would be able to use to have their own scripts, modules and styles registered automatically.We're not going to get everything working perfectly from the start but we're going to need feedback to make it work. We're going to need a lot of docs as well but the README already has some light doc.
Testing Instructions
npm linkto use the package before it's published)