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

[vite] - No matching export for import pathToFileUrl #232

Closed
jdmorlan opened this issue Mar 5, 2021 · 5 comments
Closed

[vite] - No matching export for import pathToFileUrl #232

jdmorlan opened this issue Mar 5, 2021 · 5 comments

Comments

@jdmorlan
Copy link

jdmorlan commented Mar 5, 2021

I'm using ViteJS as the build tool for a React application. When I try to run the vite dev server I get the error referenced in the title above. I'm not very well versed in the workings of awilix, but attempted to Google for that error. I was able to find a couple of things about loadModules and Windows tests, but didn't seem to match this issue.

I setup a repo that isolates vite, awilix and jishida/react-awilix. I'm more than willing to do more investigating, but I'm kind of stuck with what to attempt next. Any help or advice would be greatly appreciated.

Error Message

error

@jeffijoe
Copy link
Owner

jeffijoe commented Mar 5, 2021

You need to configure your build tool to use the browser build.

@simonvizzini
Copy link

Hi @jdmorlan, I know it's been a while when you asked this question but I'm facing the same issue. Have you ever figured out how to properly configure Vite to make it work with Awilix? I know that Vite is using esbuild under the hood and esbuild has a platform option which can be set to node or browser, but it doesn't seem to be directly exposed in the Vite config. Closes thing I have found is the optimizeDeps.esbuildOptions Vite option which does exposes the platform option from esbuild, but setting it to browser didn't change anything, Vite is still using the node-only lib/awilix.module bundle instead of the lib/awilix.browser bundle.

Only workaround I found so far is to directly import the browser bundle in my code. Typescript then complains but at least it is still getting built.

@downace
Copy link

downace commented Aug 18, 2022

I've faced similar issue.

Added alias in my vite.config.ts to make it work:

export default {
  resolve: {
    alias: {
      'awilix': 'awilix/lib/awilix.browser'
    }
  }
}

Maybe it should be noted in the docs...

@jeffijoe
Copy link
Owner

I would think it's something that should be fixed on Vite's side? Webpack resolves the browser build by default just fine.

@downace
Copy link

downace commented Aug 22, 2022

I would think it's something that should be fixed on Vite's side? Webpack resolves the browser build by default just fine.

Ah, I think I got it. Found this open issue in Vite repo: vitejs/vite#7576. Looks like the problem is the same.

This issue was closed.
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

4 participants