-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use npm workspaces for packages #65681
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c48fcbe
Update package managing flow
t-hamano bd2eaef
Remove root dependency on workspaces
sirreal fc3244e
Remove file refs
sirreal 3a8c5e3
Remove redundant packge npmrc files
sirreal f2bb6ee
Change prebuild packages to use npm workspaces
sirreal 126195a
Adapt scriptModules build for workspaces
sirreal f93f497
Adapt packages webpack config for workspaces
sirreal 934531f
Ignore "dev" scripts
sirreal e060585
Annotate packages included as WordPress scripts
sirreal de6ce22
Do not annotate react-native packages
sirreal 40095fe
Update packages webpack to use wpScript package.json
sirreal c582ff9
Implement Gutenberg specific check-licenses script
sirreal ede398e
Remove redundant entries from the ignore list
sirreal 6bdb2ec
Update lockfile
sirreal c89010a
dedupe
sirreal 8615c07
Update some docs langauge about lerna and npm workspaces
sirreal 6d4e9b9
Remove the note about creating `.npmrc` file for a new package
gziolo 770ab08
Update the documentation to provide better instruction for uninstalli…
gziolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { spawnSync } from 'node:child_process'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { checkDepsInTree } from '../packages/scripts/utils/license.js'; | ||
|
||
const ignored = [ '@ampproject/remapping' ]; | ||
|
||
/* | ||
* `wp-scripts check-licenses` uses prod and dev dependencies of the package to scan for dependencies. With npm workspaces, workspace packages (the @wordpress/* packages) are not listed in the main package json and this approach does not work. | ||
* | ||
* Instead, work from an npm query that uses some custom information in package.json files to declare packages that are shipped with WordPress (and must be GPLv2 compatible) or other files that may use more permissive licenses. | ||
*/ | ||
|
||
/** | ||
* @typedef PackageInfo | ||
* @property {string} name Package name. | ||
*/ | ||
|
||
/** @type {ReadonlyArray<PackageInfo>} */ | ||
const workspacePackages = JSON.parse( | ||
spawnSync( | ||
'npm', | ||
[ | ||
'query', | ||
'.workspace:attr([wpScript]), .workspace:attr([wpScriptModuleExports])', | ||
], | ||
/* | ||
* Set the max buffer to ~157MB, since the output size for | ||
* prod is ~21 MB and dev is ~110 MB | ||
*/ | ||
{ maxBuffer: 1024 * 1024 * 150 } | ||
).stdout | ||
); | ||
|
||
const packageNames = workspacePackages.map( ( { name } ) => name ); | ||
|
||
const dependenciesToProcess = JSON.parse( | ||
spawnSync( | ||
'npm', | ||
[ | ||
'ls', | ||
'--json', | ||
'--long', | ||
'--all', | ||
'--lockfile-only', | ||
'--omit=dev', | ||
...packageNames.map( | ||
( packageName ) => `--workspace=${ packageName }` | ||
), | ||
], | ||
/* | ||
* Set the max buffer to ~157MB, since the output size for | ||
* prod is ~21 MB and dev is ~110 MB | ||
*/ | ||
{ maxBuffer: 1024 * 1024 * 150 } | ||
).stdout | ||
).dependencies; | ||
|
||
checkDepsInTree( dependenciesToProcess, { | ||
ignored, | ||
gpl2: true, | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
# Managing Packages | ||
|
||
This repository uses [monorepo] to manage WordPress modules and publish them with [lerna] as packages to [npm]. This enforces certain steps in the workflow which are described in details in [packages](https://github.com/WordPress/gutenberg/blob/HEAD/packages/README.md) documentation. | ||
This repository uses [npm workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces) to manage WordPress packages and [lerna](https://lerna.js.org/) to publish them to [npm](https://www.npmjs.com/). This enforces certain steps in the workflow which are described in details in [packages](https://github.com/WordPress/gutenberg/blob/HEAD/packages/README.md) documentation. | ||
|
||
Maintaining dozens of npm packages is difficult—it can be tough to keep track of changes. That's why we use `CHANGELOG.md` files for each package to simplify the release process. As a contributor, you should add an entry to the aforementioned file each time you contribute adding production code as described in [Maintaining Changelogs](https://github.com/WordPress/gutenberg/blob/HEAD/packages/README.md#maintaining-changelogs) section. | ||
|
||
Publishing WordPress packages to npm is automated by synchronizing it with the bi-weekly Gutenberg plugin RC1 release. You can learn more about this process and other ways to publish new versions of npm packages in the [Gutenberg Release Process document](/docs/contributors/code/release.md#packages-releases-to-npm-and-wordpress-core-updates). | ||
|
||
[lerna]: https://lerna.js.org/ | ||
[monorepo]: https://monorepo.tools | ||
[npm]: https://www.npmjs.com/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 see it’s licensed under Apache-2.0 license so it would be handy to add now a comment explaining why it can be ignored. I hope it’s only listed as a dependency of a dependency but never used.
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.
So this is a dependency of
@babel/core
. The only production package that depends on@babel/core
that I could locate is@emotion/css
. It's used in a single place:gutenberg/packages/components/src/utils/hooks/use-cx.ts
Lines 7 to 10 in b8cd03d
It doesn't seem to use Babel at all:
The latest version of
@emotion/css
doesn't define@babel/core
as a peer dependency anymore:https://github.com/emotion-js/emotion/blob/main/packages/css/package.json
It has changed with the following PR: emotion-js/emotion#2985. The package was at
11.10.5
at the time of that change. The version used in the Gutenberg repository is11.7.1
. It could be that bumping these dependencies would make this ignore obsolete.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.
That would be nice, but I'd prefer to leave upgrades for after this PR has landed. It's already quite a big and potentially disruptive PR.
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 wanted to document everything as I was digging into the details of prior decisions. There is no need for any follow-up in this PR.