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

[Bug?]: export type crashes in 'use server' module #1226

Closed
2 tasks done
binajmen opened this issue Jan 6, 2024 · 3 comments
Closed
2 tasks done

[Bug?]: export type crashes in 'use server' module #1226

binajmen opened this issue Jan 6, 2024 · 3 comments
Labels
bug Something isn't working vinxi related to vinxi

Comments

@binajmen
Copy link

binajmen commented Jan 6, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I'm having issues when using use server to enforce modules to be server only.

By following the steps below, you should encounter the following error:

16:51:23 [vite] Error when evaluating SSR module /src/routes/admin/organisations/(list).tsx?pick=route: failed to import "/src/database/organisations.ts"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module /node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vinxi/lib/routes.js: failed to import "/src/routes/admin/organisations/(list).tsx?pick=route"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module /node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/shared/routes.ts: failed to import "/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vinxi/lib/routes.js"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module /node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/server/handler.tsx: failed to import "/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/shared/routes.ts"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module /node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/server/index.tsx: failed to import "/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/server/handler.tsx"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module /src/entry-server.tsx: failed to import "/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@solidjs/start/server/index.tsx"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

16:51:23 [vite] Error when evaluating SSR module #vinxi/handler/ssr: failed to import "/src/entry-server.tsx"
|- Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
    at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
    at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
    at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
    at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29)

[h3] [unhandled] H3Error: undefined does not match field "params": [Pattern] of type FunctionExpression
    at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
    ... 6 lines matching cause stack trace ...
    at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29) {
  cause: Error: undefined does not match field "params": [Pattern] of type FunctionExpression
      at addParam (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
      at eval (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
      at builder.from (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
      at wrapExports (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
      at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
      at TransformContext.transform (/home/projects/solid-start-error/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
      at Object.transform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44404:62)
      at async loadAndTransform (/home/projects/solid-start-error/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55078:29) {
    plugin: 'vite-server-references',
    id: '/home/projects/solid-start-error/src/database/organisations.ts',
    pluginCode: '// uncomment me to see the error\n' +
      ' "use server";\n' +
      '\n' +
      'import { sql, type InferSelectModel } from "drizzle-orm";\n' +
      'import { mysqlTable, timestamp, varchar } from "drizzle-orm/mysql-core";\n' +
      ...
      '// }\n'
  },
  statusCode: 500,
  fatal: false,
  unhandled: true,
  statusMessage: undefined,
  data: undefined
}

The pnpm build step is less verbose:

[vite-server-references] undefined does not match field "params": [Pattern] of type FunctionExpression
file: /home/projects/solid-start-error/src/database/organisations.ts

 ERROR  undefined does not match field "params": [Pattern] of type FunctionExpression                               17:00:32

  at addParam (node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:455:27)
  at eval (node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:505:25)
  at builder.from (node_modules/.pnpm/[email protected]/node_modules/ast-types/lib/types.js:503:46)
  at wrapExports (node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:376:59)
  at Object.transform (node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugins/wrap-exports.js:41:28)
  at Object.transform (node_modules/.pnpm/@[email protected][email protected]/node_modules/@vinxi/plugin-directives/plugin.js:49:34)
  at Object.handler (node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:48396:19)
  at eval (node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:25569:40) 



 ERROR  undefined does not match field "params": [Pattern] of type FunctionExpression                               17:00:32

 ELIFECYCLE  Command failed with exit code 1.

Expected behavior 🤔

No response

Steps to reproduce 🕹

Steps:

  1. Visit https://stackblitz.com/edit/solid-start-error?file=src%2Fdatabase%2Forganisations.ts
  2. Click on the link "Click here" that will bring you to /admin/organisations
  3. Uncomment use server at the top of the file ./src/database/organisations

Context 🔦

No response

Your environment 🌎

No response

@binajmen binajmen added the bug Something isn't working label Jan 6, 2024
@binajmen binajmen changed the title [Bug?]: [Bug?]: Error when evaluating SSR module Jan 6, 2024
@ryansolid
Copy link
Member

Yeah this looks like a babel error. A compiler error on the Vinxi side around server functions. Looks like it is related to exporting the type definition. It must not be handling that properly. When I comment out the export type it works.

@ryansolid ryansolid added the vinxi related to vinxi label Jan 8, 2024
@ryansolid ryansolid changed the title [Bug?]: Error when evaluating SSR module [Bug?]: export type crashes in 'use server' module Jan 10, 2024
@nksaraf
Copy link
Member

nksaraf commented Jan 11, 2024

Will be fixed in next release of vinxi

@nksaraf nksaraf closed this as completed Jan 11, 2024
@eguneys
Copy link

eguneys commented Oct 4, 2024

This isn't fixed, for export enum oh my G O D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vinxi related to vinxi
Projects
None yet
Development

No branches or pull requests

4 participants