Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD: [vite-plugin-remix-pwa:virtual-entry-sw] Could not load virtual:entry-sw #147

Open
Magzter opened this issue May 1, 2024 · 8 comments

Comments

@Magzter
Copy link

Magzter commented May 1, 2024

Hey guys, running a relatively new remix project and have been struggling with this error for the last few days.

This is after following the basic instructions at: https://remix-pwa.run/docs/main/quick-start

It seems to fail to build the worker file but I haven't been able to make sense of this error, I've tried multiple machines (ubuntu/Mac) and node versions (node 18/20) but it consistently produces this.

I've tried following the runtimes guideline to do my own runtime instead but produces the same error.

Screenshot 2024-05-01 at 5 05 36 PM

Package.json

  "name": "my-remix-app",
  "private": true,
  "sideEffects": false,
  "type": "module",
  "scripts": {
    "build": "remix vite:build",
    "dev": "sst bind remix vite:dev",
    "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
    "start": "remix-serve ./build/server/index.js",
    "typecheck": "tsc"
  },
  "dependencies": {
    "@nextui-org/autocomplete": "^2.0.16",
    "@nextui-org/dropdown": "^2.1.18",
    "@nextui-org/react": "^2.3.1",
    "@nextui-org/use-infinite-scroll": "^2.1.3",
    "@react-stately/data": "^3.11.2",
    "@remix-pwa/sw": "^3.0.3",
    "@remix-pwa/worker-runtime": "^2.1.1",
    "@remix-run/node": "^2.9.0",
    "@remix-run/react": "^2.9.0",
    "@remix-run/serve": "^2.9.0",
    "framer-motion": "^11.1.1",
    "i": "^0.3.7",
    "isbot": "^4.1.0",
    "lodash": "^4.17.21",
    "lodash.debounce": "^4.0.8",
    "next-themes": "^0.3.0",
    "npm": "^10.5.2",
    "react": "^18.3.0-canary-593ecee66-20231114",
    "react-animated-numbers": "^0.18.0",
    "react-dom": "^18.3.0-canary-593ecee66-20231114",
    "remix-auth": "^3.6.0",
    "remix-auth-form": "^1.4.0",
    "remix-auth-google": "^2.0.0"
  },
  "devDependencies": {
    "@remix-pwa/dev": "^3.0.5",
    "@remix-run/dev": "^2.8.1",
    "@types/react": "^18.2.20",
    "@types/react-dom": "^18.2.7",
    "@typescript-eslint/eslint-plugin": "^6.7.4",
    "@typescript-eslint/parser": "^6.7.4",
    "autoprefixer": "^10.4.19",
    "eslint": "^8.38.0",
    "eslint-import-resolver-typescript": "^3.6.1",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "postcss": "^8.4.38",
    "tailwindcss": "^3.4.3",
    "typescript": "^5.1.6",
    "vite": "^5.1.0",
    "vite-tsconfig-paths": "^4.2.1"
  },
  "overrides": {
    "react": "^18.3.0-canary-593ecee66-20231114",
    "react-dom": "^18.3.0-canary-593ecee66-20231114"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}
@ShafSpecs
Copy link
Member

Hello @Magzter, does this occur on build? I think I've spotted the error, remix pwa is attempting to build before remix has finished building. Is your remix pwa plugin after remix plugin in your Vite config?

@Magzter
Copy link
Author

Magzter commented May 1, 2024

@Hey @ShafSpecs , it is after, below is a copy of the vite configuration. The error does occur on build.

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths"
import { remixPWA } from '@remix-pwa/dev'

installGlobals();

export default defineConfig({
  plugins: [
    remix(
      // { ssr: false }
    ),
    remixPWA({
      //workerMinify: true,
      //workerEntryPoint: './runtime.js'
    }),
    tsconfigPaths()
  ],
});

@ShafSpecs
Copy link
Member

Hey @ShafSpecs , it is after, below is a copy of the vite configuration.

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths"
import { remixPWA } from '@remix-pwa/dev'

installGlobals();

export default defineConfig({
  plugins: [
    remix(
      // { ssr: false }
    ),
    remixPWA({
      //workerMinify: true,
      //workerEntryPoint: './runtime.js'
    }),
    tsconfigPaths()
  ],
});

The error only throws on build, right? I would have to check that out. Seems like a bug, do you have a reproduction?

@Magzter
Copy link
Author

Magzter commented May 1, 2024

On both dev and prod builds, I've got around it at the moment by manually putting an entry.worker.js file in public to continue playing with other PWA features.

I've just jumped into bed but will work on getting you an easily cloned reproduced project tomorrow.

@Magzter
Copy link
Author

Magzter commented May 2, 2024

@ShafSpecs I managed to figure it out as I was deleting stuff in the reproduce project but it looks like it fails at some sort of duplicate import lint/vite rule? However my normal Vite build doesn't throw any errors with the pwa plugin removed.

https://github.com/Magzter/remix-pwa-build-bug

If you uncomment one of the imports at my-remix-app/app/routes/_index.tsx:7 and run build you will reproduce the error.

Maybe whatever vite build error happens needs to be passed through to the CLI?

@ShafSpecs
Copy link
Member

@ShafSpecs I managed to figure it out as I was deleting stuff in the reproduce project but it looks like it fails at some sort of duplicate import lint/vite rule? However my normal Vite build doesn't throw any errors with the pwa plugin removed.

https://github.com/Magzter/remix-pwa-build-bug

If you uncomment one of the imports at my-remix-app/app/routes/_index.tsx:7 and run build you will reproduce the error.

Maybe whatever vite build error happens needs to be passed through to the CLI?

Thanks, it's 2am here so won't be able to check it out for a few hours 😄.

@ShafSpecs
Copy link
Member

Looking at the file, you seem to have imported them before. If I uncomment, you would end up importing twice

@Magzter
Copy link
Author

Magzter commented May 2, 2024

Looking at the file, you seem to have imported them before. If I uncomment, you would end up importing twice

Yes but it doesn't throw an error on my build with the PWA plugin removed and the error thrown by PWA plugin is not clear as to what the build error is. I don't mind the error as it's given me a chance to clean it up but I wouldn't have found it had I not created a new project and removed stuff xD

You can see that by uncommenting the double import and commenting out the pwa plugin then running build. I haven't done anything to configure build rules just using remix out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants