Uh oh!
There was an error while loading. Please reload this page.
WIP: Web support - #2143
Conversation
d3618f4 to
f8bf028Comparef8bf028 to
b56b154Compare1624696 to
040fb27Compare040fb27 to
b85b120Comparelocaljo
commented
Oct 13, 2022
This works for me, for rendering a map. Just to clarify, there is currently only support for I can look into contributing, but no promises how much I'll be able to do. |
localjo
commented
Oct 17, 2022
An alternative approach that might be more efficient for some is to use platform specific code for your map component, and write a separate map component for web and native. If you do all the data and state handling in parent component, you'll have very little to implement twice. https://reactnative.dev/docs/platform-specific-code#native-specific-extensions-ie-sharing-code-with-nodejs-and-web |
@mfazekas What is the state of this feature? I'm wondering if I should either invest time in doing what @localjo suggested but if there is a way to better share code I would gladdly use it. @localjo could you give an implementation example of your web map? I'm currently trying to test porting a react-native app that has a lot of maps in it. I'm using Nextjs and react-native-web. ├── package.json
├── node_modules
├── ios
├── android
├── web
│ ├── package.json
│ ├── node_modules
│ ├── config.next.js
│ └── pagesMy setup next config looks a bit like this: // next.config.jsconstpath=require('path');constpackageJson=require('../package.json');constwithTM=require('next-transpile-modules');constwithImages=require('next-images');constmodulesToTranspile=[
...Object.keys(packageJson.dependencies).filter((dep)=>dep.startsWith('react-native')),];/** @type {import('next').NextConfig} */constconfiguration={transpilePackages: modulesToTranspile,compiler: {removeConsole: process.env.NODE_ENV==='production',},images: {disableStaticImages: true,},webpack: (config,{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack })=>{config.resolve.alias={
...(config.resolve.alias||{}),'react-native$': 'react-native-web','react-native-vector-icons/': 'react-native-vector-icons/dist/','react-native-linear-gradient': 'react-native-web-linear-gradient',};config.resolve.extensions=['.web.js','.web.ts','.web.tsx',
...config.resolve.extensions,];config.module.rules.push({test: /\.ttf$/,loader: 'url-loader',include: path.resolve(__dirname,'../node_modules/react-native-vector-icons'),});config.plugins.push(newwebpack.DefinePlugin({__DEV__: dev,}));returnconfig;},};module.exports=withImages(withTM(modulesToTranspile)(configuration));So I only add to change this: const modulesToTranspile = [
+ '@rnmapbox/maps',
...Object.keys(packageJson.dependencies).filter((dep) =>
dep.startsWith('react-native')
),
];I didn't manage to install error - ../node_modules/@rnmapbox/maps/javascript/web/MapboxModule.js:1:0
Module not found: Can't resolve 'mapbox-gl'But if I add |
mfazekas
commented
Mar 4, 2023
@cglacet it's a proof of concept as this time. It's merged, but it's not really usefull at the moment. Waiting for community contributions... |
cglacet
commented
Mar 5, 2023
@mfazekas Peole at mapbox are still puting efforts in this repository or is this only maintained by benevolent people? (are they willing to support any work that is made here?) |
Ramon-Balaguer
commented
Jul 24, 2024
@mfazekas Do you know if there is a plan to move this? |
mfazekas
commented
Jul 24, 2024
@Ramon-Balaguer this has been merged. There were some contributions so it's slowly improving. https://rnmapbox.github.io/example-app/ Is the current example app. |
Rebase of #861, this is just a POC.
Structure:
package.json/browserpoints toindex.web.jswhich the loads content formjavascript/webdirectory that contains separate implementation of rnmapbox/maps on the mapbox-gl js api.To consume:
Extra steps for web:
rnmapbox/mapsis transpiled.@expo/webpack-configauto transpires packages starting withreact-native-butrnmapboxhas not `react-native in it's name, so it will not be transpired. See [Web] Work well in My Project ,but get errorModule parse failed: Unexpected tokenin module expo/expo-cli#3744 (comment) and https://github.com/expo/expo-cli/tree/master/packages/webpack-config#include-modules :