fusionjs / fusion-cli

Migrated to https://github.com/fusionjs/fusionjs
MIT License
140 stars 37 forks source link

When using a Service Worker I get "Module not found: Error: Can't resolve 'fs'" #765

Closed mcasebeer closed 5 years ago

mcasebeer commented 5 years ago

I'm currently attempting to add a service worker that does a bit more then just caching and doesn't some decompression on the worker. The decompression I'm running I have already tested and have it working outside of the service worker (just inside a fetch) without a problem. This decompression is done by the draco3D library (https://github.com/google/draco). When I attempt to load this library into my service worker I get the following error:

Module not found: Error: Can't resolve 'fs' in '/node_modules/draco3d'

Steps to reproduce

  1. create a service worker (sw.js) and configure it follow fusionjs documents
  2. add draco3d to the project
  3. update src/sw.js to import draco import draco3d from 'draco3d';
  4. attempt to run the project.
angus-c commented 5 years ago

Hi @mcasebeer, this is because sw.js runs on the client (as all service workers do)