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

SSR error #662

Open
majweb opened this issue Sep 21, 2024 · 0 comments
Open

SSR error #662

majweb opened this issue Sep 21, 2024 · 0 comments

Comments

@majweb
Copy link

majweb commented Sep 21, 2024

What causes this error after executing the artisan inertia:start-ssr command

import e__default, { useSSRContext, mergeProps, withCtx, renderSlot, computed, watch, onMounted, onUnmounted, createVNode, openBlock, createBlock, useSlots, ref, createTextVNode, unre
f, Fragment, renderList, toDisplayString, createCommentVNode, withModifiers, h as h$2, defineComponent, resolveDirective, withDirectives, vModelSelect, nextTick, createElementBlock, c
reateElementVNode, watchEffect, cloneVNode, inject, provide, shallowRef, getCurrentInstance, Teleport, reactive, normalizeClass, Transition, onBeforeUnmount, withKeys, vShow, vModelTe
xt, isRef, vModelRadio, onBeforeMount, resolveComponent, toRaw, readonly, vModelCheckbox, createSlots, resolveDynamicComponent, toHandlers, normalizeStyle, pushScopeId, popScopeId, no
rmalizeProps, guardReactiveProps, withScopeId, createApp, createSSRApp } from "vue";
^^^^^^^^^^
SyntaxError: The requested module 'vue' does not provide an export named 'default'


ssr.js
import {createInertiaApp} from '@inertiajs/vue3'
import createServer from '@inertiajs/vue3/server'
import {renderToString} from '@vue/server-renderer'
import {createSSRApp, h} from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import toast from "./plugins/toast";
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
import vue3StarRatings from "vue3-star-ratings";
import FloatingVue from "floating-vue";
import VueEasyLightbox from "vue-easy-lightbox";
import {VueClipboard} from "@soerenmartius/vue3-clipboard";

createServer(page =>
    createInertiaApp({
        page,
        render: renderToString,
        title: (title) => `${title} - ${appName}`,

        resolve: name => {
            const pages = import.meta.glob('./Pages/**/*.vue', {eager: true})
            return pages[`./Pages/${name}.vue`]
        },
        setup({App, props, plugin}) {
            let app = createSSRApp({
                render: () => h(App, props),
            });
            app.use(plugin)
                .use(toast)
                .use(FloatingVue)
                .use(VueEasyLightbox)
                .use(VueClipboard)
                .mixin({ components: { vue3StarRatings } })
                .use(ZiggyVue, {
                    ...page.props.ziggy,
                    location: new URL(page.props.ziggy.location),
                });
            return app;

        },
    })
)

vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import DefineOptions from 'unplugin-vue-define-options/vite'
import topLevelAwait from "vite-plugin-top-level-await";
import { nodePolyfills } from "vite-plugin-node-polyfills";
export default defineConfig({
    server: {
        hmr: {
            host: 'localhost',
        },
    },
    resolve: {
        alias: {
            '@': '/resources/js',
            'media-library-pro-vue3-attachment': '/vendor/spatie/laravel-medialibrary-pro/resources/js/media-library-pro-vue3-attachment',
            'media-library-pro-vue3-collection': '/vendor/spatie/laravel-medialibrary-pro/resources/js/media-library-pro-vue3-collection',
        },
    },
    ssr: {
        noExternal: [
            '@vojtechlanka/vue-tags-input',
            'vue3-carousel',
            'vue-signature-pad',
            'lodash',
            '@spatie/media-library-pro-vue3-attachment',
            '@spatie/media-library-pro-vue3-collection',
            'vue-multiselect',
            'axios',
            '@easepick/bundle',
            'vue3-emoji-picker',
            'pdfjs-dist',
            'vue3-star-ratings',
            'vue3-timepicker',
            'vue3-treeselect',
            'vuedraggable',
            'vue-material-design-icons',
            'swiper',
            '@vueuse/core',
            'lucide-vue-next',
            'floating-vue',
            '@heroicons/vue',
            '@fullcalendar/vue3',
            '@headlessui/vue',
            '@heroicons/vue',
            '@soerenmartius/vue3-clipboard',
            '@tinymce/tinymce-vue',
            '@vueuse/core',
            'floating-vue',
            'interactjs',
            'leaflet',
            'moment',
        ]

    },
    plugins: [
        nodePolyfills(),
        topLevelAwait({
            promiseExportName: "__tla",
            promiseImportName: i => `__tla_${i}`
        }),
        DefineOptions(),
        laravel({
            input: 'resources/js/app.js',
            ssr: 'resources/js/ssr.js',
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        })
    ],
    css: {
        preprocessorOptions: {
            scss: {
                silenceDeprecations: ["legacy-js-api"],
            },
        },
    },
});

