unable to get RNW working with on SSR side
See original GitHub issueDescription
I’m trying to use this plugin with React Native Web.
I’ve verified config below (aliasing RN to RNW) works in vanilla Vite project.
But using with ssr
plugin, the alias is not picked up, resulting import error due to trying to import react-native
package.
It does seem like this plugin overrides config, so please recommend best approach or necessary fix for getting this working.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import ssr from 'vite-plugin-ssr/plugin'
const reactNativeWeb = () => ({
name: 'react-native-web-plugin',
config: () => ({
resolve: {
alias: {
extensions: [".web.jsx", ".web.js", ".jsx", ".js"],
"react-native": "react-native-web",
}
}
})
})
export default defineConfig({
plugins: [
reactNativeWeb(),
react(),
ssr()
],
})
Error Stack
RN alias error:
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Example of an SSR RNWeb adaptive/heavily responsive site
Hi there,. At my place of work we have a large RN codebase and have been working hard on the web platform side...
Read more >Angular Server Side Rendering (SSR) not loading html for ...
I'm experiencing an issue with how my angular app loads. For some reason on viewing the application online regardless of the route, the...
Read more >The different strategies to building a cross-platform app
The Tamagui and NativeWind ones should work with responsivity and SSR/SEO. But with Tamagui you also get a pre-built component/UI library, plus ...
Read more >West Side Show Room News - Facebook
Casting Notices, Opportunities, and News for actors, singers, dancers, and performers at The West Side Show Room in Rockford, Illinois.
Read more >What I Learned Rebuilding My Portfolio With React Native Web
In this article I break down my key take-aways from rebuilding my portfolio app in RNW, and attempt to extrapolate these lessons into...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing because I think it’s a user land issue that should be fixable.
But if you have evidence that it’s related to vite-plugin-ssr (ideally two reproductions as I described above), then I’m happy to have a look. I’ll reopen then.
(FYI https://brillout.github.io/rules/.)
👍 . Btw. contribution much welcome to create a react-native example. I’ll then link it from the docs.