Git Product home page Git Product logo

Comments (11)

jitterbux avatar jitterbux commented on May 26, 2024 3

Were you able to make your Adonis project work with Inertia 1.0 and especially SSR? Could you please share such project on Github. Perhaps I and others could study and compare the code file by file (or use it as a starter project after cloning) and it will be even better for you not to explain all the things over and over. Because I can't find a working example of Adonis and Inertia 1.0 with SSR. It would be cool if you could create some repo with the basic working example of Adonis and Inertia with SSR, preferably using Vue ;) Just something very basic, one route and one page. Thank you a lot in advance.

from inertiajs-adonisjs.

mastermunj avatar mastermunj commented on May 26, 2024 1

@jitterbux Please try updating webpack.ssr.config.js as follows:

const nodeExternals = require('webpack-node-externals');

Then replace

config.externals = [require('webpack-node-externals')()]

with

config.externals = [
  nodeExternals({
    allowlist: ['@inertiajs/core', '@inertiajs/vue3'],
  }),
];

This solved the problem for me.

from inertiajs-adonisjs.

ammezie avatar ammezie commented on May 26, 2024 1

Oh! Makes sense.

from inertiajs-adonisjs.

eidellev avatar eidellev commented on May 26, 2024

Hey @jitterbux
Thanks for the feedback. Can you please elaborate on what stopped working for you?
A sample project would be best, but a stack trace is also good.

Keep 2 things in mind though:

  1. Version 8 is designed to work with inertia V1 and there had been some breaking changes on both ends.
  2. Since V1 all inertia packages use ESM instead of CJS (import X from 'Y' vs const X = require('Y')) . You will need to adjust your webpack/encore/vite config accordingly.

from inertiajs-adonisjs.

jitterbux avatar jitterbux commented on May 26, 2024

Yeah, I am stuck at this error message: Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules so I am not sure how to fix it. It points to this line: module.exports = require("@inertiajs/vue3"); in ssr.js. So, I need to change it to import { } from "@inertiajs/vue3"; ? Sorry, I am bad with JavaScript.

from inertiajs-adonisjs.

Quent1Pr avatar Quent1Pr commented on May 26, 2024

Thank you @mastermunj I had the same issue but after that I have this error "Cannot use import statement outside a module" (with react)

@eidellev I agree with @jitterbux It's hard to find a working example with ssr ! I saw @RomainLanz trying it on Youtube.

from inertiajs-adonisjs.

RomainLanz avatar RomainLanz commented on May 26, 2024

I have made it work with Vue and React. I will check if I can improve the readme, but I don't recall having any issues with this package.

The only thing to consider is that you should not use Inertia 1.0 yet.

from inertiajs-adonisjs.

ammezie avatar ammezie commented on May 26, 2024

@RomainLanz curious as to why Inertia 1.0 shouldn't be used yet? I thought it's a stable release.

from inertiajs-adonisjs.

RomainLanz avatar RomainLanz commented on May 26, 2024

Because this package has not been updated for it yet. No issue with Inertia 1.0 directly 😄

from inertiajs-adonisjs.

brlebtag avatar brlebtag commented on May 26, 2024

I have made it work with Vue and React. I will check if I can improve the readme, but I don't recall having any issues with this package.

The only thing to consider is that you should not use Inertia 1.0 yet.

Could you share a "how to"? I am trying to use Adonis + SSR + React but I have not succeeded so far.

from inertiajs-adonisjs.

RomainLanz avatar RomainLanz commented on May 26, 2024

Could you share a "how to"? I am trying to use Adonis + SSR + React but I have not succeeded so far.

If you want to enable SSR, you have to use version 7.4.0 of this package, and you must code your frontend in CJS.

Using the latest version will move your frontend code to ESM. Doing so will require to also have an ESM backend to render your components/pages, and this is not the case with AdonisJS 5.

TL;DR: If you want to do SSR with AdonisJS 5 and Inertia, use version 7.4.0 and code in CJS.

from inertiajs-adonisjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.