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

vite ssr import 2 is not a function #77

Open
tomdavidson opened this issue Feb 22, 2023 · 1 comment
Open

vite ssr import 2 is not a function #77

tomdavidson opened this issue Feb 22, 2023 · 1 comment

Comments

@tomdavidson
Copy link

No error on build but when I make a request with the dev server, I get __vite_ssr_import_2__ is not a function in the console and the web browser never receives a response. Any ideas?

Basic app:

export const dispatcherApp = (req, res) => {
  const app = express();

  app.get("/", (req, res) => {
    res.send("change me to see updates, cloud functions!!");
  });

  app(req, res);
};

Config:

export default defineConfig({
  server: {
    port: 3000,
  },
  build: { ssr: false },
  plugins: [
    ...VitePluginNode({
      adapter: "express",
      appPath: "./src/index.ts",
      exportName: "dispatcherApp",
      tsCompiler: "swc",
    }),
  ],
});
@JohnGurin
Copy link

I solved this by changing imports from import * as express from 'express' to import express from 'express'.

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

No branches or pull requests

2 participants