Clarkkkk / workbox-rspack-plugin

An Rspack plugin to use workbox.
MIT License
8 stars 1 forks source link

Cannot find module '...\node_modules\workbox-build\build\lib\bundle' #6

Open theninthsky opened 2 weeks ago

theninthsky commented 2 weeks ago

Hello. I'm getting the following error when trying to build my app:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Projects\client-side-rendering\node_modules\workbox-build\build\lib\bundle' imported from C:\Projects\client-side-rendering\node_modules\@aaroon\workbox-rspack-plugin\dist\index.js
Did you mean to import workbox-build/build/lib/bundle.js?
    at finalizeResolution (node:internal/modules/esm/resolve:264:11)
    at moduleResolve (node:internal/modules/esm/resolve:917:10)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///C:/Projects/client-side-rendering/node_modules/workbox-build/build/lib/bundle'
}

This is my rspack branch in which I experience the error: https://github.com/theninthsky/client-side-rendering/tree/rspack

Can you please take a look at it?

Clarkkkk commented 1 week ago

Thank you for reporting. I made a fix in 0.3.2 to solve the problem. Can you try it?

theninthsky commented 1 week ago

@Clarkkkk Thanks. It does work now, but only when there is no build folder. Otherwise, it throws the following error:

ERROR in × Error:   × Rspack FS Error: Error: ENOENT: no such file or directory, unlink 'C:\Projects\client-side-rendering\build\swr-service-worker.js'
  │   │
  │   ╰─▶ Error: ENOENT: no such file or directory, unlink 'C:\Projects\client-side-rendering\build\swr-service-worker.js'
  │
  │

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)

Note that I have output.clean set to true in my rspack.config.js file.

Clarkkkk commented 1 week ago

It has some issues when using multiple instances of InjectManifest currently and I'm still investigating. You can set compileSrc: false to avoid this problem temporarily.

theninthsky commented 1 week ago

@Clarkkkk Thanks! I'll use the flag you suggested for the time being.