Skip to content

feat(core): add package exports map for ESM subpath resolution#31180

Open
ShaneK wants to merge 3 commits into
major-9.0from
feat/core-esm-exports
Open

feat(core): add package exports map for ESM subpath resolution#31180
ShaneK wants to merge 3 commits into
major-9.0from
feat/core-esm-exports

Conversation

@ShaneK
Copy link
Copy Markdown
Member

@ShaneK ShaneK commented May 29, 2026

Issue number: resolves #30982, resolves #30686, resolves #30730


What is the current behavior?

Core's package.json has no exports field. Webpack and Vite handle that fine, but Node's strict ESM resolver ignores nested package.json files and refuses directory imports. So when the built @ionic/angular bundle does import { defineCustomElements } from '@ionic/core/loader' or import { componentOnReady } from '@ionic/core/components', anything running under Node ESM (Angular 21's default Vitest builder, raw Node, etc.) throws ERR_UNSUPPORTED_DIR_IMPORT. All three resolved issues have the same root problem

What is the new behavior?

Core's package.json now declares an exports map that covers every directory in files with explicit index.js resolution where directory imports happen, and wildcards for the deep paths

Does this introduce a breaking change?

  • Yes
  • No

When you add exports to a package.json, it becomes an allowlist. This means that every undocumented import path will break unless you're using moduleResolution: node

Related docs PR: ionic-team/ionic-docs#4523

Other information

Apps already on moduleResolution: "bundler" (Angular 17+ default, Vite default) pick up the fix automatically. Apps on classic moduleResolution: "node" keep working through the legacy fields and are unaffected.

Current dev build:

8.8.9-dev.11780086312.13aac420

@ShaneK ShaneK requested a review from a team as a code owner May 29, 2026 19:27
@ShaneK ShaneK requested a review from brandyscarney May 29, 2026 19:27
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment May 29, 2026 8:10pm

Request Review

@github-actions github-actions Bot added the package: core @ionic/core package label May 29, 2026
Copy link
Copy Markdown
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants