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 plugin / vite example project do not work #211

Open
afreidz opened this issue Nov 7, 2022 · 10 comments
Open

vite plugin / vite example project do not work #211

afreidz opened this issue Nov 7, 2022 · 10 comments

Comments

@afreidz
Copy link

afreidz commented Nov 7, 2022

When i install/use the vite plugin on a project I am unable to run the app. I also tried a fresh copy of the vite example in this repo and was met with the same error:

Error: Build failed with 25 errors:
node_modules/@app-config/config/dist/es/index.js:1:9: ERROR: No matching export in "browser-external:path" for import "join"
node_modules/@app-config/core/dist/es/config-source.js:1:9: ERROR: No matching export in "browser-external:path" for import "extname"
node_modules/@app-config/core/dist/es/config-source.js:4:9: ERROR: No matching export in "node_modules/json5/dist/index.mjs" for import "parse"
node_modules/@app-config/core/dist/es/config-source.js:4:30: ERROR: No matching export in "node_modules/json5/dist/index.mjs" for import "stringify"
node_modules/@app-config/core/dist/es/parsed-value.js:1:9: ERROR: No matching export in "browser-external:util" for import "inspect"
...
    at failureErrorWithLog (/Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:1624:15)
    at /Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:1266:28
    at runOnEndCallbacks (/Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:1046:63)
    at buildResponseToResult (/Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:1264:7)
    at /Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:1377:14
    at /Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:678:9
    at handleIncomingPacket (/Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:775:9)
    at Socket.readFromStdout (/Users/afreide/Code/vite-project/node_modules/esbuild/lib/main.js:644:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)

nodejs version: v16.18.1

Repo steps:

  • clone/download monorepo
  • run npm i from /examples/vite-project
  • run npm start
  • build fails
@joelgallant
Copy link
Contributor

We use yarn for the monorepo, I imagine the issue is npm works differently? We do check that the vite plugin works in CI

@afreidz
Copy link
Author

afreidz commented Nov 8, 2022

I can try yarn ... but doesn't it stand to reason that many people would be using npm when depending on the vite plugin? if you are able to get it to work with npm then im good with considering this user/env-error 😄

@joelgallant
Copy link
Contributor

joelgallant commented Nov 8, 2022 via email

@afreidz
Copy link
Author

afreidz commented Nov 8, 2022

ok ... thats what i tried, and when consuming the vite plugin, vite will not build and produces module export errors in json5 like the above stack. perhaps a recent release of json5 is breaking something here? can you confirm that the vite plugin is working within the last day or 2?

@afreidz
Copy link
Author

afreidz commented Nov 8, 2022

UPDATE: i can get both the example project and my repo to work if i build vite and serve the output from /dist ... however vite will not build/run in development mode (same error as above) with neither npm nor yarn

@joelgallant
Copy link
Contributor

joelgallant commented Nov 8, 2022 via email

@afreidz
Copy link
Author

afreidz commented Nov 8, 2022

thanks! strange. for now i was able to work around it by running a build step to output app-config to .env ... which vite supports ootb

@joelgallant
Copy link
Contributor

Just for the record, I was able to repro this as described in a clean vite project. Will try and get a fix out today if I can find the issue.

@joelgallant
Copy link
Contributor

Yeah, this is somewhat trickier than I thought. The plugin system doesn't work consistently between dev and prod builds, and plugin API has changes a bit from v2 and v3. I would need more than the couple hours I have today to get this all sorted out.

fwiw, I think it's basically caused by the "virtual module" concept, which breaks module names - the plugin uses names of modules (appConigImportRegex) to determine if it should intercept loading.

Thanks for pointing this out! This is definitely the tricky bit when authoring a plugin for a build system I don't currently dogfood - API docs and stability tend to be fast moving and need consumers to point out breakages.

@afreidz
Copy link
Author

afreidz commented Nov 14, 2022 via email

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