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

__workerManifest.assets is missing entry for manifest-{version}.js #240

Open
aschultz opened this issue Jun 18, 2024 · 3 comments
Open

__workerManifest.assets is missing entry for manifest-{version}.js #240

aschultz opened this issue Jun 18, 2024 · 3 comments
Labels
blocked Issues blocked by other tasks or dependencies roadmap Issues planned for future development

Comments

@aschultz
Copy link

aschultz commented Jun 18, 2024

Remix generates a file like assets/manifest-12345.js that contains the list of routes and their dependencies, and links to this from the HTML doc. But RemixPWA isn't including it in the __workerManifest.assets list, which makes it tricky to ensure that file gets cached for offline use.

I think maybe the PWA vite plugin that generates the assets list is running before Remix generates the manifest file?

//package.json
"dependencies": {
    "@remix-pwa/sw": "^3.0.7",
    "@remix-pwa/worker-runtime": "^2.1.2",
    "@remix-run/node": "^2.9.2",
    "@remix-run/react": "^2.9.2",
    "@remix-run/serve": "^2.9.2",
    "isbot": "^5.1.7",
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
},
"devDependencies": {
    "@remix-pwa/dev": "^3.0.5",
    "@remix-run/dev": "^2.9.2",
    "@types/react": "^18.3.3",
    "cross-env": "^7.0.3",
    "vite": "^5.2.12"
}
//vite.config.js
export default defineConfig({
  build: {
    minify: false
  },
  plugins: [
    remix({
        ssr: true,
    }),
    remixPWA()],
});
@ShafSpecs
Copy link
Member

Thanks for bringing this to attention! I would take a look when I am free 👍

@aschultz
Copy link
Author

Any updates on this?

@ShafSpecs ShafSpecs added blocked Issues blocked by other tasks or dependencies roadmap Issues planned for future development labels Oct 30, 2024
@ShafSpecs
Copy link
Member

Yep, thx for bringing it to my attention, this is slated for release alongside v5. I would have to manually include this, but this is a weird issue that it doesn't show up:

const files = await glob(`**/*`, {
ignore: ['**/*.map'],
absolute: false,
unique: true,
caseSensitiveMatch: true,
onlyFiles: true,
cwd: resolve(remixPluginContext.remixConfig.buildDirectory, 'client'),
}).catch(() => []);
const assetsVirtualContents = `export const assets = ${JSON.stringify(
files.map(file => `/${file}`),
null,
2
)};`;
return assetsVirtualContents;

Do note that in dev, Remix PWA uses the public folder as the build folder, so it doesn't bundle anything in build - building it in non-dev mode switches the focus to build/client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Issues blocked by other tasks or dependencies roadmap Issues planned for future development
Projects
None yet
Development

No branches or pull requests

2 participants