Skip to content

Uncaught SyntaxError: Unexpected token 'export' (at entry.worker.js:5666:1) #239

@kayluhb

Description

@kayluhb

Hello!

I'm trying to implement remix-pwa and I'm having an issue with the browser loading the entry.worker.js

Uncaught SyntaxError: Unexpected token 'export' (at entry.worker.js:5666:1)
(index):39 Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('http://localhost:3000/') with script ('http://localhost:3000/entry.worker.js'): ServiceWorker script evaluation failed

versions:

"@remix-pwa/dev": "^3.0.5",
"@remix-pwa/worker-runtime": "^2.1.2",
"@remix-run/react": "^2.8.0",
"@remix-run/server-runtime": "^2.8.0",

my vite config looks like this

import {defineConfig} from 'vite';
import {hydrogen} from '@shopify/hydrogen/vite';
import {oxygen} from '@shopify/mini-oxygen/vite';
import {remixPWA} from '@remix-pwa/dev';
import {vitePlugin as remix} from '@remix-run/dev';
import commonjs from 'vite-plugin-commonjs';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  plugins: [
    hydrogen(),
    oxygen(),
    commonjs({
      filter(id: string) {
        // `node_modules` is exclude by default, so we need to include it explicitly
        // https://github.com/vite-plugin/vite-plugin-commonjs/blob/v0.10.1/src/index.ts#L143
        if (
          id.includes('node_modules/@sanity/image-url') ||
          id.includes('node_modules/lodash.debounce')
        ) {
          return true;
        }
      },
    }),
    remix({
      presets: [hydrogen.preset()],
      ignoredRouteFiles: ['**/.*', '**/*.test.*', '**/styleguide.tsx'],
      future: {
        v3_fetcherPersist: false,
        v3_relativeSplatPath: false,
        v3_throwAbortReason: false,
      },
    }),
    tsconfigPaths(),
    remixPWA(),
  ],
  optimizeDeps: {
    include: ['clsx', 'lodash.debounce', '@sanity/image-url'],
  },
});

Any ideas on what might be wrong w/ my config?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions