diff --git a/example/babel.config.js b/example/babel.config.js index 351245114..24eb5a1fe 100644 --- a/example/babel.config.js +++ b/example/babel.config.js @@ -2,30 +2,6 @@ module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ '@babel/plugin-transform-modules-commonjs', - [ - 'module-resolver', - { - alias: { - '@react-native-mapbox-gl/maps': '../javascript/index', - // from maps/package.json - react: './node_modules/react', - 'react-native': './node_modules/react-native', - '@turf/helpers': './node_modules/@turf/helpers', - '@turf/distance': './node_modules/@turf/distance', - '@turf/nearest-point-on-line': - './node_modules/@turf/nearest-point-on-line', - '@turf/length': './node_modules/@turf/length', - '@turf/along': './node_modules/@turf/along', - '@mapbox/geo-viewport': './node_modules/@mapbox/geo-viewport', - debounce: './node_modules/debounce', - - '@babel': './node_modules/@babel', - fbjs: './node_modules/fbjs', - 'hoist-non-react-statics': './node_modules/hoist-non-react-statics', - invariant: './node_modules/invariant', - 'prop-types': './node_modules/prop-types', - }, - }, - ], + ['module-resolver'], ].filter(Boolean), }; diff --git a/example/metro.config.js b/example/metro.config.js index b76639dbe..9365be86d 100644 --- a/example/metro.config.js +++ b/example/metro.config.js @@ -6,9 +6,19 @@ */ const path = require('path'); +/* + See + + https://medium.com/@dushyant_db/how-to-import-files-from-outside-of-root-directory-with-react-native-metro-bundler-18207a348427 +*/ + const blacklist = require('metro-config/src/defaults/blacklist'); const glob = require('glob-to-regexp'); +const extraNodeModules = { + '@react-native-mapbox-gl/maps': path.resolve(__dirname+'/../maps') +} + function getBlacklist() { const nodeModuleDirs = [ glob(`${path.resolve(__dirname, '..')}/node_modules/*`), @@ -32,6 +42,13 @@ function getBlacklist() { module.exports = { resolver: { blacklistRE: getBlacklist(), + extraNodeModules: new Proxy(extraNodeModules, { + get: (target, name) => { + return name in target + ? target[name] + : path.join(process.cwd(), `node_modules/${name}`); + }, + }), }, watchFolders: [path.resolve(__dirname, '..')], transformer: {