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

createServer is not a function #10

Open
MtDalPizzol opened this issue Jul 31, 2022 · 5 comments
Open

createServer is not a function #10

MtDalPizzol opened this issue Jul 31, 2022 · 5 comments

Comments

@MtDalPizzol
Copy link

I believe there's a bug related to Node ESM in some scenarios when trying to lift the SSR server that causes the createServer function to be undefined.

How to reproduce:

Run vite build && vite build --ssr
Run node bootstrap/ssr/ssr.mjs

Node version: 18.4.0
Package version: 0.1.0

How to workaround

import createServer from '@inertiajs/server';

createServer.default((page) => // Adding .default here solved the problem for me, but it shouldn't be necessary
@Xor767
Copy link

Xor767 commented Aug 1, 2022

Same here, when I run a Laravel Vite build

@timacdonald
Copy link

FYI: In the Laravel Jetstream, we solve this by not externalising the server.

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        laravel({
            // ...
        }),
        // ...
    ],
    ssr: {
        noExternal: ['@inertiajs/server'],
    },
});

@RomkaLTU
Copy link

Where to put this option?

@timacdonald
Copy link

In the Vite configuration.

@noBloodOnTheLeaves
Copy link

noBloodOnTheLeaves commented Nov 16, 2022

in my case, i used ssr.jsx in input of laravel function call (-_-')\

plugins: [
        laravel({
            input: 'resources/js/ssr.jsx', // -> need  input: 'resources/js/app.jsx'
            ssr: 'resources/js/ssr.jsx',
            refresh: true,
        }),
        react(),
    ],
    server: {
        hmr: {
            host: 'localhost',
        },
    },
    ssr: {
        noExternal: ['@inertiajs/server'],
    },

You can check some configuration in Jetstream, like i did after read @timacdonald comment

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

5 participants