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

error on ESM environment #13

Closed
userquin opened this issue Nov 23, 2021 · 7 comments · Fixed by #14
Closed

error on ESM environment #13

userquin opened this issue Nov 23, 2021 · 7 comments · Fixed by #14

Comments

@userquin
Copy link
Member

userquin commented Nov 23, 2021

context: unplugin/unplugin-auto-import#79 (comment)

failed to load config from C:\Users\joshua\test\vite.config.ts
Error: Dynamic require of "os" is not supported
    at __require (file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:26:9)
    at node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js (file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:1156:14)
    at __require2 (file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:29:44)
    at node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js (file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:1412:56)
    at __require2 (file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:29:44)
    at file:///C:/Users/joshua/test/node_modules/vite-plugin-inspect/dist/index.mjs:34444:31
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadConfigFromFile (C:\Users\joshua\test\node_modules\vite\dist\node\chunks\dep-e0fe87f8.js:68598:31)
@userquin
Copy link
Member Author

userquin commented Nov 23, 2021

@antfu it seems we are using chalk (not esm ready), changing to use kolorist (the same change we made on unplugin-icons)

EDIT: once removed chalk, now @rollup/pluginutils uses picomatch, not esm ready?, we can remove @rollup/pluginutils and include a custom implementation (just copy/paste from it): I'll try to clone the behavior, we also need to provide FilterPattern: rollup/plugins#539

EDIT 2: to align with vite we should use micromatch: vitejs/vite#5610

@josh-hemphill the error also using vitesse template repo?

@josh-hemphill
Copy link

josh-hemphill the error also using vitesse template repo?

I believe so, yes.

@josh-hemphill
Copy link

Yeah, that's the first error after changing the project type.
Though to get vitesse working I have to do npm i -D critters@^0.0.10 @vueuse/head@^0.5.1 to get the packages to install.

@RoenLie
Copy link

RoenLie commented Dec 1, 2021

Also having this issue when I set my package.json to type:module.
Changing the export statement in vite plugin inspect to js instead of mjs solves the issue on my end.
"exports": { ".": { "require": "./dist/index.js", "import": "./dist/index.js" // changed from mjs to js. } }

It does mean I have to import the plugin like this however.
( inspect as any ).default()

@emme1444
Copy link

@userquin any updates on this?

@userquin
Copy link
Member Author

@emme1444 I'm working on it right now

@userquin
Copy link
Member Author

userquin commented Dec 30, 2021

@emme1444 I have it working with vite + svelte and vitesse + type module + vitesse + NO type module (the same project): you can see it in action:

/cc @antfu PR in a few minutes: some plugins must be used with .default(), for example VueI18n and Layouts using vitesse project.

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 a pull request may close this issue.

4 participants