@expo/metro-config 0.3.17 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ExpoMetroConfig.js +320 -221
- package/build/ExpoMetroConfig.js.map +1 -1
- package/build/getModulesPaths.js +49 -26
- package/build/getModulesPaths.js.map +1 -1
- package/build/getWatchFolders.js +118 -65
- package/build/getWatchFolders.js.map +1 -1
- package/build/importMetroFromProject.js +40 -25
- package/build/importMetroFromProject.js.map +1 -1
- package/build/transformer/createExoticTransformer.js +132 -96
- package/build/transformer/createExoticTransformer.js.map +1 -1
- package/build/transformer/createMatcher.js +48 -39
- package/build/transformer/createMatcher.js.map +1 -1
- package/build/transformer/createMultiRuleTransformer.js +267 -168
- package/build/transformer/createMultiRuleTransformer.js.map +1 -1
- package/build/transformer/generateFunctionMap.js +39 -26
- package/build/transformer/generateFunctionMap.js.map +1 -1
- package/build/transformer/getBabelConfig.js +142 -94
- package/build/transformer/getBabelConfig.js.map +1 -1
- package/build/transformer/getCacheKey.js +40 -19
- package/build/transformer/getCacheKey.js.map +1 -1
- package/build/transformer/index.js +74 -11
- package/build/transformer/index.js.map +1 -1
- package/build/transformer/metro-expo-babel-transformer.js +43 -22
- package/build/transformer/metro-expo-babel-transformer.js.map +1 -1
- package/build/transformer/metro-expo-exotic-babel-transformer.js +14 -3
- package/build/transformer/metro-expo-exotic-babel-transformer.js.map +1 -1
- package/package.json +11 -16
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBabelConfig = getBabelConfig;
|
|
7
|
+
|
|
8
|
+
function _fs() {
|
|
9
|
+
const data = _interopRequireDefault(require("fs"));
|
|
10
|
+
|
|
11
|
+
_fs = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _path() {
|
|
19
|
+
const data = _interopRequireDefault(require("path"));
|
|
20
|
+
|
|
21
|
+
_path = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _resolveFrom() {
|
|
29
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
30
|
+
|
|
31
|
+
_resolveFrom = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
+
|
|
2
40
|
/**
|
|
3
41
|
* Copyright (c) Expo.
|
|
4
42
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -8,110 +46,120 @@
|
|
|
8
46
|
*
|
|
9
47
|
* Forks the default metro-react-native-babel-transformer and adds support for known transforms.
|
|
10
48
|
*/
|
|
11
|
-
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getBabelConfig = void 0;
|
|
16
|
-
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
49
|
+
|
|
19
50
|
/**
|
|
20
51
|
* Return a memoized function that checks for the existence of a
|
|
21
52
|
* project level .babelrc file, and if it doesn't exist, reads the
|
|
22
53
|
* default RN babelrc file and uses that.
|
|
23
54
|
*/
|
|
24
|
-
const getBabelRC =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
const getBabelRC = function () {
|
|
56
|
+
let babelRC = null;
|
|
57
|
+
return function _getBabelRC(projectRoot, options) {
|
|
58
|
+
if (babelRC != null) {
|
|
59
|
+
return babelRC;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
babelRC = {
|
|
63
|
+
plugins: []
|
|
64
|
+
}; // Let's look for a babel config file in the project root.
|
|
65
|
+
// TODO look into adding a command line option to specify this location
|
|
66
|
+
|
|
67
|
+
let projectBabelRCPath; // .babelrc
|
|
68
|
+
|
|
69
|
+
if (projectRoot) {
|
|
70
|
+
projectBabelRCPath = _path().default.resolve(projectRoot, '.babelrc');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (projectBabelRCPath) {
|
|
74
|
+
// .babelrc.js
|
|
75
|
+
if (!_fs().default.existsSync(projectBabelRCPath)) {
|
|
76
|
+
projectBabelRCPath = _path().default.resolve(projectRoot, '.babelrc.js');
|
|
77
|
+
} // babel.config.js
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if (!_fs().default.existsSync(projectBabelRCPath)) {
|
|
81
|
+
projectBabelRCPath = _path().default.resolve(projectRoot, 'babel.config.js');
|
|
82
|
+
} // If we found a babel config file, extend our config off of it
|
|
83
|
+
// otherwise the default config will be used
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (_fs().default.existsSync(projectBabelRCPath)) {
|
|
87
|
+
babelRC.extends = projectBabelRCPath;
|
|
88
|
+
}
|
|
89
|
+
} // If a babel config file doesn't exist in the project then
|
|
90
|
+
// the default preset for react-native will be used instead.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if (!babelRC.extends) {
|
|
94
|
+
var _ref, _resolveFrom$silent;
|
|
95
|
+
|
|
96
|
+
const {
|
|
97
|
+
experimentalImportSupport,
|
|
98
|
+
...presetOptions
|
|
99
|
+
} = options; // Use `babel-preset-expo` instead of `metro-react-native-babel-preset`.
|
|
100
|
+
|
|
101
|
+
const presetPath = (_ref = (_resolveFrom$silent = _resolveFrom().default.silent(projectRoot, 'babel-preset-expo')) !== null && _resolveFrom$silent !== void 0 ? _resolveFrom$silent : _resolveFrom().default.silent(projectRoot, 'metro-react-native-babel-preset')) !== null && _ref !== void 0 ? _ref : require.resolve('babel-preset-expo');
|
|
102
|
+
babelRC.presets = [[require(presetPath), {
|
|
103
|
+
// Default to React 17 automatic JSX transform.
|
|
104
|
+
jsxRuntime: 'automatic',
|
|
105
|
+
...presetOptions,
|
|
106
|
+
disableImportExportTransform: experimentalImportSupport,
|
|
107
|
+
enableBabelRuntime: options.enableBabelRuntime
|
|
108
|
+
}]];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return babelRC;
|
|
112
|
+
};
|
|
113
|
+
}();
|
|
76
114
|
/**
|
|
77
115
|
* Given a filename and options, build a Babel
|
|
78
116
|
* config object with the appropriate plugins.
|
|
79
117
|
*/
|
|
118
|
+
|
|
119
|
+
|
|
80
120
|
function getBabelConfig(filename, options, plugins = []) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
const babelRC = getBabelRC(options.projectRoot, options);
|
|
122
|
+
const extraConfig = {
|
|
123
|
+
babelrc: typeof options.enableBabelRCLookup === 'boolean' ? options.enableBabelRCLookup : true,
|
|
124
|
+
code: false,
|
|
125
|
+
filename,
|
|
126
|
+
highlightCode: true
|
|
127
|
+
};
|
|
128
|
+
const config = { ...babelRC,
|
|
129
|
+
...extraConfig
|
|
130
|
+
}; // Add extra plugins
|
|
131
|
+
|
|
132
|
+
const extraPlugins = []; // TODO: This probably can be removed
|
|
133
|
+
|
|
134
|
+
if (options.inlineRequires) {
|
|
135
|
+
const inlineRequiresPlugin = (0, _resolveFrom().default)(options.projectRoot, 'babel-preset-fbjs/plugins/inline-requires');
|
|
136
|
+
extraPlugins.push(inlineRequiresPlugin);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
config.plugins = extraPlugins.concat(config.plugins, plugins);
|
|
140
|
+
|
|
141
|
+
if (options.dev && options.hot) {
|
|
142
|
+
// Note: this intentionally doesn't include the path separator because
|
|
143
|
+
// I'm not sure which one it should use on Windows, and false positives
|
|
144
|
+
// are unlikely anyway. If you later decide to include the separator,
|
|
145
|
+
// don't forget that the string usually *starts* with "node_modules" so
|
|
146
|
+
// the first one often won't be there.
|
|
147
|
+
// TODO: Support monorepos
|
|
148
|
+
const mayContainEditableReactComponents = filename.indexOf('node_modules') === -1;
|
|
149
|
+
|
|
150
|
+
if (mayContainEditableReactComponents) {
|
|
151
|
+
if (!config.plugins) {
|
|
152
|
+
config.plugins = [];
|
|
153
|
+
} // Add react refresh runtime.
|
|
154
|
+
// NOTICE: keep in sync with 'metro-react-native-babel-preset/src/configs/hmr'.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
config.plugins.push(_resolveFrom().default.silent(options.projectRoot, 'react-refresh/babel'));
|
|
95
158
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// don't forget that the string usually *starts* with "node_modules" so
|
|
102
|
-
// the first one often won't be there.
|
|
103
|
-
// TODO: Support monorepos
|
|
104
|
-
const mayContainEditableReactComponents = filename.indexOf('node_modules') === -1;
|
|
105
|
-
if (mayContainEditableReactComponents) {
|
|
106
|
-
if (!config.plugins) {
|
|
107
|
-
config.plugins = [];
|
|
108
|
-
}
|
|
109
|
-
// Add react refresh runtime.
|
|
110
|
-
// NOTICE: keep in sync with 'metro-react-native-babel-preset/src/configs/hmr'.
|
|
111
|
-
config.plugins.push(resolve_from_1.default.silent(options.projectRoot, 'react-refresh/babel'));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return { ...babelRC, ...config };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return { ...babelRC,
|
|
162
|
+
...config
|
|
163
|
+
};
|
|
115
164
|
}
|
|
116
|
-
exports.getBabelConfig = getBabelConfig;
|
|
117
165
|
//# sourceMappingURL=getBabelConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBabelConfig.js","
|
|
1
|
+
{"version":3,"file":"getBabelConfig.js","names":["getBabelRC","babelRC","_getBabelRC","projectRoot","options","plugins","projectBabelRCPath","path","resolve","fs","existsSync","extends","experimentalImportSupport","presetOptions","presetPath","resolveFrom","silent","require","presets","jsxRuntime","disableImportExportTransform","enableBabelRuntime","getBabelConfig","filename","extraConfig","babelrc","enableBabelRCLookup","code","highlightCode","config","extraPlugins","inlineRequires","inlineRequiresPlugin","push","concat","dev","hot","mayContainEditableReactComponents","indexOf"],"sources":["../../src/transformer/getBabelConfig.ts"],"sourcesContent":["/**\n * Copyright (c) Expo.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Forks the default metro-react-native-babel-transformer and adds support for known transforms.\n */\n\nimport type { PluginItem as BabelPlugins, PluginItem } from '@babel/core';\nimport fs from 'fs';\nimport type { BabelTransformerOptions } from 'metro-babel-transformer';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\n/**\n * Return a memoized function that checks for the existence of a\n * project level .babelrc file, and if it doesn't exist, reads the\n * default RN babelrc file and uses that.\n */\nconst getBabelRC = (function () {\n let babelRC: {\n // `any` to avoid flow type mismatch with Babel 7's internal type of\n // `Array<string>` even though it correctly accepts the usage below.\n presets?: any;\n extends?: string;\n plugins: BabelPlugins;\n } | null = null;\n\n return function _getBabelRC(projectRoot: string, options: BabelTransformerOptions) {\n if (babelRC != null) {\n return babelRC;\n }\n\n babelRC = { plugins: [] };\n\n // Let's look for a babel config file in the project root.\n // TODO look into adding a command line option to specify this location\n let projectBabelRCPath;\n\n // .babelrc\n if (projectRoot) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc');\n }\n\n if (projectBabelRCPath) {\n // .babelrc.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, '.babelrc.js');\n }\n\n // babel.config.js\n if (!fs.existsSync(projectBabelRCPath)) {\n projectBabelRCPath = path.resolve(projectRoot, 'babel.config.js');\n }\n\n // If we found a babel config file, extend our config off of it\n // otherwise the default config will be used\n if (fs.existsSync(projectBabelRCPath)) {\n babelRC.extends = projectBabelRCPath;\n }\n }\n\n // If a babel config file doesn't exist in the project then\n // the default preset for react-native will be used instead.\n if (!babelRC.extends) {\n const { experimentalImportSupport, ...presetOptions } = options;\n\n // Use `babel-preset-expo` instead of `metro-react-native-babel-preset`.\n const presetPath =\n resolveFrom.silent(projectRoot, 'babel-preset-expo') ??\n resolveFrom.silent(projectRoot, 'metro-react-native-babel-preset') ??\n require.resolve('babel-preset-expo');\n\n babelRC.presets = [\n [\n require(presetPath),\n {\n // Default to React 17 automatic JSX transform.\n jsxRuntime: 'automatic',\n ...presetOptions,\n disableImportExportTransform: experimentalImportSupport,\n enableBabelRuntime: options.enableBabelRuntime,\n },\n ],\n ];\n }\n\n return babelRC;\n };\n})();\n\n/**\n * Given a filename and options, build a Babel\n * config object with the appropriate plugins.\n */\nexport function getBabelConfig(\n filename: string,\n options: BabelTransformerOptions,\n plugins: BabelPlugins = []\n) {\n const babelRC = getBabelRC(options.projectRoot, options);\n\n const extraConfig = {\n babelrc: typeof options.enableBabelRCLookup === 'boolean' ? options.enableBabelRCLookup : true,\n code: false,\n filename,\n highlightCode: true,\n };\n\n const config: any = { ...babelRC, ...extraConfig };\n\n // Add extra plugins\n const extraPlugins: (string | PluginItem)[] = [];\n\n // TODO: This probably can be removed\n if (options.inlineRequires) {\n const inlineRequiresPlugin = resolveFrom(\n options.projectRoot,\n 'babel-preset-fbjs/plugins/inline-requires'\n );\n extraPlugins.push(inlineRequiresPlugin);\n }\n\n config.plugins = extraPlugins.concat(config.plugins, plugins);\n\n if (options.dev && options.hot) {\n // Note: this intentionally doesn't include the path separator because\n // I'm not sure which one it should use on Windows, and false positives\n // are unlikely anyway. If you later decide to include the separator,\n // don't forget that the string usually *starts* with \"node_modules\" so\n // the first one often won't be there.\n // TODO: Support monorepos\n const mayContainEditableReactComponents = filename.indexOf('node_modules') === -1;\n\n if (mayContainEditableReactComponents) {\n if (!config.plugins) {\n config.plugins = [];\n }\n // Add react refresh runtime.\n // NOTICE: keep in sync with 'metro-react-native-babel-preset/src/configs/hmr'.\n config.plugins.push(resolveFrom.silent(options.projectRoot, 'react-refresh/babel'));\n }\n }\n\n return { ...babelRC, ...config };\n}\n"],"mappings":";;;;;;;AAWA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA,MAAMA,UAAU,GAAI,YAAY;EAC9B,IAAIC,OAMI,GAAG,IANX;EAQA,OAAO,SAASC,WAAT,CAAqBC,WAArB,EAA0CC,OAA1C,EAA4E;IACjF,IAAIH,OAAO,IAAI,IAAf,EAAqB;MACnB,OA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;MACAwB,MAAM,CAACxB,OAAP,CAAe4B,IAAf,CAAoBlB,sBAAA,CAAYC,MAAZ,CAAmBZ,OAAO,CAACD,WAA3B,EAAwC,qBAAxC,CAApB;IACD;EACF;;EAED,OAAO,EAAE,GAAGF,OAAL;IAAc,GAAG4B;EAAjB,CAAP;AACD"}
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cacheKeyParts = void 0;
|
|
7
|
+
exports.getCacheKey = getCacheKey;
|
|
8
|
+
|
|
9
|
+
function _crypto() {
|
|
10
|
+
const data = _interopRequireDefault(require("crypto"));
|
|
11
|
+
|
|
12
|
+
_crypto = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _fs() {
|
|
20
|
+
const data = require("fs");
|
|
21
|
+
|
|
22
|
+
_fs = function () {
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
const cacheKeyParts = [(0, _fs().readFileSync)(__filename), // Since babel-preset-fbjs cannot be safely resolved relative to the
|
|
32
|
+
// project root, use this environment variable that we define earlier.
|
|
33
|
+
process.env.EXPO_METRO_CACHE_KEY_VERSION || '3.3.0' // require('babel-preset-fbjs/package.json').version,
|
|
34
|
+
]; // Matches upstream
|
|
35
|
+
|
|
36
|
+
exports.cacheKeyParts = cacheKeyParts;
|
|
37
|
+
|
|
17
38
|
function getCacheKey() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
const key = _crypto().default.createHash('md5');
|
|
40
|
+
|
|
41
|
+
cacheKeyParts.forEach(part => key.update(part));
|
|
42
|
+
return key.digest('hex');
|
|
21
43
|
}
|
|
22
|
-
exports.getCacheKey = getCacheKey;
|
|
23
44
|
//# sourceMappingURL=getCacheKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCacheKey.js","
|
|
1
|
+
{"version":3,"file":"getCacheKey.js","names":["cacheKeyParts","readFileSync","__filename","process","env","EXPO_METRO_CACHE_KEY_VERSION","getCacheKey","key","crypto","createHash","forEach","part","update","digest"],"sources":["../../src/transformer/getCacheKey.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { readFileSync } from 'fs';\n\nexport const cacheKeyParts = [\n readFileSync(__filename),\n // Since babel-preset-fbjs cannot be safely resolved relative to the\n // project root, use this environment variable that we define earlier.\n process.env.EXPO_METRO_CACHE_KEY_VERSION || '3.3.0',\n // require('babel-preset-fbjs/package.json').version,\n];\n\n// Matches upstream\nexport function getCacheKey(): string {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach(part => key.update(part));\n return key.digest('hex');\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEO,MAAMA,aAAa,GAAG,CAC3B,IAAAC,kBAAA,EAAaC,UAAb,CAD2B,EAE3B;AACA;AACAC,OAAO,CAACC,GAAR,CAAYC,4BAAZ,IAA4C,OAJjB,CAK3B;AAL2B,CAAtB,C,CAQP;;;;AACO,SAASC,WAAT,GAA+B;EACpC,MAAMC,GAAG,GAAGC,iBAAA,CAAOC,UAAP,CAAkB,KAAlB,CAAZ;;EACAT,aAAa,CAACU,OAAd,CAAsBC,IAAI,IAAIJ,GAAG,CAACK,MAAJ,CAAWD,IAAX,CAA9B;EACA,OAAOJ,GAAG,CAACM,MAAJ,CAAW,KAAX,CAAP;AACD"}
|
|
@@ -1,13 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "createModuleMatcher", {
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createExoticTransformer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _createExoticTransformer().createExoticTransformer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "createModuleMatcher", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _createMatcher().createModuleMatcher;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "createMultiRuleTransformer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _createMultiRuleTransformer().createMultiRuleTransformer;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getCacheKey", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _getCacheKey().getCacheKey;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "loaders", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _createMultiRuleTransformer().loaders;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function _createExoticTransformer() {
|
|
38
|
+
const data = require("./createExoticTransformer");
|
|
39
|
+
|
|
40
|
+
_createExoticTransformer = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _getCacheKey() {
|
|
48
|
+
const data = require("./getCacheKey");
|
|
49
|
+
|
|
50
|
+
_getCacheKey = function () {
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _createMultiRuleTransformer() {
|
|
58
|
+
const data = require("./createMultiRuleTransformer");
|
|
59
|
+
|
|
60
|
+
_createMultiRuleTransformer = function () {
|
|
61
|
+
return data;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _createMatcher() {
|
|
68
|
+
const data = require("./createMatcher");
|
|
69
|
+
|
|
70
|
+
_createMatcher = function () {
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return data;
|
|
75
|
+
}
|
|
13
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/transformer/index.ts"],"sourcesContent":["export { createExoticTransformer } from './createExoticTransformer';\nexport { getCacheKey } from './getCacheKey';\nexport { loaders, createMultiRuleTransformer } from './createMultiRuleTransformer';\nexport { createModuleMatcher } from './createMatcher';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
|
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
function _resolveFrom() {
|
|
4
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
5
|
+
|
|
6
|
+
_resolveFrom = function () {
|
|
7
|
+
return data;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function _getCacheKey() {
|
|
14
|
+
const data = require("./getCacheKey");
|
|
15
|
+
|
|
16
|
+
_getCacheKey = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
|
|
2
25
|
// Copyright 2021-present 650 Industries (Expo). All rights reserved.
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
8
|
-
const getCacheKey_1 = require("./getCacheKey");
|
|
9
26
|
let transformer = null;
|
|
27
|
+
|
|
10
28
|
function resolveTransformer(projectRoot) {
|
|
11
|
-
|
|
12
|
-
return transformer;
|
|
13
|
-
}
|
|
14
|
-
const resolvedPath = resolve_from_1.default.silent(projectRoot, 'metro-react-native-babel-transformer');
|
|
15
|
-
if (!resolvedPath) {
|
|
16
|
-
throw new Error('Missing package "metro-react-native-babel-transformer" in the project. ' +
|
|
17
|
-
'This usually means `react-native` is not installed. ' +
|
|
18
|
-
'Please verify that dependencies in package.json include "react-native" ' +
|
|
19
|
-
'and run `yarn` or `npm install`.');
|
|
20
|
-
}
|
|
21
|
-
transformer = require(resolvedPath);
|
|
29
|
+
if (transformer) {
|
|
22
30
|
return transformer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const resolvedPath = _resolveFrom().default.silent(projectRoot, 'metro-react-native-babel-transformer');
|
|
34
|
+
|
|
35
|
+
if (!resolvedPath) {
|
|
36
|
+
throw new Error('Missing package "metro-react-native-babel-transformer" in the project. ' + 'This usually means `react-native` is not installed. ' + 'Please verify that dependencies in package.json include "react-native" ' + 'and run `yarn` or `npm install`.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
transformer = require(resolvedPath);
|
|
40
|
+
return transformer;
|
|
23
41
|
}
|
|
24
42
|
/**
|
|
25
43
|
* Extends the default `metro-react-native-babel-transformer`
|
|
@@ -34,13 +52,16 @@ function resolveTransformer(projectRoot) {
|
|
|
34
52
|
*
|
|
35
53
|
* @returns
|
|
36
54
|
*/
|
|
55
|
+
|
|
56
|
+
|
|
37
57
|
function transform(props) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
// Use babel-preset-expo by default if available...
|
|
59
|
+
props.options.extendsBabelConfigPath = _resolveFrom().default.silent(props.options.projectRoot, 'babel-preset-expo');
|
|
60
|
+
return resolveTransformer(props.options.projectRoot).transform(props);
|
|
41
61
|
}
|
|
62
|
+
|
|
42
63
|
module.exports = {
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
getCacheKey: _getCacheKey().getCacheKey,
|
|
65
|
+
transform
|
|
45
66
|
};
|
|
46
67
|
//# sourceMappingURL=metro-expo-babel-transformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro-expo-babel-transformer.js","
|
|
1
|
+
{"version":3,"file":"metro-expo-babel-transformer.js","names":["transformer","resolveTransformer","projectRoot","resolvedPath","resolveFrom","silent","Error","require","transform","props","options","extendsBabelConfigPath","module","exports","getCacheKey"],"sources":["../../src/transformer/metro-expo-babel-transformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport resolveFrom from 'resolve-from';\n\nimport { getCacheKey } from './getCacheKey';\n\nlet transformer: any = null;\n\nfunction resolveTransformer(projectRoot: string) {\n if (transformer) {\n return transformer;\n }\n const resolvedPath = resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer');\n if (!resolvedPath) {\n throw new Error(\n 'Missing package \"metro-react-native-babel-transformer\" in the project. ' +\n 'This usually means `react-native` is not installed. ' +\n 'Please verify that dependencies in package.json include \"react-native\" ' +\n 'and run `yarn` or `npm install`.'\n );\n }\n transformer = require(resolvedPath);\n return transformer;\n}\n\n/**\n * Extends the default `metro-react-native-babel-transformer`\n * and uses babel-preset-expo as the default instead of metro-react-native-babel-preset.\n * This enables users to safely transpile an Expo project without\n * needing to explicitly define a `babel.config.js`\n *\n * @param filename string\n * @param options BabelTransformerOptions\n * @param plugins $PropertyType<BabelCoreOptions, 'plugins'>\n * @param src string\n *\n * @returns\n */\nfunction transform(props: {\n filename: string;\n options: Record<string, any> & { projectRoot: string };\n plugins?: unknown;\n src: string;\n}) {\n // Use babel-preset-expo by default if available...\n props.options.extendsBabelConfigPath = resolveFrom.silent(\n props.options.projectRoot,\n 'babel-preset-expo'\n );\n return resolveTransformer(props.options.projectRoot).transform(props);\n}\n\nmodule.exports = {\n getCacheKey,\n transform,\n};\n"],"mappings":";;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAJA;AAMA,IAAIA,WAAgB,GAAG,IAAvB;;AAEA,SAASC,kBAAT,CAA4BC,WAA5B,EAAiD;EAC/C,IAAIF,WAAJ,EAAiB;IACf,OAAOA,WAAP;EACD;;EACD,MAAMG,YAAY,GAAGC,sBAAA,CAAYC,MAAZ,CAAmBH,WAAnB,EAAgC,sCAAhC,CAArB;;EACA,IAAI,CAACC,YAAL,EAAmB;IACjB,MAAM,IAAIG,KAAJ,CACJ,4EACE,sDADF,GAEE,yEAFF,GAGE,kCAJE,CAAN;EAMD;;EACDN,WAAW,GAAGO,OAAO,CAACJ,YAAD,CAArB;EACA,OAAOH,WAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASQ,SAAT,CAAmBC,KAAnB,EAKG;EACD;EACAA,KAAK,CAACC,OAAN,CAAcC,sBAAd,GAAuCP,sBAAA,CAAYC,MAAZ,CACrCI,KAAK,CAACC,OAAN,CAAcR,WADuB,EAErC,mBAFqC,CAAvC;EAIA,OAAOD,kBAAkB,CAACQ,KAAK,CAACC,OAAN,CAAcR,WAAf,CAAlB,CAA8CM,SAA9C,CAAwDC,KAAxD,CAAP;AACD;;AAEDG,MAAM,CAACC,OAAP,GAAiB;EACfC,WAAW,EAAXA,0BADe;EAEfN;AAFe,CAAjB"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
function _createExoticTransformer() {
|
|
4
|
+
const data = require("./createExoticTransformer");
|
|
5
|
+
|
|
6
|
+
_createExoticTransformer = function () {
|
|
7
|
+
return data;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
|
|
2
13
|
// Copyright 2021-present 650 Industries (Expo). All rights reserved.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
14
|
+
module.exports = (0, _createExoticTransformer().createExoticTransformer)({
|
|
15
|
+
nodeModulesPaths: ['node_modules']
|
|
16
|
+
});
|
|
6
17
|
//# sourceMappingURL=metro-expo-exotic-babel-transformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro-expo-exotic-babel-transformer.js","
|
|
1
|
+
{"version":3,"file":"metro-expo-exotic-babel-transformer.js","names":["module","exports","createExoticTransformer","nodeModulesPaths"],"sources":["../../src/transformer/metro-expo-exotic-babel-transformer.ts"],"sourcesContent":["// Copyright 2021-present 650 Industries (Expo). All rights reserved.\n\nimport { createExoticTransformer } from './createExoticTransformer';\n\nmodule.exports = createExoticTransformer({ nodeModulesPaths: ['node_modules'] });\n"],"mappings":";;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAFA;AAIAA,MAAM,CAACC,OAAP,GAAiB,IAAAC,kDAAA,EAAwB;EAAEC,gBAAgB,EAAE,CAAC,cAAD;AAApB,CAAxB,CAAjB"}
|