Commit 14cd04a
committed
Icons: Add
Alternative to (and revert of) #72299 (e82f668)
As of #71878 (8dff7de), Icons are defined as SVG files under
`src/library/`, and an accompanying `build` script will produce their
corresponding TSX files and an index at `src/library/index.ts`.
This patch reverts the addition of `.npmignore` in #72299. With this
revert, we return to the guarantee that any generated source code WILL
NOT be included in the published NPM package.
Instead, this patch adds a `prepare` script for @wordpress/icons to
trigger the code generation. This script is part of several NPM life
cycles, including installation (`install`, `ci`) and packing (`publish`,
`pack`), and runs in the background:
https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-scripts
This change is motivated by the fact that Gutenberg's workflow for
release NPM packages involves calling `npm version` (via Lerna) on a
fresh repository clone. Since `npm version` involves creating new
commits, the clone needs to be prepared to run pre-commit hooks.
Concretely, linting will fail if import paths to the icon library cannot
be resolved.
A more localised fix would have been to explicitly invoke a build of the
icons package during the package-release workflow (after `ci` and before
`version`), but with this approach based on `prepare` we guarantee the
availability of the generation code in (probably) all situations. In
particular, it eliminates the need to bundle the generated code in the
package (as previously mentioned).prepare script to generate source; don't bundle1 parent e6e0f56 commit 14cd04a
2 files changed
+1
-0
lines changedWhitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
0 commit comments