Open Xstoudi opened 1 year ago
Hey @Xstoudi
Unfortunately, and if I recall correctly, we still use CJS on the server. This was a limitation imposed by adonis, but things may have changed since then. I will check this out when I am able.
Can you please confirm that client-side rendering works?
Hey !
Yes I can confirme CSR works, the website renders perfectly if I set ssr.enabled
to false
in the config/inertia.ts
file.
I know that Adonis still uses CJS, but I can't figure ou why Webpack seems to output ESM.
Ok I found a workaround. Webpack is trying to deduct a publicPath
and do it using the import.meta
(which we want to avoid).
So, forcing a publicPath
in the webpack.ssr.config.js
did the trick.
End of webpack.ssr.config.js
is modified like this:
config.externals = [require('webpack-node-externals')()]
config.externalsPresets = { node: true }
config.output = {
libraryTarget: 'commonjs2',
filename: 'ssr.js',
path: join(__dirname, './build/inertia/ssr'),
publicPath: '/', // <--- HERE
}
config.experiments = { outputModule: true }
webpack.config.js
: https://pastebin.com/TqBTuZNfwebpack.ssr.config.js
: https://pastebin.com/7eSR3tD5As you can see, I use a Inertia-React-Tailwind stack.
When navigating to a route of my app, Adonis throws this error:
It seems to generate ESM code
import.meta
that obviously fail.Did I do something wrong?