Skip to content

fix(package): move @stencil/core to devDependencies - #1522

Open
Goldloli wants to merge 1 commit into
ionic-team:mainfrom
Goldloli:fix/stencil-core-dev-dependency
Open

Goldloli wants to merge 1 commit into
ionic-team:mainfrom
Goldloli:fix/stencil-core-dev-dependency

Conversation

@Goldloli

Copy link
Copy Markdown

Fixes #1519

Problem

npm install ionicons pulls in @stencil/core as a runtime dependency, even though nothing shipped in the package needs it at runtime.

Why it is unused at runtime

Since e04eccc (v8.0.0) the custom elements output target is generated with externalRuntime: false, which inlines the Stencil runtime into components/:

  • dist/ (main + loader): self-contained, no stencil imports
  • components/ (custom elements + direct component path): Stencil runtime inlined
  • icons/: data-URL strings only

The only shipped artifact that references @stencil/core is dist/collection, which is not reachable through the exports map. It is consumed by Stencil projects that re-compile the collection, and those projects necessarily provide their own @stencil/core at build time.

Verified on the published 8.1.1 tarball: none of the entry points (dist/index.js, dist/index.cjs.js, dist/loader/index.js, components/index.js, components/ion-icon.js, icons/index.*) contains an @stencil/core import.

Change

Move @stencil/core from dependencies to devDependencies. The lockfile picks up only dev/peer markers — no version or resolved URL changed.

Verification

  • npm run build before/after: byte-identical output (compared full hash trees of dist/, components/, icons/)
  • npm run test.spec: 50 passed, 2 skipped — same before and after
  • npm pack before/after, each installed into a clean consumer project:
    • before: ionicons └── @stencil/core@4.45.6 (3 packages installed)
    • after: ionicons alone (1 package), no node_modules/@stencil/core
  • Functional smoke test in the "after" consumer (jsdom), where @stencil/core is not resolvable:
    • import 'ionicons', import 'ionicons/components/ion-icon.js', require('ionicons'), require('ionicons/icons') all work
    • defineCustomElement() registers ion-icon; addIcons({ checkmark }) + <ion-icon name="checkmark"> renders the sanitized SVG into the shadow DOM
    • the unregistered-name path still emits the expected getAssetPath fallback warning instead of throwing
  • npm run prettier.dry-run: clean

Risk

None for the documented entry points — they do not import @stencil/core. The only behavioral difference is that consumers no longer receive a transitive @stencil/core copy; a project that relied on it being hoisted would already have to declare it itself, because it can only matter in a Stencil build that provides its own copy.

The custom elements build has inlined the Stencil runtime since
e04eccc (externalRuntime: false), and none of the package's export
targets (dist, loader, components, icons) import @stencil/core at
runtime. The only shipped artifact that references it, dist/collection,
is consumed by Stencil projects that provide their own copy at build
time. Moving it to devDependencies removes it from the dependency
tree of every `npm install ionicons` consumer.

Fixes ionic-team#1519

This branch has not been deployed

No deployments
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.

bug: @stencil/core should be a devDependency

1 participant