Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ionic not compatible with vitest #25134

Closed
4 of 6 tasks
riderx opened this issue Apr 15, 2022 · 3 comments
Closed
4 of 6 tasks

bug: ionic not compatible with vitest #25134

riderx opened this issue Apr 15, 2022 · 3 comments
Labels

Comments

@riderx
Copy link

riderx commented Apr 15, 2022

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

When switch from jest to Vitest, the vite based alternative, i got this error:

SyntaxError: Cannot use import statement outside a module
 ❯ wrapSafe internal/modules/cjs/loader.js:1001:16
 ❯ Module._compile internal/modules/cjs/loader.js:1049:27
 ❯ Object.Module._extensions..js internal/modules/cjs/loader.js:1114:10
 ❯ Module.load internal/modules/cjs/loader.js:950:32
 ❯ Function.Module._load internal/modules/cjs/loader.js:790:12
 ❯ Module.require internal/modules/cjs/loader.js:974:19
 ❯ require internal/modules/cjs/helpers.js:101:18
 ❯ Object.<anonymous> node_modules/.pnpm/@ionic+vue@6.1.0/node_modules/@ionic/vue/dist/index.js:6:25
      4| 
      5| const vue = require('vue');
      6| const ionAccordion_js = require('@ionic/core/components/ion-accordion.js');
       |                         ^
      7| const ionAccordionGroup_js = require('@ionic/core/components/ion-accordion-group.js');
      8| const ionAvatar_js = require('@ionic/core/components/ion-avatar.js');
 ❯ Module._compile internal/modules/cjs/loader.js:1085:14
 ❯ Object.Module._extensions..js internal/modules/cjs/loader.js:1114:10

Module /Users/martindonadieu/Documents/Projects.nosync/Mimesis/node_modules/.pnpm/@ionic+core@6.1.0/node_modules/@ionic/core/components/ion-accordion.js:4 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "@ionic/core" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

Expected Behavior

Importing ionic should work for vite and vitest without issue

Steps to Reproduce

git clone this app: https://github.com/Forgr-ee/Mimesis/
pnpm i
pnpm test and you will get the issue

Code Reproduction URL

https://github.com/Forgr-ee/Mimesis

Ionic Info

Ionic:

   Ionic CLI       : 6.18.2 (/Users/martindonadieu/pnpm-global/5/node_modules/.pnpm/@ionic+cli@6.18.2/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 6.1.0

Capacitor:

   Capacitor CLI      : 3.4.3
   @capacitor/android : 3.4.3
   @capacitor/core    : 3.4.3
   @capacitor/ios     : 3.4.3

Utility:

   cordova-res (update available: 0.15.4) : 0.15.2
   native-run                             : 1.5.0

System:

   NodeJS : v14.19.1 (/usr/local/bin/node)
   npm    : 6.14.16
   OS     : macOS Monterey

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Apr 15, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I am going to close this as a duplicate of #25104.

@riderx
Copy link
Author

riderx commented Apr 15, 2022

oh sorry i try to search for it but didn't find it

@ionitron-bot
Copy link

ionitron-bot bot commented May 15, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants