Skip to content

Commit ea9799f

Browse files
[2.x] Inertia v1 (#1219)
* Update dependencies * Rename imports * Update progress usage * Update setup arguments * Remove `.value` from `usePage()` * Remove creation of Inertia config on SSR install This is no longer required as Inertia will automatically detect SSR. * Remove `ssr.noExternal` from Vite config This doesn't seem to be required any longer. * Fix SSR build * Pass empty object to `useForm` Co-authored-by: Tim MacDonald <[email protected]>
1 parent 1965e32 commit ea9799f

29 files changed

+53
-68
lines changed

src/Console/InstallCommand.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,14 @@ protected function livewireRouteDefinition()
337337
protected function installInertiaStack()
338338
{
339339
// Install Inertia...
340-
if (! $this->requireComposerPackages('inertiajs/inertia-laravel:^0.6.5', 'tightenco/ziggy:^1.0')) {
340+
if (! $this->requireComposerPackages('inertiajs/inertia-laravel:^0.6.8', 'tightenco/ziggy:^1.0')) {
341341
return false;
342342
}
343343

344344
// Install NPM packages...
345345
$this->updateNodePackages(function ($packages) {
346346
return [
347-
'@inertiajs/inertia' => '^0.11.0',
348-
'@inertiajs/inertia-vue3' => '^0.6.0',
349-
'@inertiajs/progress' => '^0.2.7',
347+
'@inertiajs/vue3' => '^1.0.0',
350348
'@tailwindcss/forms' => '^0.5.2',
351349
'@tailwindcss/typography' => '^0.5.2',
352350
'@vitejs/plugin-vue' => '^4.0.0',
@@ -571,24 +569,15 @@ protected function installInertiaSsrStack()
571569
{
572570
$this->updateNodePackages(function ($packages) {
573571
return [
574-
'@inertiajs/server' => '^0.1.0',
575572
'@vue/server-renderer' => '^3.2.31',
576573
] + $packages;
577574
});
578575

579576
copy(__DIR__.'/../../stubs/inertia/resources/js/ssr.js', resource_path('js/ssr.js'));
580577
$this->replaceInFile("input: 'resources/js/app.js',", "input: 'resources/js/app.js',".PHP_EOL." ssr: 'resources/js/ssr.js',", base_path('vite.config.js'));
581-
$this->replaceInFile('});', ' ssr: {'.PHP_EOL." noExternal: ['@inertiajs/server'],".PHP_EOL.' },'.PHP_EOL.'});', base_path('vite.config.js'));
582-
583-
(new Process([$this->phpBinary(), 'artisan', 'vendor:publish', '--provider=Inertia\ServiceProvider', '--force'], base_path()))
584-
->setTimeout(null)
585-
->run(function ($type, $output) {
586-
$this->output->write($output);
587-
});
588578

589579
copy(__DIR__.'/../../stubs/inertia/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php'));
590580

591-
$this->replaceInFile("'enabled' => false", "'enabled' => true", config_path('inertia.php'));
592581
$this->replaceInFile('vite build', 'vite build && vite build --ssr', base_path('package.json'));
593582
$this->replaceInFile('/node_modules', '/bootstrap/ssr'.PHP_EOL.'/node_modules', base_path('.gitignore'));
594583
}

stubs/inertia/resources/js/Components/AuthenticationCardLogo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { Link } from '@inertiajs/inertia-vue3';
2+
import { Link } from '@inertiajs/vue3';
33
</script>
44

55
<template>

stubs/inertia/resources/js/Components/Banner.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup>
22
import { computed, ref, watch } from 'vue';
3-
import { usePage } from '@inertiajs/inertia-vue3';
3+
import { usePage } from '@inertiajs/vue3';
44
55
const show = ref(true);
6-
const style = computed(() => usePage().props.value.jetstream.flash?.bannerStyle || 'success');
7-
const message = computed(() => usePage().props.value.jetstream.flash?.banner || '');
6+
const style = computed(() => usePage().props.jetstream.flash?.bannerStyle || 'success');
7+
const message = computed(() => usePage().props.jetstream.flash?.banner || '');
88
99
watch(message, async () => {
1010
show.value = true;

stubs/inertia/resources/js/Components/DropdownLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { Link } from '@inertiajs/inertia-vue3';
2+
import { Link } from '@inertiajs/vue3';
33
44
defineProps({
55
href: String,

stubs/inertia/resources/js/Components/NavLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { computed } from 'vue';
3-
import { Link } from '@inertiajs/inertia-vue3';
3+
import { Link } from '@inertiajs/vue3';
44
55
const props = defineProps({
66
href: String,

stubs/inertia/resources/js/Components/ResponsiveNavLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { computed } from 'vue';
3-
import { Link } from '@inertiajs/inertia-vue3';
3+
import { Link } from '@inertiajs/vue3';
44
55
const props = defineProps({
66
active: Boolean,

stubs/inertia/resources/js/Layouts/AppLayout.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup>
22
import { ref } from 'vue';
3-
import { Inertia } from '@inertiajs/inertia';
4-
import { Head, Link } from '@inertiajs/inertia-vue3';
3+
import { Head, Link, router } from '@inertiajs/vue3';
54
import ApplicationMark from '@/Components/ApplicationMark.vue';
65
import Banner from '@/Components/Banner.vue';
76
import Dropdown from '@/Components/Dropdown.vue';
@@ -16,15 +15,15 @@ defineProps({
1615
const showingNavigationDropdown = ref(false);
1716
1817
const switchToTeam = (team) => {
19-
Inertia.put(route('current-team.update'), {
18+
router.put(route('current-team.update'), {
2019
team_id: team.id,
2120
}, {
2221
preserveState: false,
2322
});
2423
};
2524
2625
const logout = () => {
27-
Inertia.post(route('logout'));
26+
router.post(route('logout'));
2827
};
2928
</script>
3029

stubs/inertia/resources/js/Pages/API/Partials/ApiTokenManager.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { ref } from 'vue';
3-
import { useForm } from '@inertiajs/inertia-vue3';
3+
import { useForm } from '@inertiajs/vue3';
44
import ActionMessage from '@/Components/ActionMessage.vue';
55
import ActionSection from '@/Components/ActionSection.vue';
66
import Checkbox from '@/Components/Checkbox.vue';
@@ -30,7 +30,7 @@ const updateApiTokenForm = useForm({
3030
permissions: [],
3131
});
3232
33-
const deleteApiTokenForm = useForm();
33+
const deleteApiTokenForm = useForm({});
3434
3535
const displayingToken = ref(false);
3636
const managingPermissionsFor = ref(null);

stubs/inertia/resources/js/Pages/Auth/ConfirmPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { ref } from 'vue';
3-
import { Head, useForm } from '@inertiajs/inertia-vue3';
3+
import { Head, useForm } from '@inertiajs/vue3';
44
import AuthenticationCard from '@/Components/AuthenticationCard.vue';
55
import AuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
66
import InputError from '@/Components/InputError.vue';

stubs/inertia/resources/js/Pages/Auth/ForgotPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { Head, useForm } from '@inertiajs/inertia-vue3';
2+
import { Head, useForm } from '@inertiajs/vue3';
33
import AuthenticationCard from '@/Components/AuthenticationCard.vue';
44
import AuthenticationCardLogo from '@/Components/AuthenticationCardLogo.vue';
55
import InputError from '@/Components/InputError.vue';

0 commit comments

Comments
 (0)