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

4.921 TypeError: [vite-plugin-remix-pwa:virtual-entry-sw] Could not load virtual:entry-sw (imported by node_modules/@remix-pwa/worker-runtime/dist/src/service-worker.internal.js): traverse is not a function. (In 'traverse(ast, { #18419

Open
phpmac opened this issue Mar 23, 2025 · 0 comments
Labels
bug Something isn't working docker An issue that occurs when running in Docker node.js Compatibility with Node.js APIs

Comments

@phpmac
Copy link

phpmac commented Mar 23, 2025

What version of Bun is running?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

Compose now can delegate build to bake for better performances
Just set COMPOSE_BAKE=true
[+] Building 86.1s (11/13)                                                    docker:desktop-linux
 => [mp internal] load build definition from Dockerfile                                       0.0s
 => => transferring dockerfile: 356B                                                          0.0s
 => [mp internal] load metadata for docker.io/oven/bun:latest                                 1.0s
 => [mp internal] load .dockerignore                                                          0.0s
 => => transferring context: 160B                                                             0.0s
 => [mp 1/9] FROM docker.io/oven/bun:latest@sha256:0805b993b27de973af29184dafcde64622e0aeeb9  0.0s
 => [mp internal] load build context                                                          0.1s
 => => transferring context: 306.72kB                                                         0.1s
 => CACHED [mp 2/9] RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime               0.0s
 => CACHED [mp 3/9] WORKDIR /app                                                              0.0s
 => [mp 4/9] COPY . .                                                                         0.2s
 => [mp 5/9] RUN bun i                                                                       76.4s
 => [mp 6/9] RUN bun install pm2 tsx                                                          3.3s
 => ERROR [mp 7/9] RUN bun run build                                                          5.1s
------
 > [mp 7/9] RUN bun run build:
0.190 $ remix vite:build
1.679 vite v5.4.14 building for production...
1.784 transforming...
4.578 ✓ 484 modules transformed.
4.598 Generated an empty chunk: "api.trading-plans._id.stop".
4.668 Generated an empty chunk: "api.trading-plans".
4.668 Generated an empty chunk: "protected-route".
4.668 Generated an empty chunk: "api.feedback".
4.668 Generated an empty chunk: "api.hello".
4.668 Generated an empty chunk: "api.sse2".
4.668 Generated an empty chunk: "api.sse".
4.668 Generated an empty chunk: "api.env".
4.668 Generated an empty chunk: "api.ai".
4.668 Generated an empty chunk: "api.ip".
4.732 rendering chunks...
4.854 computing gzip size...
4.870 build/client/.vite/manifest.json                              9.82 kB │ gzip:   1.13 kB
4.870 build/client/assets/root-D16bQLOm.css                        33.00 kB │ gzip:   6.08 kB
4.870 build/client/assets/api.trading-plans._id.stop-l0sNRNKZ.js    0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.trading-plans-l0sNRNKZ.js             0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/protected-route-l0sNRNKZ.js               0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.feedback-l0sNRNKZ.js                  0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.hello-l0sNRNKZ.js                     0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.sse2-l0sNRNKZ.js                      0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.sse-l0sNRNKZ.js                       0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.env-l0sNRNKZ.js                       0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.ai-l0sNRNKZ.js                        0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/api.ip-l0sNRNKZ.js                        0.00 kB │ gzip:   0.02 kB
4.870 build/client/assets/a-Bf1vAIWS.js                             0.33 kB │ gzip:   0.25 kB
4.870 build/client/assets/b-CZtLeKrA.js                             0.92 kB │ gzip:   0.49 kB
4.870 build/client/assets/terms-Dpv8uB_3.js                         1.38 kB │ gzip:   0.91 kB
4.870 build/client/assets/Auth-tqX-2M2z.js                          1.54 kB │ gzip:   0.79 kB
4.870 build/client/assets/Pagination-De669KWu.js                    1.56 kB │ gzip:   0.69 kB
4.870 build/client/assets/_-btXtZj-b.js                             2.17 kB │ gzip:   1.09 kB
4.870 build/client/assets/root-BLPv668J.js                          2.59 kB │ gzip:   1.43 kB
4.870 build/client/assets/forgot-password-BxhBLMzl.js               3.16 kB │ gzip:   1.65 kB
4.870 build/client/assets/entry.client-DCadYpX6.js                  3.89 kB │ gzip:   1.50 kB
4.870 build/client/assets/register-Cwpi-TgO.js                      4.20 kB │ gzip:   1.65 kB
4.870 build/client/assets/todo2-BR_YHE6T.js                         4.30 kB │ gzip:   1.64 kB
4.870 build/client/assets/todo-BR_YHE6T.js                          4.30 kB │ gzip:   1.64 kB
4.870 build/client/assets/news-B9LvBdJZ.js                          4.70 kB │ gzip:   2.08 kB
4.870 build/client/assets/post._-s9so76su.js                        5.11 kB │ gzip:   1.90 kB
4.870 build/client/assets/Default-CYmN0giE.js                       5.64 kB │ gzip:   1.80 kB
4.870 build/client/assets/login-Dg9h2z6H.js                         5.89 kB │ gzip:   2.57 kB
4.870 build/client/assets/_index-Vv2lAE9R.js                        6.00 kB │ gzip:   2.28 kB
4.870 build/client/assets/jsx-runtime-Db593e1Q.js                   8.23 kB │ gzip:   3.09 kB
4.870 build/client/assets/dayjs-BbgrKl-j.js                         9.43 kB │ gzip:   4.26 kB
4.870 build/client/assets/ImproveAnalysisModal-BCS38QJN.js          9.56 kB │ gzip:   2.61 kB
4.870 build/client/assets/ai-BAsCKmTi.js                           10.56 kB │ gzip:   4.00 kB
4.870 build/client/assets/demo-CLjRTyM4.js                         11.08 kB │ gzip:   3.23 kB
4.870 build/client/assets/store-TUUdJaBe.js                        17.09 kB │ gzip:   5.32 kB
4.870 build/client/assets/plans-DW0WA2zg.js                        18.97 kB │ gzip:   4.31 kB
4.870 build/client/assets/my-COO4-Ukv.js                           38.13 kB │ gzip:   9.81 kB
4.870 build/client/assets/components-B2JD_Bx5.js                  248.40 kB │ gzip:  80.23 kB
4.870 build/client/assets/index-DlUQvdjS.js                       337.24 kB │ gzip: 106.66 kB
4.871 ✓ built in 3.14s
4.899 vite v5.4.14 building SSR bundle for production...
4.901 🏗️  Building Service Worker in production mode...
4.921 x Build failed in 19ms
4.921 Error during worker build: 4 |         hasLoader: false,
4.921 5 |         hasAction: false,
4.921 6 |         hasWorkerLoader: false,
4.921 7 |         hasWorkerAction: false,
4.921 8 |     };
4.921 9 |     traverse(ast, {
4.921        ^
4.921 TypeError: [vite-plugin-remix-pwa:virtual-entry-sw] Could not load virtual:entry-sw (imported by node_modules/@remix-pwa/worker-runtime/dist/src/service-worker.internal.js): traverse is not a function. (In 'traverse(ast, {
4.921     FunctionDeclaration(path) {
4.921       const functionName = path.node.id?.name;
4.921       if (functionName === "loader")
4.921         routeModules.hasLoader = !0;
4.921       if (functionName === "action")
4.921         routeModules.hasAction = !0;
4.921       if (functionName === "workerLoader")
4.921         routeModules.hasWorkerLoader = !0;
4.921       if (functionName === "workerAction")
4.921         routeModules.hasWorkerAction = !0;
4.921     },
4.921     ArrowFunctionExpression(path) {
4.921       if (t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)) {
4.921         const functionName = path.parent.id.name;
4.921         if (functionName === "loader")
4.921           routeModules.hasLoader = !0;
4.921         if (functionName === "action")
4.921           routeModules.hasAction = !0;
4.921         if (functionName === "workerLoader")
4.921           routeModules.hasWorkerLoader = !0;
4.921         if (functionName === "workerAction")
4.921           routeModules.hasWorkerAction = !0;
4.921       }
4.921     }
4.921   })', 'traverse' is undefined)
4.921      plugin: "vite-plugin-remix-pwa:virtual-entry-sw",
4.921        hook: "load",
4.921  watchFiles: [ "/app/node_modules/@remix-pwa/worker-runtime/dist/src/service-worker.internal.js" ],
4.921        code: "PLUGIN_ERROR"
4.921
4.921       at resolveRouteModules (/app/node_modules/@remix-pwa/dev/dist/src/resolve-route-modules.js:9:4)
4.921
4.922 ✓ 0 modules transformed.
4.922 x Build failed in 23ms
4.923 2 | import { readFileSync } from 'fs';
4.923 3 | import { join } from 'pathe';
4.923 4 | export const getWorkerHash = ({ workerBuildDirectory, workerName }) => {
4.923 5 |     const hash = createHash('md5');
4.923 6 |     const workerPath = join(workerBuildDirectory, `${workerName}.js`);
4.923 7 |     hash.update(readFileSync(workerPath, { encoding: 'utf-8' }));
4.923     ^
4.923 error: [vite-plugin-remix-pwa:bundler] ENOENT: no such file or directory, open '/app/build/client/entry.worker.js'
4.923        path: "/app/build/client/entry.worker.js",
4.923     syscall: "open",
4.923       errno: -2,
4.923  pluginCode: "ENOENT",
4.923      plugin: "vite-plugin-remix-pwa:bundler",
4.923        hook: "buildStart",
4.923        code: "PLUGIN_ERROR"
4.923
4.923       at readFileSync (native:1:1)
4.923       at getWorkerHash (/app/node_modules/@remix-pwa/dev/dist/src/hash.js:7:16)
4.923
4.953 error: script "build" exited with code 1
------
failed to solve: process "/bin/sh -c bun run build" did not complete successfully: exit code: 1

dockerfile is

FROM oven/bun AS base

# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

WORKDIR /app

COPY . .

RUN bun i
RUN bun install pm2 tsx

# 构建
RUN bun run build

# pwa
RUN bunx remix-pwa sw

RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

vite.config.ts is

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

declare module "@remix-run/node" {
  interface Future {
    v3_singleFetch: true;
  }
}

export default defineConfig({
  plugins: [
    remix({
      future: {
        v3_fetcherPersist: true,
        v3_relativeSplatPath: true,
        v3_throwAbortReason: true,
        v3_singleFetch: true,
        v3_lazyRouteDiscovery: true,
      },
    }),
    remixPWA(),
    tsconfigPaths(),
  ],
  server: {
    hmr: {
      timeout: 1000,
    },
  },
  optimizeDeps: {
    include: ['react-markdown', 'remark-gfm', 'rehype-raw']
  }
});

it's simple remix.run app

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@phpmac phpmac added bug Something isn't working needs triage labels Mar 23, 2025
@RiskyMH RiskyMH added docker An issue that occurs when running in Docker node.js Compatibility with Node.js APIs and removed needs triage labels Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docker An issue that occurs when running in Docker node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

2 participants