[ Bug ] Ambient Import/Export Issues
nikuscs opened this issue · comments
Hey! Thank you for the amazing package!
Im trying to get this working with vitepress but having some weird error on the :
import { createApp } from '@whyframe:app'
Seems like its unable to figure out that export that is done on compile time ( i assume , sorry for my ignorance :D )
Here is a small repo for reproduction:
https://github.com/igerslike/vitepress-whyframe
yarn install && yarn docs:dev
Enviorment:
- Node 18
- MacOS Ventura Beta5 ( ARM )
Thanks! :)
It looks like you need to move vite.config.js
under docs/
for VitePress to pick up the Vite config
Seems like it doesnt make any difference for me, even if i inline the vite config on the theme file, it seems to always fail, were you able to make it work with vite.config.js under docs/ and it worked? If yes could you please share more about your env?
Moving over to docs/ throws the following :
failed to start server. error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/xxxx/projects/vitepress-starter/node_modules/@whyframe/core/package.json
at new NodeError (node:internal/errors:393:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:340:9)
at packageExportsResolve (node:internal/modules/esm/resolve:564:7)
at resolveExports (node:internal/modules/cjs/loader:492:36)
at Module._findPath (node:internal/modules/cjs/loader:532:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:941:27)
at Module._load (node:internal/modules/cjs/loader:803:27)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/Users/xxx/projects/vitepress-starter/docs/vite.config.js:26:19) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
While if inline in the theme config it reproduces the OP.
Ah I think that's because whyframe
is an ESM only package. If you set "type": "module"
in the root package.json
of your project, that should fix it.
Indeed it works with a minimal setup, but brings another whole new set of issues :p since than all the other modules / files must be ESM as well. Ill pass it for now, but thanks for your time :)
Btw, tested with a more complex vitepress setup + module and still behaves the same, it simply doesnt understand the export :(
Or you could use vite.config.mjs
do be less destructive too "type": "module"
as it's nicer to move to ESM in the long run.