Surreal
Surreal
NNuxt
Created by Surreal on 2/6/2025 in #❓・help
Rollup error when using server components
I'm guessing it's possible to hack together a dummy polyfill for the Node.js dependencies in postgres, but what I'm confused by is why does Rollup even try to bundle server-only code imports into the client-side/browser bundle?
7 replies
NNuxt
Created by Surreal on 2/6/2025 in #❓・help
Rollup error when using server components
The specific error I get is:
[nuxi 1:12:15 PM] ERROR Nuxt Build Error: node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js (5:9): "performance" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js".

file: node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js:5:9

3: import crypto from 'crypto'
4: import Stream from 'stream'
5: import { performance } from 'perf_hooks'
^
6:
7: import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'

at getRollupError (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:397:41)
at error (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:393:42)
at Module.error (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:16607:16)
at Module.traceVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:17055:29)
at ModuleScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:14718:39)
at FunctionScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionBodyScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionBodyScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at MemberExpression.bind (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7282:49)
[nuxi 1:12:15 PM] ERROR Nuxt Build Error: node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js (5:9): "performance" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js".

file: node_modules/.pnpm/[email protected]/node_modules/postgres/src/connection.js:5:9

3: import crypto from 'crypto'
4: import Stream from 'stream'
5: import { performance } from 'perf_hooks'
^
6:
7: import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'

at getRollupError (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:397:41)
at error (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:393:42)
at Module.error (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:16607:16)
at Module.traceVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:17055:29)
at ModuleScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:14718:39)
at FunctionScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionBodyScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at FunctionBodyScope.findVariable (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5579:38)
at MemberExpression.bind (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:7282:49)
7 replies
NNuxt
Created by Surreal on 7/24/2024 in #❓・help
How to access buildId/build hash at runtime?
Oh interesting! Hadn't seen that hook before, will have to take a look - thanks!
3 replies
NNuxt
Created by Surreal on 5/22/2024 in #❓・help
How to get cookie value in SSR page?
Ah, nevermind. I realized that I had modified the nuxt config to make some pages not use SSR, some pages use SWR, etc., and that seems to be tied to the cause
6 replies
NNuxt
Created by Surreal on 5/22/2024 in #❓・help
How to get cookie value in SSR page?
P.S. I'm also not getting a "A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function." error, I'm getting a hydration mismatch between a server-side rendered undefined value, and a client-side rendered value from the cookie
6 replies
NNuxt
Created by Surreal on 5/22/2024 in #❓・help
How to get cookie value in SSR page?
e.g.,
<template>
<div>{{foobar}}</div>
</template>
<script lang="ts" setup>
const foobar = useCookie('foobar');
</script>
<template>
<div>{{foobar}}</div>
</template>
<script lang="ts" setup>
const foobar = useCookie('foobar');
</script>
also returns undefined in the SSR HTML, even when the cookie is defined
6 replies
NNuxt
Created by Surreal on 5/22/2024 in #❓・help
How to get cookie value in SSR page?
I use the Composition API exclusively (e.g., <script lang="ts" setup>...</script>) - shouldn't useCookie() have access to the Nuxt context in that scope?
6 replies