Closed aryzing closed 10 months ago
Had a quick look at the plugin's source, could this banner be the issue?
I got a same issues with you. import absolute path with build。
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
globals set false will solve then polyfills will invalid。 did you solve this problem?
This is fixed in v0.11.2
.
It seems that when using this plugin, one of the related output files has an absolute import path, which fails to resolve when loaded in the broswer:
Other assets I've inspected don't have the
/home/path/to/repo
bit, and start directly at/node_modules/...
.This is what the Vite config looks like,
```ts import react from '@vitejs/plugin-react-swc'; import path from 'path'; import { UserConfig } from 'vite'; import { nodePolyfills } from 'vite-plugin-node-polyfills'; import wasm from 'vite-plugin-wasm'; import webExtension, { readJsonFile } from 'vite-plugin-web-extension'; import tsconfigPaths from 'vite-tsconfig-paths'; const config: UserConfig = { build: { target: 'esnext', }, plugins: [ react(), tsconfigPaths(), nodePolyfills(), wasm(), webExtension(), ], resolve: { alias: { // Needed by the `vite-plugin-web-extension` plugin. // See https://github.com/aklinker1/vite-plugin-web-extension/issues/84#issuecomment-1471196461 // In dev mode, make sure fast refresh works '/@react-refresh': path.resolve('node_modules/@vitejs/plugin-react-swc/refresh-runtime.js'), }, }, }; export default config; ```Any idea how to fix the imports? Could the web extension plugin be interfering somehow?