alienfast / vite-plugin-i18next-loader

Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.
Other
42 stars 3 forks source link

Electron runtime issue - [vite]: Rollup failed to resolve import "virtual:i18next-loader" #18

Open grctest opened 6 months ago

grctest commented 6 months ago

I'm getting this blocking error during build:

error during build:
Error: [vite]: Rollup failed to resolve import "virtual:i18next-loader" from "filepath/src/localization/index.js".This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at viteWarn (file:///filepath/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:67190:27)
    at onRollupWarning (file:///filepath/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:67218:9)
    at onwarn (file:///filepath/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:66922:13)
    at file:///filepath/node_modules/rollup/dist/es/shared/node-entry.js:18300:13
    at Object.logger [as onLog] (file:///filepath/node_modules/rollup/dist/es/shared/node-entry.js:19957:9)
    at ModuleLoader.handleInvalidResolvedId (file:///filepath/node_modules/rollup/dist/es/shared/node-entry.js:18901:26)
    at file:///filepath/node_modules/rollup/dist/es/shared/node-entry.js:18859:26

I tried adding the following to my vite config without success:

build: {
    rollupOptions: {
      external: ['virtual:i18next-loader'],
    },
  }

Is there a configuration I'm missing for rollup to support vite virtual modules?

Thanks

rosskevin commented 6 months ago

I reviewed our archetype app and we do nothing with virtual:i18next-loader to make it work.

To me, it looks like this path actually doesn't exist where rollup (via vite) is looking for it, so you might have a path problem?

grctest commented 6 months ago

Despite the console error in the dev terminal, the virtual module functions as expected.

I've created a discussion in the Vite repo in case it's an issue to do with virtual modules during vite build

https://github.com/vitejs/vite/discussions/16142

I have been working on implementing electron context isolation & disabling render node integration for application security best practices & the error was not breaking the build process prior to these changes, so perhaps that's a factor too?