Skip to content

Commit

Permalink
replace symlink with extraNodeModules
Browse files Browse the repository at this point in the history
  • Loading branch information
arvkmr committed Dec 15, 2023
1 parent fca8928 commit 553e63b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
29 changes: 21 additions & 8 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const { makeMetroConfig } = require('@rnx-kit/metro-config')
const MetroSymlinksResolver = require("@rnx-kit/metro-resolver-symlinks");
const path = require("path");
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");

const defaultConfig = getDefaultConfig(__dirname);
const { resolver: { sourceExts, assetExts } } = defaultConfig;

const extraNodeModules = {
'react-native-feed-media-audio-player': path.resolve(__dirname + '/../package/'),
};
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {

resolver: {
extraNodeModules: new Proxy(extraNodeModules, {
get: (target, name) =>
//redirects dependencies referenced from react-native-feed-media-audio-player/ to local node_modules
name in target ? target[name] : path.join(process.cwd(), `node_modules/${name}`),
}),

assetExts: assetExts.filter((ext) => ext !== "svg"),
sourceExts: [...sourceExts, 'jsx', 'js', 'ts', 'tsx', 'cjs', 'json', "svg"],
resolverMainFields: ["sbmodern", "react-native", "browser", "main"],
},
watchFolders: [path.resolve(__dirname + '/../package/')],
};
module.exports = makeMetroConfig({
resolver: {
resolveRequest: MetroSymlinksResolver(),
},
});

module.exports = mergeConfig(defaultConfig, config);


5 changes: 2 additions & 3 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest",
"postinstall": "cd ../package && npm link && cd ../example && npm link react-native-feed-media-audio-player"
"test": "jest"
},
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.0",
"react-native-feed-media-audio-player": "file:..package"
"react-native-feed-media-audio-player": "file:../package"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@babel/runtime": "^7.23.6",
"@react-native/babel-preset": "^0.73.18",
"@react-native/eslint-config": "^0.73.1",
"@react-native/metro-config": "^0.73.2",
Expand Down

0 comments on commit 553e63b

Please sign in to comment.