-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap-web-fix.js
23 lines (18 loc) · 893 Bytes
/
map-web-fix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const chalk = require('chalk')
const { readFile, writeFile, copyFile } = require('fs').promises
console.log(chalk.green('here'))
function log(...args) {
console.log(chalk.yellow('[react-native-maps]'), ...args)
}
reactNativeMaps = async function() {
log('📦 Creating web compatibility of react-native-maps using an empty module loaded on web builds')
const modulePath = 'node_modules/react-native-maps'
await writeFile(`${modulePath}/lib/index.web.js`, 'module.exports = {}', 'utf-8')
await copyFile(`${modulePath}/lib/index.d.ts`, `${modulePath}/lib/index.web.d.ts`)
const pkg = JSON.parse(await readFile(`${modulePath}/package.json`))
pkg['react-native'] = 'lib/index.js'
pkg['main'] = 'lib/index.web.js'
await writeFile(`${modulePath}/package.json`, JSON.stringify(pkg, null, 2), 'utf-8')
log('✅ script ran successfully')
}
reactNativeMaps()