Skip to content

feat: add tree-shakeable Ionicons initialization - #13

Merged
rdlabo merged 5 commits into
mainfrom
codex/initialize-ionicons-runtime
Aug 27, 2026
Merged

feat: add tree-shakeable Ionicons initialization#13
rdlabo merged 5 commits into
mainfrom
codex/initialize-ionicons-runtime

Conversation

@rdlabo

@rdlabo rdlabo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the browser-safe initializeIonicons runtime entry point
  • register collected icons synchronously while loading the full catalog only in development builds
  • migrate recognized legacy generated initializers after explicit user consent
  • prompt with Yes selected by default during normal interactive CLI runs; No leaves the initializer unchanged and icon collection continues
  • require --migrate true in CI and other non-interactive environments, with --dry-run true available for preview
  • preserve custom initializers and normalize legacy bare generated icon imports to relative paths
  • keep existing package deep imports compatible while exposing the runtime for ESM and CJS
  • document interactive, explicit, dry-run, manual, and rollback migration paths

Verification

  • npm test — 92 tests passed
  • npm run lint
  • npm run build
  • git diff --check
  • real built-CLI acceptance: default Yes, explicit No, non-TTY without consent, --migrate true, and dry-run
  • regression coverage verifies No and non-TTY consent boundaries remain intact with --initialize true while icon collection continues
  • packed-package acceptance verified with new and migrated consumer fixtures
  • production bundle test verifies the full Ionicons catalog is removed
  • development bundle test verifies the full catalog remains available

The package version is intentionally unchanged; maintainers will handle the release version.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts entry 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.

Comment thread src/runtime.ts
Comment thread src/runtime.bundle.test.ts Outdated
@rdlabo
rdlabo merged commit 3f16ba4 into main Aug 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants