Code Monkey home page Code Monkey logo

Comments (7)

userquin avatar userquin commented on August 15, 2024 1

@ShafSpecs I had similar problem, check vite-pwa/vite-plugin-pwa#629

from monorepo.

userquin avatar userquin commented on August 15, 2024 1

Rename the js file to mjs (change the rollup input to the mjs file) before Vite build call, then rename it back to the original (don't forget to change also sourcemap file and reference in the js file): the problem is about using esbuild in Vite minify option (the default): check Vite issue vitejs/vite#15379 (comment)

You can try switching Vite minify option to terser (will require adding the dependency).

from monorepo.

ShafSpecs avatar ShafSpecs commented on August 15, 2024

What does your entry worker look like?

from monorepo.

ShafSpecs avatar ShafSpecs commented on August 15, 2024

The built service worker is meant to be a standalone js file, meaning no exports. But somehow, your entry.worker file gets built with export still present

from monorepo.

kayluhb avatar kayluhb commented on August 15, 2024

The entry worker looks like this

https://gist.github.com/kayluhb/d2e1d0cac8b99d53af45339aa52972e2

from monorepo.

ShafSpecs avatar ShafSpecs commented on August 15, 2024

Thanks! Would try and replicate it here as well 👍

from monorepo.

ShafSpecs avatar ShafSpecs commented on August 15, 2024

@ShafSpecs I had similar problem, check vite-pwa/vite-plugin-pwa#629

@userquin Would building into mjs format, then simply renaming to js fix the export issue though? Or do I transform whilst renaming? Looking at his built worker, it's built in a completely different format for some reason:

var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var require_entry_worker = __commonJS({
  // ...
});
export default require_entry_worker();

Instead of as a script

from monorepo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.