fix infinite bundle size bug

This commit is contained in:
CoolElectronics 2023-08-14 14:20:40 -04:00
parent 3539de7c18
commit 6c6ace4336
No known key found for this signature in database
GPG key ID: F63593D168636C50
5 changed files with 475 additions and 1014 deletions

3
frontend/filemap.js Normal file
View file

@ -0,0 +1,3 @@
import index from "sw-filemap"
self.filemap = JSON.parse(index);

View file

@ -0,0 +1 @@
// file intentionally left empty

View file

@ -6,10 +6,8 @@
* However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally. * However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally.
*/ */
// import index from "sw-filemap" self.filemap = {};
importScripts("filemap.js");
// let filemap = JSON.parse(index);
let filemap = {};
importScripts('uv/uv.bundle.js'); importScripts('uv/uv.bundle.js');
importScripts('uv.config.js'); importScripts('uv.config.js');

View file

@ -19,8 +19,8 @@ const transform = options => {
return { return {
name: 'esbuild-sw-transformer', name: 'esbuild-sw-transformer',
setup(build) { setup(build) {
if (_fs.existsSync("./sw.js")) if (_fs.existsSync("./filemap.js"))
fs.rm("./sw.js"); fs.rm("./filemap.js");
build.onResolve({ filter }, args => { build.onResolve({ filter }, args => {
const realPath = args.path.replace(filter, ''); const realPath = args.path.replace(filter, '');
return { return {
@ -68,9 +68,9 @@ const transform = options => {
}; };
build({ build({
entryPoints: ['../public/sw.js'], entryPoints: ['../filemap.js'],
bundle: true, bundle: true,
outfile: 'sw.js', outfile: 'filemap.js',
plugins: [ plugins: [
// Always include this plugin before others // Always include this plugin before others
transform() transform()

1471
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff