Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Native dependencies and babel plugins resolution issues #37

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion template/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This babel config is used by Jest.
* Modify this babel config file when you need to add a new plugin.
*/
const path = require('path');

Expand Down
5 changes: 5 additions & 0 deletions template/example/bare/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Don't edit this file directly if you don't have to.
* Modify the babel config file in the project root directory.
*/
const path = require('path');

const rootDir = path.resolve(__dirname, '../..');
Expand All @@ -9,6 +13,7 @@ const appPkg = require(path.join(appDir, 'package.json'));
module.exports = function (api) {
api.cache(true);
return {
extends: path.join(rootDir, 'babel.config.cjs'),
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
Expand Down
18 changes: 15 additions & 3 deletions template/example/bare/react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
/**
* This file is required to properly resolve native dependencies
* listed in the example/app package.json on Android.
*/
const path = require('path');
const appPackageJSON = require('../app/package.json');

const rootDir = path.resolve(__dirname, '../..');
const rootPkg = require(path.join(rootDir, 'package.json'));

const appDir = path.resolve(__dirname, '../app');
const appPkg = require(path.resolve(appDir, 'package.json'));

let dependencies = {};

Object.keys(appPackageJSON.dependencies).forEach(dep => {
[
// Include library dependencies that will normally be installed with
// the library (dependencies in the top-level package.json)
...Object.keys(rootPkg.dependencies || {}),
// Include example app dependencies that will be normally available
// (both dependencies and devDependencies in the example app's package.json)
...Object.keys(appPkg.devDependencies || {}),
...Object.keys(appPkg.dependencies || {})
].forEach(dep => {
dependencies[dep] = {
root: path.resolve(__dirname, `../../node_modules/${dep}`)
};
Expand Down
5 changes: 5 additions & 0 deletions template/example/expo/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Don't edit this file directly if you don't have to.
* Modify the babel config file in the project root directory.
*/
const path = require('path');

const rootDir = path.resolve(__dirname, '../..');
Expand All @@ -9,6 +13,7 @@ const appPkg = require(path.join(appDir, 'package.json'));
module.exports = function (api) {
api.cache(true);
return {
extends: path.join(rootDir, 'babel.config.cjs'),
presets: ['babel-preset-expo'],
plugins: [
[
Expand Down
Loading