Repository navigation
feat(angular, react, vue): export additional core APIs - #31864
Conversation
The docs import getMode, componentOnReady, OverlayEventDetail and other APIs from @ionic/core in framework examples. Those imports only resolve because npm hoists the framework's @ionic/core dependency, so they fail with pnpm or Yarn PnP. Re-export them from each framework package. - react: getMode, componentOnReady, menuController, OverlayEventDetail, RangeValue, SelectInterface - vue: getMode, componentOnReady, OverlayEventDetail, RangeValue, SelectInterface - angular (lazy and standalone): componentOnReady, OverlayEventDetail, RangeValue, SelectInterface Angular reads the mode through Config and has its own MenuController, so it does not export getMode or menuController.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The security guide imports setNonce from @ionic/core/loader. React, Vue and Angular standalone render through @ionic/core/components, which has its own setNonce. Re-export the one each framework uses: the components build for React, Vue and Angular standalone, and the loader for Angular lazy.
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me! Just one thing on the Vue test, since nothing there would catch the new types going missing.
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
| import type { OverlayEventDetail, RangeValue, SelectInterface } from "./index"; | ||
|
|
||
| export type CoreTypeExports = [OverlayEventDetail, RangeValue, SelectInterface]; |
There was a problem hiding this comment.
Since rollup.config.mjs gives the TypeScript plugin the whole tsconfig, this file ends up in the published package as dist/types/exports.type-test.d.ts. Excluding it in rollup.config.mjs keeps it out of dist, and npm run typecheck still checks it:
typescript({ exclude: ['**/*.type-test.ts'] }),The pattern resolves from rootDir (src), so src/**/*.type-test.ts doesn't match.
There was a problem hiding this comment.
Thanks! Added your exclude in 339481b. The file is no longer in dist, and typecheck still catches a removed export.
| componentOnReady, | ||
| setNonce, |
There was a problem hiding this comment.
Nothing in CI fails if one of these exports is dropped from @ionic/angular or @ionic/angular/standalone. verify-exports.js only checks the per-component entries in package.json, and the Angular test app doesn't import any of them.
The Angular docs examples will import OverlayEventDetail and the rest from here too, so please add a usage of componentOnReady, setNonce, OverlayEventDetail, RangeValue and SelectInterface to the test app, once under standalone and once under lazy. That way a removed export fails CI, the same way the Vue type-test file does.
There was a problem hiding this comment.
Good call! Added the five exports to the providers pages in both lazy and standalone in e6c1615, with a spec for each. Removing any of them now fails the test app build.
Co-authored-by: Maria Hutt <13530427+thetaPC@users.noreply.github.com>
Issue number: internal
What is the current behavior?
The docs import several APIs from
@ionic/corein Angular, React and Vue examples, such asgetModeon the Config page,OverlayEventDetailin the modal examples, andsetNoncefrom@ionic/core/loaderin the security guide. The framework packages don't re-export them, and the install docs never say to add@ionic/core.These imports only resolve because npm hoists the framework's
@ionic/coredependency, so they fail with pnpm or Yarn PnP. Each framework package pins@ionic/coreto an exact version when published, so adding it yourself at another version installs two copies.What is the new behavior?
@ionic/reactexportsgetMode,componentOnReady,menuController,setNonce,OverlayEventDetail,RangeValueandSelectInterface.@ionic/vueexportsgetMode,componentOnReady,setNonce,OverlayEventDetail,RangeValueandSelectInterface. It already exportedmenuController.@ionic/angularexportscomponentOnReady,setNonce,OverlayEventDetail,RangeValueandSelectInterfacefrom both the standalone and lazy entry points. It doesn't exportgetModeormenuController, because Angular reads the mode throughConfigand has its ownMenuController.Does this introduce a breaking change?
Other information
Dev build:
9.0.15-dev.11796247574.1ecbe59dReact's
alertControlleris left out on purpose. The only docs page that imports it is the JavaScript-onlyion-routepage, and React apps useuseIonAlertorIonAlert.setNoncecomes from the build each framework renders with. React, Vue and Angular standalone use@ionic/core/components, which has its ownsetNonce, so the security guide's@ionic/core/loaderimport doesn't apply to them. Angular lazy re-exports the loader'ssetNonce.The docs examples will switch to importing from the framework package in a follow-up.