feat: add tree-shakeable Ionicons initialization - #13
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new, tree-shakeable runtime entry point (initializeIonicons) and updates the CLI/migrations to optionally migrate older generated Ionicons initializers with explicit consent, aiming to keep the full Ionicons catalog out of production bundles while preserving development ergonomics.
Changes:
- Add
src/runtime.tsentry point and package exports for@rdlabo/ionic-angular-collect-icons/runtime(ESM + CJS) with updated build configuration. - Add consent-based migration flow for recognized legacy initializers (
--migrate, interactive default-Yes prompt, non-interactive requires explicit approval). - Add tests and documentation for runtime behavior, bundle-size expectations, and migration/rollback paths.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsup.config.ts | Adds multi-entry tsup build for CLI and new runtime output (node vs browser targets). |
| tsconfig.json | Sets TS module output to ESNext to align with ESM-focused build/export strategy. |
| src/utils/log-utils.ts | Adds format option to optionally skip formatting when saving changes. |
| src/utils/log-utils.test.ts | Tests the new “skip formatting” save behavior. |
| src/types/cli-options.ts | Introduces migrate?: boolean flag for explicit migration consent. |
| src/runtime.ts | New browser runtime initializeIonicons with dev-only full-catalog loading behavior. |
| src/runtime.test.ts | Unit tests for production vs dev behavior of initializeIonicons. |
| src/runtime.bundle.test.ts | Bundle-size regression tests to validate tree-shaking of full icon catalog in production. |
| src/migrations/standalone/index.ts | Adds consent boundary logic and integrates it into standalone migration flow. |
| src/migrations/standalone/index.test.ts | Tests consent boundary behavior (interactive No, non-interactive consent required). |
| src/migrations/standalone/0000-initialize-add-icons.ts | Enhances initializer detection/migration and normalizes generated import specifiers. |
| src/migrations/standalone/0000-initialize-add-icons.test.ts | Expands coverage for initializer migration cases and edge conditions. |
| src/index.ts | Wires interactive confirmation prompt (default Yes) for legacy initializer migration. |
| package.json | Adds exports for ./runtime, updates build scripts, adds esbuild dev dependency. |
| package-lock.json | Locks esbuild@0.24.2. |
| docs/options.md | Documents --initialize changes and new --migrate option. |
| docs/migration.md | Adds detailed initializer upgrade guide, consent behavior, and rollback guidance. |
| docs/initialize.md | Updates initialization docs to reference runtime and migration consent flow. |
Suppressed comments (1)
src/runtime.bundle.test.ts:57
- Same as above: the development bundle assertion uses a hard-coded Ionicons catalog input path in the metafile. Matching by normalized path segments will keep this test stable if Ionicons reorganizes its published file layout.
const catalogBytes = Object.values(development.metafile.outputs).reduce(
(total, output) =>
total +
(output.inputs["node_modules/ionicons/icons/index.mjs"]
?.bytesInOutput ?? 0),
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
initializeIoniconsruntime entry point--migrate truein CI and other non-interactive environments, with--dry-run trueavailable for previewVerification
npm test— 92 tests passednpm run lintnpm run buildgit diff --check--migrate true, and dry-run--initialize truewhile icon collection continuesThe package version is intentionally unchanged; maintainers will handle the release version.