Commit 75036cbc8bfd8b02599fdc988390302a6e415132
dx: refactor metro.config.js
Andre Staltz committed on 10/15/2019, 8:57:34 AMParent: 3626ff6ef7eab6d4c93d7724ea76e56a3eb1af48
Files changed
metro.config.js | changed |
metro.config.js | ||
---|---|---|
@@ -1,31 +1,9 @@ | ||
1 | 1 | /* Any copyright is dedicated to the Public Domain. |
2 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
3 | 3 | |
4 | -const path = require('path'); | |
4 | +const blacklist = require('metro-config/src/defaults/blacklist'); | |
5 | 5 | |
6 | -const blacklistRE = new RegExp( | |
7 | - '(' + | |
8 | - [/nodejs-assets\/.*/, /android\/.*/, /ios\/.*/] | |
9 | - .map(escapeRegExp) | |
10 | - .join('|') + | |
11 | - ')$', | |
12 | -); | |
13 | - | |
14 | -function escapeRegExp(pattern) { | |
15 | - if (Object.prototype.toString.call(pattern) === '[object RegExp]') { | |
16 | - return pattern.source.replace(/\//g, path.sep); | |
17 | - } else if (typeof pattern === 'string') { | |
18 | - const escaped = pattern.replace( | |
19 | - /[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, | |
20 | - '\\$&', | |
21 | - ); | |
22 | - // convert the '/' into an escaped local file separator | |
23 | - return escaped.replace(/\//g, `\\${path.sep}`); | |
24 | - } | |
25 | - throw new Error(`Unexpected packager blacklist pattern: ${pattern}`); | |
26 | -} | |
27 | - | |
28 | 6 | module.exports = { |
29 | 7 | transformer: { |
30 | 8 | getTransformOptions: async () => ({ |
31 | 9 | transform: { |
@@ -36,7 +14,16 @@ | ||
36 | 14 | }, |
37 | 15 | |
38 | 16 | resolver: { |
39 | 17 | platforms: ['android', 'ios', 'web'], |
40 | - blacklistRE, | |
18 | + blacklistRE: blacklist([ | |
19 | + /\/android\/.*/, | |
20 | + /\/e2e\/.*/, | |
21 | + /\/ios\/.*/, | |
22 | + /\/nodejs-assets\/.*/, | |
23 | + /\/patches\/.*/, | |
24 | + /\/tools\/.*/, | |
25 | + // Not used in runtime (is either dev dependency or surely not used) | |
26 | + /\/node_modules\/appium\/.*/, | |
27 | + ]), | |
41 | 28 | }, |
42 | 29 | }; |
Built with git-ssb-web