Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v8.x
Current Behavior
When I run unit tests in a component library that I am building, I face the following error:
Error: Directory import '[domain-lib-repo]/node_modules/@ionic/core/components' is not supported resolving ES modules imported from '[domain-lib-repo]/node_modules/@ionic/vue/dist/index.js
Did you mean to import "@ionic/core/components/index.js"?
Expected Behavior
Ability to run unit tests with vitest without a build error.
Steps to Reproduce
In the project I am working on, I am producing a "generic" components library, use by a "domain-specific" components library, and both are used in the final app.
Both libs are build with Vite in lib mode with rollup, with vue and @ionic/vue declared as dev and peer dependencies, and rollup configured to treat these packages as external. Here is what the vite config looks like:
export default defineConfig({
plugins: [vue(), dts({ insertTypesEntry: true })],
build: {
lib: {
entry: "src/index.ts",
name: "MyLib",
fileName: "my-lib",
},
rollupOptions: {
external: ["vue", "vue-i18n", "vue-router", "@ionic/vue"],
output: {
globals: {
vue: "Vue",
"vue-i18n": "VueI18n",
"vue-router": "VueRouter",
"@ionic/vue": "IonicVue",
},
},
},
},
});When I run unit tests in the domain-specific library, I face the following error:
Error: Directory import '[domain-lib-repo]/node_modules/@ionic/core/components' is not supported resolving ES modules imported from '[domain-lib-repo]/node_modules/@ionic/vue/dist/index.js
Did you mean to import "@ionic/core/components/index.js"?
Interestingly, out of the two components that I have started writing, the tests for one of them work fine, but not the other. The only relevant difference I can see is that the failing component makes use of a component from the "generic" library.
Unfortunately, I was not able to create a minimum reproducing scenario so far. But I notice that in @ionic/vue/dist/index.js, there is an import line 80 (for version 8.7.7) to @ionic/core/components:
import { LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, initialize, modalController as modalController$1, popoverController as popoverController$1, alertController as alertController$1, actionSheetController as actionSheetController$1, loadingController as loadingController$1, pickerController as pickerController$1, toastController as toastController$1 } from '@ionic/core/components';
Since the package now exports only an ES module, isn't that an incorrect statement in the build output of @ionic/vue? Shouldn't it be @ionic/core/components/index.js like the error mentions?
Code Reproduction URL
- https://www.npmjs.com/package/@ionic/vue/v/8.7.7?activeTab=code
- https://gitlab.com/rthouvenin/ionic-repro
Ionic Info
Ionic:
Ionic CLI : 7.2.1 (/home/romain/.nvm/versions/node/v20.19.5/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/vue 8.4.2
Capacitor:
Capacitor CLI : 6.2.1
@capacitor/android : 6.2.0
@capacitor/core : 6.2.1
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 2.0.1
System:
NodeJS : v20.19.5 (/home/romain/.nvm/versions/node/v20.19.5/bin/node)
npm : 10.8.2
OS : Linux 6.8
Additional Information
No response
Activity
ionitron-bot commentedon Oct 17, 2025
Thanks for the issue! This issue has been labeled as
needs reproduction. This label is added to issues that need a code reproduction.Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.
If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.
For a guide on how to create a good reproduction, see our Contributing Guide.
rthouvenin commentedon Oct 21, 2025
I'll continue to try creating a minimum reproducing set-up, but don't you agree that regardless of how I use Ionic, the built package contains a JS statement that is invalid for a ES module?
rthouvenin commentedon Oct 21, 2025
I finally managed to pin down a fairly minimal scenario:
The
group-uifolder contains the code for a minimal component library. It depends on another components library@rthouvenin/ionic-repro-base-lib, built similarly with the code in themy-libfolder and published on npmjs registry.Some clues that may help explain the problem or why it does not occur more often:
npm run test -- tests/components/IndieTile.spec.tsruns without error.IndieTileand its test don't make use of@rthouvenin/ionic-repro-base-libnpm install ../my-libto get the package locally instead of from the registry,npm run testworks without errorShaneK commentedon May 29, 2026
Hey! I have a PR built off of major-9.0 that will address this issue. There's a dev build here if you would like to verify for yourself:
However, it is based off of major-9.0 because it is technically a breaking change in that it limits the imports that can be used to officially documented imports. I considered this breaking behavior because we don't know who is importing what and how.
There's also other big changes in major-9.0 already that may cause this dev build to have issues with a bigger project, but it did pass against your reproduction repo.
feat(core): add package exports map for ESM subpath resolution (#31180)
ionitron-bot commentedon Sep 18, 2026
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.