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 ] Ambient Import/Export Issues #7

Closed
nikuscs opened this issue Sep 12, 2022 · 5 comments
Closed

[ Bug ] Ambient Import/Export Issues #7

nikuscs opened this issue Sep 12, 2022 · 5 comments

Comments

@nikuscs
Copy link

nikuscs commented Sep 12, 2022

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! :)

@bluwy
Copy link
Owner

bluwy commented Sep 12, 2022

It looks like you need to move vite.config.js under docs/ for VitePress to pick up the Vite config

@nikuscs
Copy link
Author

nikuscs commented Sep 12, 2022

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.

@bluwy
Copy link
Owner

bluwy commented Sep 12, 2022

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.

@nikuscs
Copy link
Author

nikuscs commented Sep 12, 2022

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 :(

@nikuscs nikuscs closed this as completed Sep 12, 2022
@bluwy
Copy link
Owner

bluwy commented Sep 13, 2022

Or you could use vite.config.mjs do be less destructive too 😅 I prefer "type": "module" as it's nicer to move to ESM in the long run.

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

No branches or pull requests

2 participants