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 build error 0.16.4 Error: Dynamic require of "workbox-build" is not supported #540

Closed
mathiash98 opened this issue Jun 26, 2023 · 5 comments

Comments

@mathiash98
Copy link

mathiash98 commented Jun 26, 2023

Vite: 4.3.9
Vue: 3.3.4
vite-plugin-pwa: 0.16.4
NodeJs: 20.3.0

Error:

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
error during build:
Error: Dynamic require of "workbox-build" is not supported
    at file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite-plugin-pwa/dist/index.js:6:9
    at loadWorkboxBuild (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite-plugin-pwa/dist/index.js:258:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateServiceWorker (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite-plugin-pwa/dist/index.js:291:26)
    at async _generateSW (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite-plugin-pwa/dist/index.js:459:5)
    at async Object.handler (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite-plugin-pwa/dist/index.js:589:11)
    at async PluginDriver.hookParallel (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24821:17)
    at async Object.close (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:26073:13)
    at async build (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:46487:13)
    at async CAC.<anonymous> (file:///Users/mathias/Documents/GitHub/Frontend/node_modules/vite/dist/node/cli.js:812:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Tried:
0.16.x
0.15.x
0.14.x

Potentially related issues:
#405

@userquin
Copy link
Member

@mathiash98 can you check if you have workbox-build installed? From your log, it seems the dynamic import is failing, and then trying to load workbox-build using require: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/modules.ts#L13-L26

@userquin
Copy link
Member

From 0.16.0 you need Node 16: https://github.com/vite-pwa/vite-plugin-pwa#-install

@mathiash98
Copy link
Author

mathiash98 commented Jun 26, 2023

@userquin
workbox-build v7.0.0 is installed in node_modules at least. I have not referenced workbox-build in package.json if that is required.

  • According to yarn.lock workbox-buil v7 is installed as dependency from vite-plugin-pwa

Using Node 20.3

@userquin
Copy link
Member

@mathiash98 can you provide a minimal repro?

@mathiash98
Copy link
Author

Upon creating the minimal repro I found out I still had "vue-cli-plugin-vite": "~1.5.0", installed from when I transitioned from vue-cli-service to Vite.

Removing this package solved the problem!

Thanks for the time @userquin

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