packages.json
{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build && vite build --ssr"
    },
    "devDependencies": {
        "@inertiajs/vue3": "^1.2.0",
        "@tailwindcss/forms": "^0.5.2",
        "@tailwindcss/typography": "^0.5.2",
        "@vitejs/plugin-vue": "^4.0.0",
        "@vue-macros/volar": "^0.18.11",
        "autoprefixer": "^10.4.7",
        "axios": "^1.1.2",
        "laravel-vite-plugin": "^0.7.2",
        "postcss": "^8.4.14",
        "sass": "^1.77.8",
        "sass-loader": "^16.0.0",
        "tailwindcss": "^3.1.0",
        "unplugin-vue-define-options": "^1.4.2",
        "vite": "^4.0.0",
        "vite-plugin-node-polyfills": "^0.22.0",
        "vue": "^3.2.31"
    },
    "dependencies": {
        "@easepick/bundle": "^1.2.1",
        "@fullcalendar/core": "^6.1.11",
        "@fullcalendar/daygrid": "^6.1.11",
        "@fullcalendar/interaction": "^6.1.11",
        "@fullcalendar/moment-timezone": "^6.1.11",
        "@fullcalendar/timegrid": "^6.1.11",
        "@fullcalendar/vue3": "^6.1.11",
        "@headlessui/vue": "^1.7.19",
        "@heroicons/vue": "^2.0.16",
        "@primevue/themes": "^4.0.0",
        "@soerenmartius/vue3-clipboard": "^0.1.2",
        "@spatie/media-library-pro-styles": "^1.4.0",
        "@spatie/media-library-pro-vue3-attachment": "^1.4.0",
        "@spatie/media-library-pro-vue3-collection": "^1.4.0",
        "@tinymce/tinymce-vue": "^4.0.7",
        "@tiptap/extension-text-align": "^2.3.1",
        "@tiptap/extension-underline": "^2.3.1",
        "@tiptap/pm": "^2.3.1",
        "@tiptap/starter-kit": "^2.3.1",
        "@tiptap/vue-3": "^2.3.1",
        "@vojtechlanka/vue-tags-input": "^3.0.15",
        "@vue/compiler-sfc": "^3.5.7",
        "@vue/server-renderer": "^3.5.6",
        "@vueuse/core": "^10.11.0",
        "autosize": "^6.0.1",
        "floating-vue": "^2.0.0-beta.24",
        "interactjs": "^1.10.27",
        "laravel-echo": "^1.16.1",
        "leaflet": "^1.9.4",
        "lodash": "^4.17.21",
        "lucide-vue-next": "^0.427.0",
        "meilisearch": "^0.34.2",
        "moment": "^2.30.1",
        "moment-interval": "^0.2.1",
        "pdfjs-dist": "^4.2.67",
        "pluralize": "^8.0.0",
        "primeicons": "^7.0.0",
        "primevue": "^4.0.0",
        "pusher-js": "^8.4.0-rc2",
        "swiper": "^11.1.5",
        "vite-plugin-top-level-await": "^1.4.1",
        "vue-confetti-explosion": "^1.0.2",
        "vue-easy-lightbox": "^1.16.0",
        "vue-material-design-icons": "^5.3.0",
        "vue-multiselect": "^3.0.0-beta.2",
        "vue-recaptcha-v3": "^2.0.1",
        "vue-signature-pad": "^3.0.2",
        "vue3-carousel": "^0.3.3",
        "vue3-emoji-picker": "^1.1.8",
        "vue3-star-ratings": "^3.0.5",
        "vue3-timepicker": "^1.0.0-beta.2",
        "vue3-treeselect": "^0.1.10",
        "vuedraggable": "^4.1.0"
    }
}

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

1 participant