diff --git a/example-new-architecture/android/app/build.gradle b/example-new-architecture/android/app/build.gradle index 972cde170..26e1bd033 100644 --- a/example-new-architecture/android/app/build.gradle +++ b/example-new-architecture/android/app/build.gradle @@ -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) diff --git a/example-new-architecture/metro.config.js b/example-new-architecture/metro.config.js index b011c48c7..2f9c5a36e 100644 --- a/example-new-architecture/metro.config.js +++ b/example-new-architecture/metro.config.js @@ -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: {