Skip to content

Commit

Permalink
Make new arch example app compile on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
louiszawadzki committed Sep 20, 2023
1 parent eb2eeea commit 221fbb2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example-new-architecture/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ dependencies {
} else {
implementation jscFlavor
}

constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
32 changes: 32 additions & 0 deletions example-new-architecture/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
const path = require('path');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const escape = require('escape-string-regexp');
const pakCore = require('../packages/core/package.json');

const root = path.resolve(__dirname, '..');

const modules = Object.keys({
...pakCore.peerDependencies,
});

module.exports = {
projectRoot: __dirname,
watchFolders: [root],

// We need to make sure that only one version is loaded for peerDependencies
// So we blacklist them at the root, and alias them to the versions in example's node_modules
// This block is very important, because otherwise things like React can be packed multiple times
// while it should be only one React instance in the runtime. exclusionList relies on the modules which are
// declared as peer dependencies in the core package.
resolver: {
blacklistRE: exclusionList(
modules.map(
m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`),
),
),

extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
},

transformer: {
getTransformOptions: async () => ({
transform: {
Expand Down

0 comments on commit 221fbb2

Please sign in to comment.