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

Top-level await is not available #585

Closed
aheissenberger opened this issue Mar 8, 2024 · 2 comments · Fixed by #590
Closed

Top-level await is not available #585

aheissenberger opened this issue Mar 8, 2024 · 2 comments · Fixed by #590
Assignees

Comments

@aheissenberger
Copy link
Contributor

WAKU Commit (Main): f985f59

Works with pnpm dev but fails in BUILD mode waku build - this file is only imported into a server action and there is no difference if there is an additional 'use server' on top.

pnpm build

> waku-example@0.1.0 build /waku/examples/xx_auth
> waku build

vite v5.1.5 building SSR bundle for production...
src/func.ts (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
src/lib/db-lowdb.ts (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
✓ 71 modules transformed.
x Build failed in 341ms
/waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1651
  let error = new Error(text);
              ^

Error: [vite:esbuild-transpile] Transform failed with 2 errors:
assets/func-!~{005}~.js:571:16: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
assets/func-!~{005}~.js:572:19: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
569|  }
570|  
571|  const dbUsers = await JSONFilePreset("users.json", []);
   |                  ^
572|  const dbSessions = await JSONFilePreset("sessions.json", []);
573|  

Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
570|  
571|  const dbUsers = await JSONFilePreset("users.json", []);
572|  const dbSessions = await JSONFilePreset("sessions.json", []);
   |                     ^
573|  
574|  const adapter = new S(dbSessions, dbUsers);

    at failureErrorWithLog (/waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:1651:15)
    at /waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:849:29
    at responseCallbacks.<computed> (/waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/waku/node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter],
  frame: '\n' +
    '\x1B[33mTop-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)\x1B[39m\n' +
    '569|  }\n' +
    '570|  \n' +
    '571|  const dbUsers = await JSONFilePreset("users.json", []);\n' +
    '   |                  ^\n' +
    '572|  const dbSessions = await JSONFilePreset("sessions.json", []);\n' +
    '573|  \n' +
    '\n' +
    '\x1B[33mTop-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)\x1B[39m\n' +
    '570|  \n' +
    '571|  const dbUsers = await JSONFilePreset("users.json", []);\n' +
    '572|  const dbSessions = await JSONFilePreset("sessions.json", []);\n' +
    '   |                     ^\n' +
    '573|  \n' +
    '574|  const adapter = new S(dbSessions, dbUsers);\n',
  loc: {
    column: 16,
    file: 'assets/func-!~{005}~.js',
    length: 5,
    line: 571,
    lineText: 'const dbUsers = await JSONFilePreset("users.json", []);',
    namespace: '',
    suggestion: ''
  },
  code: 'PLUGIN_ERROR',
  plugin: 'vite:esbuild-transpile',
  hook: 'renderChunk'
}

Node.js v21.7.0
@dai-shi
Copy link
Owner

dai-shi commented Mar 9, 2024

Sounds like a vite config thing?
@Aslemammad can you help?

@Aslemammad
Copy link
Contributor

Sure, I'll check it after the current PRs (you might want to assign me)

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

Successfully merging a pull request may close this issue.

3 participants