Advertisement
loloof64

Metro bundler config

Feb 6th, 2022
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const blacklist = require('metro-config/src/defaults/blacklist');
  3. const escape = require('escape-string-regexp');
  4. const pak = require('../package.json');
  5. const defaultAssetExts = require("metro-config/src/defaults/defaults").assetExts;
  6.  
  7. const root = path.resolve(__dirname, '..');
  8.  
  9. const modules = Object.keys({
  10.   ...pak.peerDependencies,
  11. });
  12.  
  13. module.exports = {
  14.   projectRoot: __dirname,
  15.   watchFolders: [root],
  16.  
  17.   // We need to make sure that only one version is loaded for peerDependencies
  18.   // So we blacklist them at the root, and alias them to the versions in example's node_modules
  19.   resolver: {
  20.     blacklistRE: blacklist(
  21.       modules.map(
  22.         (m) =>
  23.           new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
  24.       )
  25.     ),
  26.  
  27.     extraNodeModules: modules.reduce((acc, name) => {
  28.       acc[name] = path.join(__dirname, 'node_modules', name);
  29.       return acc;
  30.     }, {}),
  31.  
  32.     assetExts: [...defaultAssetExts, 'nnue'],
  33.   },
  34.  
  35.   transformer: {
  36.     getTransformOptions: async () => ({
  37.       transform: {
  38.         experimentalImportSupport: false,
  39.         inlineRequires: true,
  40.       },
  41.     }),
  42.   },
  43. };
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement