vite-ssg icon indicating copy to clipboard operation
vite-ssg copied to clipboard

createApp is not a function

Open ranjanngc opened this issue 2 years ago • 3 comments

D:\Assemble\src\core-vue-app\src\vue-frontend-app\node_modules\vite-ssg\dist\chunks\build.cjs:173 const { routes } = await createApp(false); ^

TypeError: createApp is not a function at Object.build (D:\Assemble\src\core-vue-app\src\vue-frontend-app\node_modules\vite-ssg\dist\chunks\build.cjs:173:28)
at async Object.handler (D:\Assemble\src\core-vue-app\src\vue-frontend-app\node_modules\vite-ssg\dist\node\cli.cjs:25:3)
PS D:\Assemble\src\core-vue-app\src\vue-frontend-app>

ranjanngc avatar Apr 25 '22 06:04 ranjanngc

I had the same problem. Change:

const createApp = ViteSSG(/* Your config */);
export default createApp;

to:

export const createApp = ViteSSG(/* Your config */);

untlsn avatar Apr 29 '22 10:04 untlsn

I have this issue but I was already exporting createApp as a named variable in main.ts.

yankeeinlondon avatar Oct 06 '22 23:10 yankeeinlondon

I believe the right solution is to include the following in your vite.config.ts:

  ssr: {
    // TODO: workaround until they support native ESM
    noExternal: ['workbox-window', /vue-i18n/],
  },

yankeeinlondon avatar Oct 07 '22 01:10 yankeeinlondon

Please check your first of type module script, vite-ssg will use it as an entry.

https://github.com/antfu/vite-ssg/blob/7ef969c0e8e96e0dd4915f8c9aacb006a94e7a9d/src/node/build.ts#L237-L248

Leon2xiaowu avatar Mar 28 '24 09:03 Leon2xiaowu

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info. Please provide a minimal reproduction to reopen the issue. Thanks.

Why reproduction is required

antfu avatar Mar 28 '24 09:03 antfu