Skip to content

Commit 14cd04a

Browse files
committed
Icons: Add prepare script to generate source; don't bundle
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).
1 parent e6e0f56 commit 14cd04a

File tree

2 files changed

+1
-0
lines changed

2 files changed

+1
-0
lines changed

packages/icons/.npmignore

Whitespace-only changes.

packages/icons/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
},
4646
"scripts": {
4747
"prelint": "npm run build",
48+
"prepare": "npm run build",
4849
"build": "node lib/generate-library"
4950
}
5051
}

0 commit comments

Comments
 (0)