Skip to content

Commit 343e7ac

Browse files
committed
feat: monorepo configuration
1 parent 5c9d3d0 commit 343e7ac

File tree

15 files changed

+3026
-9667
lines changed

15 files changed

+3026
-9667
lines changed

.github/workflows/android-actions.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
- name: Setup JDK zulu 17
2323
uses: actions/setup-java@v4
2424
with:
25-
distribution: 'zulu'
26-
java-version: '17'
25+
distribution: "zulu"
26+
java-version: "17"
2727

2828
- name: Enable Corepack
2929
run: corepack enable
3030

3131
- run: yarn install --immutable --check-cache
32-
working-directory: example
32+
working-directory: packages/react-native-app
3333

3434
- run: ./gradlew assemble
35-
working-directory: example/android
35+
working-directory: packages/react-native-app/android

.github/workflows/ios-actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
defaults:
1616
run:
17-
working-directory: ./example
17+
working-directory: ./packages/react-native-app
1818

1919
steps:
2020
- name: Checkout

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
compressionLevel: mixed
22
enableGlobalCache: false
33
nodeLinker: node-modules
4+
nmMode: hardlinks-local
5+
enableGlobalCache: true
6+
nmHoistingLimits: workspaces

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,8 @@
137137
"prettier/prettier": "error"
138138
}
139139
},
140-
"packageManager": "[email protected]"
140+
"packageManager": "[email protected]",
141+
"workspaces": [
142+
"packages/*"
143+
]
141144
}

packages/react-native-app/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autoli
44
rootProject.name = 'RNMaplibreExample'
55

66
include ':rctmln'
7-
project(':rctmln').projectDir = new File(rootProject.projectDir, '../../android/rctmln')
7+
project(':rctmln').projectDir = new File(rootProject.projectDir, '../../../android/rctmln')
88

99
includeBuild('../node_modules/@react-native/gradle-plugin')
1010
include ':app'

packages/react-native-app/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
debounce: './node_modules/debounce',
1616
react: './node_modules/react',
1717
'react-native': './node_modules/react-native',
18-
'@maplibre/maplibre-react-native': '../javascript',
18+
'@maplibre/maplibre-react-native': '../../javascript',
1919
},
2020
},
2121
],

packages/react-native-app/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ target 'RNMaplibreExample' do
5151
)
5252

5353
# default version
54-
pod 'maplibre-react-native', :path => '../../', :inhibit_warnings => false
54+
pod 'maplibre-react-native', :path => '../../../', :inhibit_warnings => false
5555

5656
use_native_modules!
5757

packages/react-native-app/ios/RNMaplibreExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/React-Core_privacy.bundle",
304304
"${PODS_CONFIGURATION_BUILD_DIR}/React-cxxreact/React-cxxreact_privacy.bundle",
305305
"${PODS_CONFIGURATION_BUILD_DIR}/boost/boost_privacy.bundle",
306+
"${PODS_CONFIGURATION_BUILD_DIR}/glog/glog_privacy.bundle",
306307
);
307308
name = "[CP] Copy Pods Resources";
308309
outputPaths = (
@@ -329,6 +330,7 @@
329330
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/React-Core_privacy.bundle",
330331
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/React-cxxreact_privacy.bundle",
331332
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/boost_privacy.bundle",
333+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/glog_privacy.bundle",
332334
);
333335
runOnlyForDeploymentPostprocessing = 0;
334336
shellPath = /bin/sh;

packages/react-native-app/ios/RNMaplibreExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/react-native-app/ios/RNMaplibreExample.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,41 @@
11
const path = require('path');
2-
3-
// eslint-disable-next-line import/order
4-
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
5-
6-
/*
7-
See
8-
9-
https://medium.com/@dushyant_db/how-to-import-files-from-outside-of-root-directory-with-react-native-metro-bundler-18207a348427
10-
*/
11-
12-
// exclusionList is a function that takes an array of regexes and combines
13-
// them with the default exclusions to return a single regex.
14-
const exclusionList = require('metro-config/src/defaults/exclusionList');
2+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
153
const glob = require('glob-to-regexp');
164

17-
const extraNodeModules = {
18-
'@maplibre/maplibre-react-native': path.resolve(__dirname + '/../maps'),
19-
};
20-
21-
function getBlacklist() {
22-
const nodeModuleDirs = [
23-
glob(`${path.resolve(__dirname, '..')}/node_modules/*`),
24-
glob(`${path.resolve(__dirname, '..')}/docs/*`),
25-
glob(`${path.resolve(__dirname, '..')}/e2e/*`),
26-
glob(`${path.resolve(__dirname)}/node_modules/*/node_modules/fbjs/*`),
27-
glob(
28-
`${path.resolve(
29-
__dirname,
30-
)}/node_modules/*/node_modules/hoist-non-react-statics/*`,
31-
),
32-
glob(
33-
`${path.resolve(
34-
__dirname,
35-
)}/node_modules/react-native/node_modules/@babel/*`,
36-
),
37-
];
38-
return exclusionList(nodeModuleDirs);
39-
}
5+
const projectRoot = __dirname;
6+
const workspaceRoot = path.resolve(projectRoot, '../..');
407

418
/**
429
* Metro configuration
4310
* https://reactnative.dev/docs/metro
4411
*
4512
* @type {import('metro-config').MetroConfig}
4613
*/
14+
15+
function withMonorepoPaths(config) {
16+
// #1 - Watch all files in the monorepo
17+
config.watchFolders = [workspaceRoot];
18+
config.resolver.nodeModulesPaths = [
19+
path.resolve(projectRoot, 'node_modules'),
20+
path.resolve(workspaceRoot, 'node_modules'),
21+
];
22+
23+
// #3 - Force resolving nested modules to the folders below
24+
config.resolver.disableHierarchicalLookup = true;
25+
26+
return config;
27+
}
28+
4729
const config = {
48-
resolver: {
49-
blacklistRE: getBlacklist(),
50-
extraNodeModules: new Proxy(extraNodeModules, {
51-
get: (target, name) => {
52-
return name in target
53-
? target[name]
54-
: path.join(process.cwd(), `node_modules/${name}`);
30+
projectRoot: projectRoot,
31+
transformer: {
32+
getTransformOptions: async () => ({
33+
transform: {
34+
experimentalImportSupport: false,
35+
inlineRequires: true,
5536
},
5637
}),
5738
},
58-
watchFolders: [path.resolve(__dirname, '..')],
5939
};
6040

61-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
41+
module.exports = mergeConfig(withMonorepoPaths(getDefaultConfig(projectRoot)), config);

packages/react-native-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "RNMaplibreExample",
2+
"name": "@maplibre-react-native/react-native-app",
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {

packages/react-native-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"noEmit": true,
55
"paths": {
6-
"@maplibre/maplibre-react-native": ["../javascript"],
6+
"@maplibre/maplibre-react-native": ["../../javascript"],
77
"react": ["./node_modules/@types/react"],
88
"react-native": ["./node_modules/@types/react-native"]
99
},

0 commit comments

Comments
 (0)