metro 0.60.0 → 0.64.0
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/package.json +22 -22
- package/src/Bundler/util.js +12 -10
- package/src/Bundler/util.js.flow +13 -12
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +1 -1
- package/src/DeltaBundler/computeDelta.js.flow +4 -1
- package/src/DeltaBundler/getTransformCacheKey.js +4 -3
- package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/HmrServer.js.flow +2 -2
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +0 -2
- package/src/ModuleGraph/node-haste/node-haste.js +1 -0
- package/src/ModuleGraph/node-haste/node-haste.js.flow +4 -2
- package/src/ModuleGraph/output/indexed-ram-bundle.js +7 -3
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +7 -2
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +7 -3
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +7 -2
- package/src/ModuleGraph/output/plain-bundle.js +3 -1
- package/src/ModuleGraph/output/plain-bundle.js.flow +2 -0
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +34 -10
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +30 -14
- package/src/ModuleGraph/output/util.js +57 -24
- package/src/ModuleGraph/output/util.js.flow +66 -24
- package/src/ModuleGraph/test-helpers.js +74 -2
- package/src/ModuleGraph/types.flow.js.flow +14 -8
- package/src/ModuleGraph/worker/JsFileWrapping.js +95 -16
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +38 -23
- package/src/ModuleGraph/worker/collectDependencies.js +321 -207
- package/src/ModuleGraph/worker/collectDependencies.js.flow +397 -209
- package/src/ModuleGraph/worker/generate.js.flow +2 -2
- package/src/ModuleGraph/worker/generateImportNames.js +1 -0
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -4
- package/src/Server.js +5 -0
- package/src/Server.js.flow +8 -0
- package/src/cli.js +0 -0
- package/src/commands/build.js +1 -0
- package/src/commands/build.js.flow +2 -0
- package/src/commands/serve.js +19 -6
- package/src/commands/serve.js.flow +17 -5
- package/src/index.js +33 -16
- package/src/index.js.flow +32 -18
- package/src/integration_tests/metro.config.js +2 -2
- package/src/lib/TerminalReporter.js +24 -30
- package/src/lib/TerminalReporter.js.flow +24 -30
- package/src/lib/bundleToBytecode.js.flow +4 -1
- package/src/lib/bundleToString.js.flow +4 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -2
- package/src/lib/getPreludeCode.js.flow +3 -0
- package/src/lib/getPrependedScripts.js +6 -3
- package/src/lib/getPrependedScripts.js.flow +16 -3
- package/src/lib/transformHelpers.js +3 -3
- package/src/lib/transformHelpers.js.flow +4 -4
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -1
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +6 -5
- package/src/node-haste/DependencyGraph.js +37 -5
- package/src/node-haste/DependencyGraph.js.flow +40 -2
- package/src/ModuleGraph/worker/optimizeDependencies.js +0 -122
- package/src/ModuleGraph/worker/optimizeDependencies.js.flow +0 -128
- package/src/lib/bundle-modules/HMRClient.js +0 -306
- package/src/lib/bundle-modules/HMRClient.js.flow +0 -206
- package/src/lib/bundle-modules/asyncRequire.js +0 -16
- package/src/lib/bundle-modules/asyncRequire.js.flow +0 -17
- package/src/lib/bundle-modules/types.flow.js +0 -10
- package/src/lib/bundle-modules/types.flow.js.flow +0 -110
- package/src/lib/getKeyFromFiles.js +0 -29
- package/src/lib/getKeyFromFiles.js.flow +0 -31
- package/src/lib/polyfills/require.js +0 -920
- package/src/lib/polyfills/require.js.flow +0 -930
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.60.0",
|
|
3
2
|
"name": "metro",
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"@babel/core": "^7.0.0",
|
|
18
18
|
"@babel/generator": "^7.5.0",
|
|
19
19
|
"@babel/parser": "^7.0.0",
|
|
20
|
-
"@babel/plugin-external-helpers": "^7.0.0",
|
|
21
20
|
"@babel/template": "^7.0.0",
|
|
22
21
|
"@babel/traverse": "^7.0.0",
|
|
23
22
|
"@babel/types": "^7.0.0",
|
|
@@ -30,29 +29,29 @@
|
|
|
30
29
|
"debug": "^2.2.0",
|
|
31
30
|
"denodeify": "^1.2.1",
|
|
32
31
|
"error-stack-parser": "^2.0.6",
|
|
33
|
-
"eventemitter3": "^3.0.0",
|
|
34
|
-
"fbjs": "^1.0.0",
|
|
35
32
|
"fs-extra": "^1.0.0",
|
|
36
33
|
"graceful-fs": "^4.1.3",
|
|
37
34
|
"image-size": "^0.6.0",
|
|
38
35
|
"invariant": "^2.2.4",
|
|
39
|
-
"jest-haste-map": "^26.
|
|
36
|
+
"jest-haste-map": "^26.5.2",
|
|
40
37
|
"jest-worker": "^26.0.0",
|
|
41
38
|
"lodash.throttle": "^4.1.1",
|
|
42
|
-
"metro-babel-register": "0.
|
|
43
|
-
"metro-babel-transformer": "0.
|
|
44
|
-
"metro-cache": "0.
|
|
45
|
-
"metro-
|
|
46
|
-
"metro-
|
|
47
|
-
"metro-
|
|
48
|
-
"metro-
|
|
49
|
-
"metro-
|
|
50
|
-
"metro-
|
|
51
|
-
"metro-
|
|
52
|
-
"metro-
|
|
53
|
-
"metro-
|
|
54
|
-
"metro-
|
|
55
|
-
"metro-
|
|
39
|
+
"metro-babel-register": "0.64.0",
|
|
40
|
+
"metro-babel-transformer": "0.64.0",
|
|
41
|
+
"metro-cache": "0.64.0",
|
|
42
|
+
"metro-cache-key": "0.64.0",
|
|
43
|
+
"metro-config": "0.64.0",
|
|
44
|
+
"metro-core": "0.64.0",
|
|
45
|
+
"metro-hermes-compiler": "0.64.0",
|
|
46
|
+
"metro-inspector-proxy": "0.64.0",
|
|
47
|
+
"metro-minify-uglify": "0.64.0",
|
|
48
|
+
"metro-react-native-babel-preset": "0.64.0",
|
|
49
|
+
"metro-resolver": "0.64.0",
|
|
50
|
+
"metro-runtime": "0.64.0",
|
|
51
|
+
"metro-source-map": "0.64.0",
|
|
52
|
+
"metro-symbolicate": "0.64.0",
|
|
53
|
+
"metro-transform-plugins": "0.64.0",
|
|
54
|
+
"metro-transform-worker": "0.64.0",
|
|
56
55
|
"mime-types": "^2.1.27",
|
|
57
56
|
"mkdirp": "^0.5.1",
|
|
58
57
|
"node-fetch": "^2.2.0",
|
|
@@ -70,9 +69,10 @@
|
|
|
70
69
|
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
|
|
71
70
|
"acorn": "^5.1.2",
|
|
72
71
|
"dedent": "^0.7.0",
|
|
73
|
-
"
|
|
74
|
-
"metro-
|
|
75
|
-
"metro-react-native-babel-
|
|
72
|
+
"jest-snapshot": "^26.5.2",
|
|
73
|
+
"metro-memory-fs": "0.64.0",
|
|
74
|
+
"metro-react-native-babel-preset": "0.64.0",
|
|
75
|
+
"metro-react-native-babel-transformer": "0.64.0",
|
|
76
76
|
"stack-trace": "^0.0.10"
|
|
77
77
|
},
|
|
78
78
|
"license": "MIT"
|
package/src/Bundler/util.js
CHANGED
|
@@ -78,18 +78,20 @@ function _arrayWithHoles(arr) {
|
|
|
78
78
|
if (Array.isArray(arr)) return arr;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const template = require("@babel/template").default;
|
|
82
|
-
|
|
83
81
|
const babelTypes = require("@babel/types");
|
|
84
82
|
|
|
85
83
|
const babylon = require("@babel/parser");
|
|
86
84
|
|
|
87
|
-
const
|
|
85
|
+
const nullthrows = require("nullthrows");
|
|
86
|
+
|
|
87
|
+
const template = require("@babel/template").default;
|
|
88
|
+
|
|
89
|
+
const assetPropertyBlockList = new Set(["files", "fileSystemLocation", "path"]);
|
|
88
90
|
|
|
89
91
|
function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
90
92
|
const properDescriptor = filterObject(
|
|
91
93
|
assetDescriptor,
|
|
92
|
-
|
|
94
|
+
assetPropertyBlockList
|
|
93
95
|
); // {...}
|
|
94
96
|
|
|
95
97
|
const descriptorAst = babylon.parseExpression(
|
|
@@ -97,7 +99,7 @@ function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
|
97
99
|
);
|
|
98
100
|
const t = babelTypes; // require('AssetRegistry').registerAsset({...})
|
|
99
101
|
|
|
100
|
-
const buildRequire = template(`
|
|
102
|
+
const buildRequire = template.statement(`
|
|
101
103
|
module.exports = require(ASSET_REGISTRY_PATH).registerAsset(DESCRIPTOR_AST)
|
|
102
104
|
`);
|
|
103
105
|
return t.file(
|
|
@@ -138,9 +140,9 @@ function generateRemoteAssetCodeFileAst(
|
|
|
138
140
|
|
|
139
141
|
const URI = t.stringLiteral(remoteServer); // Size numbers.
|
|
140
142
|
|
|
141
|
-
const WIDTH = t.numericLiteral(assetDescriptor.width);
|
|
142
|
-
const HEIGHT = t.numericLiteral(assetDescriptor.height);
|
|
143
|
-
const buildRequire = template(`
|
|
143
|
+
const WIDTH = t.numericLiteral(nullthrows(assetDescriptor.width));
|
|
144
|
+
const HEIGHT = t.numericLiteral(nullthrows(assetDescriptor.height));
|
|
145
|
+
const buildRequire = template.statement(`
|
|
144
146
|
module.exports = {
|
|
145
147
|
"width": WIDTH,
|
|
146
148
|
"height": HEIGHT,
|
|
@@ -175,10 +177,10 @@ function isAssetTypeAnImage(type) {
|
|
|
175
177
|
);
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
function filterObject(object,
|
|
180
|
+
function filterObject(object, blockList) {
|
|
179
181
|
const copied = Object.assign({}, object);
|
|
180
182
|
|
|
181
|
-
for (const key of
|
|
183
|
+
for (const key of blockList) {
|
|
182
184
|
delete copied[key];
|
|
183
185
|
}
|
|
184
186
|
|
package/src/Bundler/util.js.flow
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const template = require('@babel/template').default;
|
|
14
13
|
const babelTypes = require('@babel/types');
|
|
15
14
|
const babylon = require('@babel/parser');
|
|
15
|
+
const nullthrows = require('nullthrows');
|
|
16
|
+
const template = require('@babel/template').default;
|
|
16
17
|
|
|
17
18
|
import type {AssetDataFiltered, AssetDataWithoutFiles} from '../Assets';
|
|
18
19
|
import type {ModuleTransportLike} from '../shared/types.flow';
|
|
19
|
-
import type {
|
|
20
|
+
import type {File} from '@babel/types';
|
|
20
21
|
|
|
21
22
|
// Structure of the object: dir.name.scale = asset
|
|
22
23
|
export type RemoteFileMap = {
|
|
@@ -47,15 +48,15 @@ type SubTree<T: ModuleTransportLike> = (
|
|
|
47
48
|
moduleTransportsByPath: Map<string, T>,
|
|
48
49
|
) => Iterable<number>;
|
|
49
50
|
|
|
50
|
-
const
|
|
51
|
+
const assetPropertyBlockList = new Set(['files', 'fileSystemLocation', 'path']);
|
|
51
52
|
|
|
52
53
|
function generateAssetCodeFileAst(
|
|
53
54
|
assetRegistryPath: string,
|
|
54
55
|
assetDescriptor: AssetDataWithoutFiles,
|
|
55
|
-
):
|
|
56
|
+
): File {
|
|
56
57
|
const properDescriptor = filterObject(
|
|
57
58
|
assetDescriptor,
|
|
58
|
-
|
|
59
|
+
assetPropertyBlockList,
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
// {...}
|
|
@@ -65,7 +66,7 @@ function generateAssetCodeFileAst(
|
|
|
65
66
|
const t = babelTypes;
|
|
66
67
|
|
|
67
68
|
// require('AssetRegistry').registerAsset({...})
|
|
68
|
-
const buildRequire = template(`
|
|
69
|
+
const buildRequire = template.statement(`
|
|
69
70
|
module.exports = require(ASSET_REGISTRY_PATH).registerAsset(DESCRIPTOR_AST)
|
|
70
71
|
`);
|
|
71
72
|
|
|
@@ -89,7 +90,7 @@ function generateRemoteAssetCodeFileAst(
|
|
|
89
90
|
assetDescriptor: AssetDataWithoutFiles,
|
|
90
91
|
remoteServer: string,
|
|
91
92
|
remoteFileMap: RemoteFileMap,
|
|
92
|
-
): ?
|
|
93
|
+
): ?File {
|
|
93
94
|
const t = babelTypes;
|
|
94
95
|
|
|
95
96
|
const file = remoteFileMap[assetDescriptor.fileSystemLocation];
|
|
@@ -111,10 +112,10 @@ function generateRemoteAssetCodeFileAst(
|
|
|
111
112
|
const URI = t.stringLiteral(remoteServer);
|
|
112
113
|
|
|
113
114
|
// Size numbers.
|
|
114
|
-
const WIDTH = t.numericLiteral(assetDescriptor.width);
|
|
115
|
-
const HEIGHT = t.numericLiteral(assetDescriptor.height);
|
|
115
|
+
const WIDTH = t.numericLiteral(nullthrows(assetDescriptor.width));
|
|
116
|
+
const HEIGHT = t.numericLiteral(nullthrows(assetDescriptor.height));
|
|
116
117
|
|
|
117
|
-
const buildRequire = template(`
|
|
118
|
+
const buildRequire = template.statement(`
|
|
118
119
|
module.exports = {
|
|
119
120
|
"width": WIDTH,
|
|
120
121
|
"height": HEIGHT,
|
|
@@ -153,10 +154,10 @@ function isAssetTypeAnImage(type: string): boolean {
|
|
|
153
154
|
|
|
154
155
|
function filterObject(
|
|
155
156
|
object: AssetDataWithoutFiles,
|
|
156
|
-
|
|
157
|
+
blockList: Set<string>,
|
|
157
158
|
): AssetDataFiltered {
|
|
158
159
|
const copied = Object.assign({}, object);
|
|
159
|
-
for (const key of
|
|
160
|
+
for (const key of blockList) {
|
|
160
161
|
delete copied[key];
|
|
161
162
|
}
|
|
162
163
|
return copied;
|
|
@@ -16,13 +16,13 @@ const processBytecodeModules = require('./helpers/processBytecodeModules');
|
|
|
16
16
|
const {getJsOutput} = require('./helpers/js');
|
|
17
17
|
const {compile} = require('metro-hermes-compiler');
|
|
18
18
|
|
|
19
|
-
import type {BytecodeBundle} from '../../lib/bundle-modules/types.flow';
|
|
20
19
|
import type {
|
|
21
20
|
Graph,
|
|
22
21
|
MixedOutput,
|
|
23
22
|
Module,
|
|
24
23
|
SerializerOptions,
|
|
25
24
|
} from '../types.flow';
|
|
25
|
+
import type {BytecodeBundle} from 'metro-runtime/src/modules/types.flow';
|
|
26
26
|
|
|
27
27
|
function baseBytecodeBundle(
|
|
28
28
|
entryPoint: string,
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
const getAppendScripts = require('../../lib/getAppendScripts');
|
|
14
14
|
const processModules = require('./helpers/processModules');
|
|
15
15
|
|
|
16
|
-
import type {Bundle} from '../../lib/bundle-modules/types.flow';
|
|
17
16
|
import type {
|
|
18
17
|
Graph,
|
|
19
18
|
MixedOutput,
|
|
20
19
|
Module,
|
|
21
20
|
SerializerOptions,
|
|
22
21
|
} from '../types.flow';
|
|
22
|
+
import type {Bundle} from 'metro-runtime/src/modules/types.flow';
|
|
23
23
|
|
|
24
24
|
function baseJSBundle(
|
|
25
25
|
entryPoint: string,
|
|
@@ -17,8 +17,8 @@ const {isJsModule, wrapModule} = require('./helpers/js');
|
|
|
17
17
|
const {addParamsToDefineCall} = require('metro-transform-plugins');
|
|
18
18
|
|
|
19
19
|
import type {EntryPointURL} from '../../HmrServer';
|
|
20
|
-
import type {HmrModule} from '../../lib/bundle-modules/types.flow';
|
|
21
20
|
import type {DeltaResult, Graph, Module} from '../types.flow';
|
|
21
|
+
import type {HmrModule} from 'metro-runtime/src/modules/types.flow';
|
|
22
22
|
|
|
23
23
|
type Options = {
|
|
24
24
|
+clientUrl: EntryPointURL,
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
ModuleMap,
|
|
15
|
+
DeltaBundle,
|
|
16
|
+
} from 'metro-runtime/src/modules/types.flow';
|
|
14
17
|
|
|
15
18
|
function computeDelta(entries1: ModuleMap, entries2: ModuleMap): DeltaBundle {
|
|
16
19
|
const modules1 = new Map(entries1);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
const crypto = require("crypto");
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const getCacheKey = require("metro-cache-key");
|
|
15
15
|
|
|
16
16
|
const path = require("path");
|
|
17
17
|
|
|
@@ -39,8 +39,9 @@ function getTransformCacheKey(opts) {
|
|
|
39
39
|
VERSION,
|
|
40
40
|
opts.cacheVersion,
|
|
41
41
|
path.relative(path.join(__dirname, "../../.."), opts.projectRoot),
|
|
42
|
-
|
|
43
|
-
transformerKey
|
|
42
|
+
getCacheKey([require.resolve(transformerPath)]),
|
|
43
|
+
transformerKey,
|
|
44
|
+
transformerConfig.globalPrefix
|
|
44
45
|
].join("$")
|
|
45
46
|
)
|
|
46
47
|
.digest("hex");
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
const crypto = require('crypto');
|
|
14
|
-
const
|
|
14
|
+
const getCacheKey = require('metro-cache-key');
|
|
15
15
|
const path = require('path');
|
|
16
16
|
|
|
17
17
|
const VERSION = require('../../package.json').version;
|
|
@@ -47,8 +47,9 @@ function getTransformCacheKey(opts: {|
|
|
|
47
47
|
VERSION,
|
|
48
48
|
opts.cacheVersion,
|
|
49
49
|
path.relative(path.join(__dirname, '../../..'), opts.projectRoot),
|
|
50
|
-
|
|
50
|
+
getCacheKey([require.resolve(transformerPath)]),
|
|
51
51
|
transformerKey,
|
|
52
|
+
transformerConfig.globalPrefix,
|
|
52
53
|
].join('$'),
|
|
53
54
|
)
|
|
54
55
|
.digest('hex');
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import type {DeltaBundle} from '
|
|
13
|
+
import type {DeltaBundle} from 'metro-runtime/src/modules/types.flow';
|
|
14
14
|
|
|
15
15
|
function mergeDeltas(delta1: DeltaBundle, delta2: DeltaBundle): DeltaBundle {
|
|
16
16
|
const added1 = new Map(delta1.added);
|
package/src/HmrServer.js.flow
CHANGED
|
@@ -30,13 +30,13 @@ const {
|
|
|
30
30
|
const {VERSION: BYTECODE_VERSION} = require('metro-hermes-compiler');
|
|
31
31
|
|
|
32
32
|
import type {RevisionId} from './IncrementalBundler';
|
|
33
|
+
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
33
34
|
import type {
|
|
34
35
|
HmrMessage,
|
|
35
36
|
HmrClientMessage,
|
|
36
37
|
HmrUpdateMessage,
|
|
37
38
|
HmrErrorMessage,
|
|
38
|
-
} from '
|
|
39
|
-
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
39
|
+
} from 'metro-runtime/src/modules/types.flow';
|
|
40
40
|
|
|
41
41
|
type $ReturnType<F> = $Call<<A, R>((...A) => R) => R, F>;
|
|
42
42
|
export type EntryPointURL = $ReturnType<typeof url.parse>;
|
|
@@ -63,10 +63,8 @@ type HasteMapOptions = {|
|
|
|
63
63
|
preferNativePlatform: true,
|
|
64
64
|
|};
|
|
65
65
|
|
|
66
|
-
/* eslint-disable flowtype/object-type-delimiter */
|
|
67
66
|
declare class HasteMap {
|
|
68
67
|
// node-haste/DependencyGraph/HasteMap.js
|
|
69
68
|
build(): Promise<Object>;
|
|
70
69
|
constructor(options: HasteMapOptions): void;
|
|
71
70
|
}
|
|
72
|
-
/* eslint-enable flowtype/object-type-delimiter */
|
|
@@ -29,14 +29,15 @@ import type {Extensions, Path} from './node-haste.flow';
|
|
|
29
29
|
import type {CustomResolver} from 'metro-resolver';
|
|
30
30
|
|
|
31
31
|
type ResolveOptions = {|
|
|
32
|
+
+platform: string,
|
|
33
|
+
+sourceExts: Extensions,
|
|
32
34
|
assetExts: Extensions,
|
|
33
35
|
assetResolutions: $ReadOnlyArray<string>,
|
|
34
36
|
extraNodeModules: {[id: string]: string, ...},
|
|
35
37
|
mainFields: $ReadOnlyArray<string>,
|
|
38
|
+
nodeModulesPaths: $ReadOnlyArray<string>,
|
|
36
39
|
resolveRequest?: ?CustomResolver,
|
|
37
|
-
+sourceExts: Extensions,
|
|
38
40
|
transformedFiles: {[path: Path]: TransformedCodeFile, ...},
|
|
39
|
-
+platform: string,
|
|
40
41
|
|};
|
|
41
42
|
|
|
42
43
|
const platforms = new Set(defaults.platforms);
|
|
@@ -147,6 +148,7 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
|
|
|
147
148
|
mocks: new Map(),
|
|
148
149
|
rootDir: '',
|
|
149
150
|
}),
|
|
151
|
+
nodeModulesPaths: options.nodeModulesPaths,
|
|
150
152
|
preferNativePlatform: true,
|
|
151
153
|
projectRoot: '',
|
|
152
154
|
resolveAsset: (
|
|
@@ -175,6 +175,7 @@ const _require3 = require("./util"),
|
|
|
175
175
|
function asIndexedRamBundle(_ref) {
|
|
176
176
|
let dependencyMapReservedName = _ref.dependencyMapReservedName,
|
|
177
177
|
filename = _ref.filename,
|
|
178
|
+
globalPrefix = _ref.globalPrefix,
|
|
178
179
|
idsForPath = _ref.idsForPath,
|
|
179
180
|
modules = _ref.modules,
|
|
180
181
|
preloadedModules = _ref.preloadedModules,
|
|
@@ -194,7 +195,8 @@ function asIndexedRamBundle(_ref) {
|
|
|
194
195
|
);
|
|
195
196
|
const deferredModules = deferred.map(m =>
|
|
196
197
|
toModuleTransport(m, idsForPath, {
|
|
197
|
-
dependencyMapReservedName
|
|
198
|
+
dependencyMapReservedName,
|
|
199
|
+
globalPrefix
|
|
198
200
|
})
|
|
199
201
|
);
|
|
200
202
|
|
|
@@ -218,7 +220,8 @@ function asIndexedRamBundle(_ref) {
|
|
|
218
220
|
m =>
|
|
219
221
|
getModuleCodeAndMap(m, idForPath, {
|
|
220
222
|
dependencyMapReservedName,
|
|
221
|
-
enableIDInlining: true
|
|
223
|
+
enableIDInlining: true,
|
|
224
|
+
globalPrefix
|
|
222
225
|
}).moduleCode
|
|
223
226
|
)
|
|
224
227
|
.join("\n"),
|
|
@@ -234,7 +237,8 @@ function asIndexedRamBundle(_ref) {
|
|
|
234
237
|
moduleGroups,
|
|
235
238
|
startupModules: startupModules.map(m =>
|
|
236
239
|
toModuleTransport(m, idsForPath, {
|
|
237
|
-
dependencyMapReservedName
|
|
240
|
+
dependencyMapReservedName,
|
|
241
|
+
globalPrefix
|
|
238
242
|
})
|
|
239
243
|
)
|
|
240
244
|
})
|
|
@@ -26,6 +26,7 @@ import type {IndexMap} from 'metro-source-map';
|
|
|
26
26
|
function asIndexedRamBundle({
|
|
27
27
|
dependencyMapReservedName,
|
|
28
28
|
filename,
|
|
29
|
+
globalPrefix,
|
|
29
30
|
idsForPath,
|
|
30
31
|
modules,
|
|
31
32
|
preloadedModules,
|
|
@@ -40,7 +41,7 @@ function asIndexedRamBundle({
|
|
|
40
41
|
const [startup, deferred] = partition(modules, preloadedModules);
|
|
41
42
|
const startupModules = [...startup, ...requireCalls];
|
|
42
43
|
const deferredModules = deferred.map((m: Module) =>
|
|
43
|
-
toModuleTransport(m, idsForPath, {dependencyMapReservedName}),
|
|
44
|
+
toModuleTransport(m, idsForPath, {dependencyMapReservedName, globalPrefix}),
|
|
44
45
|
);
|
|
45
46
|
for (const m of deferredModules) {
|
|
46
47
|
invariant(
|
|
@@ -63,6 +64,7 @@ function asIndexedRamBundle({
|
|
|
63
64
|
getModuleCodeAndMap(m, idForPath, {
|
|
64
65
|
dependencyMapReservedName,
|
|
65
66
|
enableIDInlining: true,
|
|
67
|
+
globalPrefix,
|
|
66
68
|
}).moduleCode,
|
|
67
69
|
)
|
|
68
70
|
.join('\n'),
|
|
@@ -78,7 +80,10 @@ function asIndexedRamBundle({
|
|
|
78
80
|
lazyModules: deferredModules,
|
|
79
81
|
moduleGroups,
|
|
80
82
|
startupModules: startupModules.map((m: Module) =>
|
|
81
|
-
toModuleTransport(m, idsForPath, {
|
|
83
|
+
toModuleTransport(m, idsForPath, {
|
|
84
|
+
dependencyMapReservedName,
|
|
85
|
+
globalPrefix,
|
|
86
|
+
}),
|
|
82
87
|
),
|
|
83
88
|
}),
|
|
84
89
|
};
|
|
@@ -173,6 +173,7 @@ const _require = require("./util"),
|
|
|
173
173
|
function asMultipleFilesRamBundle(_ref) {
|
|
174
174
|
let dependencyMapReservedName = _ref.dependencyMapReservedName,
|
|
175
175
|
filename = _ref.filename,
|
|
176
|
+
globalPrefix = _ref.globalPrefix,
|
|
176
177
|
idsForPath = _ref.idsForPath,
|
|
177
178
|
modules = _ref.modules,
|
|
178
179
|
requireCalls = _ref.requireCalls,
|
|
@@ -191,7 +192,8 @@ function asMultipleFilesRamBundle(_ref) {
|
|
|
191
192
|
);
|
|
192
193
|
const deferredModules = deferred.map(m =>
|
|
193
194
|
toModuleTransport(m, idsForPath, {
|
|
194
|
-
dependencyMapReservedName
|
|
195
|
+
dependencyMapReservedName,
|
|
196
|
+
globalPrefix
|
|
195
197
|
})
|
|
196
198
|
);
|
|
197
199
|
const magicFileContents = Buffer.alloc(4); // Just concatenate all startup modules, one after the other.
|
|
@@ -201,7 +203,8 @@ function asMultipleFilesRamBundle(_ref) {
|
|
|
201
203
|
m =>
|
|
202
204
|
getModuleCodeAndMap(m, idForPath, {
|
|
203
205
|
dependencyMapReservedName,
|
|
204
|
-
enableIDInlining: true
|
|
206
|
+
enableIDInlining: true,
|
|
207
|
+
globalPrefix
|
|
205
208
|
}).moduleCode
|
|
206
209
|
)
|
|
207
210
|
.join("\n"); // Write one file per module, wrapped with __d() call if it proceeds.
|
|
@@ -226,7 +229,8 @@ function asMultipleFilesRamBundle(_ref) {
|
|
|
226
229
|
moduleGroups: null,
|
|
227
230
|
startupModules: startupModules.map(m =>
|
|
228
231
|
toModuleTransport(m, idsForPath, {
|
|
229
|
-
dependencyMapReservedName
|
|
232
|
+
dependencyMapReservedName,
|
|
233
|
+
globalPrefix
|
|
230
234
|
})
|
|
231
235
|
)
|
|
232
236
|
});
|
|
@@ -25,6 +25,7 @@ import type {Module, OutputFn, OutputFnArg, OutputResult} from '../types.flow';
|
|
|
25
25
|
function asMultipleFilesRamBundle({
|
|
26
26
|
dependencyMapReservedName,
|
|
27
27
|
filename,
|
|
28
|
+
globalPrefix,
|
|
28
29
|
idsForPath,
|
|
29
30
|
modules,
|
|
30
31
|
requireCalls,
|
|
@@ -34,7 +35,7 @@ function asMultipleFilesRamBundle({
|
|
|
34
35
|
const [startup, deferred] = partition(modules, preloadedModules);
|
|
35
36
|
const startupModules = [...startup, ...requireCalls];
|
|
36
37
|
const deferredModules = deferred.map((m: Module) =>
|
|
37
|
-
toModuleTransport(m, idsForPath, {dependencyMapReservedName}),
|
|
38
|
+
toModuleTransport(m, idsForPath, {dependencyMapReservedName, globalPrefix}),
|
|
38
39
|
);
|
|
39
40
|
const magicFileContents = Buffer.alloc(4);
|
|
40
41
|
|
|
@@ -45,6 +46,7 @@ function asMultipleFilesRamBundle({
|
|
|
45
46
|
getModuleCodeAndMap(m, idForPath, {
|
|
46
47
|
dependencyMapReservedName,
|
|
47
48
|
enableIDInlining: true,
|
|
49
|
+
globalPrefix,
|
|
48
50
|
}).moduleCode,
|
|
49
51
|
)
|
|
50
52
|
.join('\n');
|
|
@@ -71,7 +73,10 @@ function asMultipleFilesRamBundle({
|
|
|
71
73
|
lazyModules: deferredModules,
|
|
72
74
|
moduleGroups: null,
|
|
73
75
|
startupModules: startupModules.map((m: Module) =>
|
|
74
|
-
toModuleTransport(m, idsForPath, {
|
|
76
|
+
toModuleTransport(m, idsForPath, {
|
|
77
|
+
dependencyMapReservedName,
|
|
78
|
+
globalPrefix,
|
|
79
|
+
}),
|
|
75
80
|
),
|
|
76
81
|
});
|
|
77
82
|
|
|
@@ -21,6 +21,7 @@ const _require2 = require("metro-source-map"),
|
|
|
21
21
|
function asPlainBundle(_ref) {
|
|
22
22
|
let dependencyMapReservedName = _ref.dependencyMapReservedName,
|
|
23
23
|
filename = _ref.filename,
|
|
24
|
+
globalPrefix = _ref.globalPrefix,
|
|
24
25
|
idsForPath = _ref.idsForPath,
|
|
25
26
|
modules = _ref.modules,
|
|
26
27
|
requireCalls = _ref.requireCalls,
|
|
@@ -33,7 +34,8 @@ function asPlainBundle(_ref) {
|
|
|
33
34
|
for (const module of concat(modules, requireCalls)) {
|
|
34
35
|
const _getModuleCodeAndMap = getModuleCodeAndMap(module, modIdForPath, {
|
|
35
36
|
dependencyMapReservedName,
|
|
36
|
-
enableIDInlining
|
|
37
|
+
enableIDInlining,
|
|
38
|
+
globalPrefix
|
|
37
39
|
}),
|
|
38
40
|
moduleCode = _getModuleCodeAndMap.moduleCode,
|
|
39
41
|
moduleMap = _getModuleCodeAndMap.moduleMap;
|
|
@@ -21,6 +21,7 @@ import type {MixedSourceMap} from 'metro-source-map';
|
|
|
21
21
|
function asPlainBundle({
|
|
22
22
|
dependencyMapReservedName,
|
|
23
23
|
filename,
|
|
24
|
+
globalPrefix,
|
|
24
25
|
idsForPath,
|
|
25
26
|
modules,
|
|
26
27
|
requireCalls,
|
|
@@ -38,6 +39,7 @@ function asPlainBundle({
|
|
|
38
39
|
const {moduleCode, moduleMap} = getModuleCodeAndMap(module, modIdForPath, {
|
|
39
40
|
dependencyMapReservedName,
|
|
40
41
|
enableIDInlining,
|
|
42
|
+
globalPrefix,
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
builder.append(moduleCode + '\n', moduleMap);
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
13
|
+
|
|
14
|
+
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) {
|
|
17
|
+
return obj && obj.__esModule
|
|
18
|
+
? obj
|
|
19
|
+
: {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
function reverseDependencyMapReferences(_ref) {
|
|
13
25
|
let t = _ref.types;
|
|
14
26
|
return {
|
|
@@ -16,29 +28,41 @@ function reverseDependencyMapReferences(_ref) {
|
|
|
16
28
|
CallExpression(path, state) {
|
|
17
29
|
const node = path.node;
|
|
18
30
|
|
|
19
|
-
if (node.callee.name ===
|
|
20
|
-
|
|
31
|
+
if (node.callee.name === `${state.opts.globalPrefix}__d`) {
|
|
32
|
+
// $FlowFixMe Flow error uncovered by typing Babel more strictly
|
|
33
|
+
const lastArg = node.arguments[0].params.slice(-1)[0]; // $FlowFixMe Flow error uncovered by typing Babel more strictly
|
|
34
|
+
|
|
21
35
|
const depMapName = lastArg && lastArg.name;
|
|
22
36
|
|
|
23
|
-
if (
|
|
37
|
+
if (depMapName == null) {
|
|
24
38
|
return;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
|
-
const
|
|
28
|
-
|
|
41
|
+
const body = path.get("arguments.0.body");
|
|
42
|
+
(0, _invariant.default)(
|
|
43
|
+
!Array.isArray(body),
|
|
44
|
+
"meetro: Expected `body` to be a single path."
|
|
45
|
+
);
|
|
46
|
+
const scope = body.scope;
|
|
47
|
+
const binding = (0, _nullthrows.default)(
|
|
48
|
+
scope.getBinding(depMapName)
|
|
49
|
+
);
|
|
29
50
|
binding.referencePaths.forEach(_ref2 => {
|
|
30
51
|
let parentPath = _ref2.parentPath;
|
|
31
|
-
const memberNode =
|
|
52
|
+
const memberNode =
|
|
53
|
+
parentPath === null || parentPath === void 0
|
|
54
|
+
? void 0
|
|
55
|
+
: parentPath.node;
|
|
32
56
|
|
|
33
57
|
if (
|
|
58
|
+
memberNode != null &&
|
|
34
59
|
memberNode.type === "MemberExpression" &&
|
|
35
60
|
memberNode.property.type === "NumericLiteral"
|
|
36
61
|
) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
state.opts.dependencyIds[memberNode.property.value]
|
|
40
|
-
)
|
|
62
|
+
const numericLiteral = t.numericLiteral(
|
|
63
|
+
state.opts.dependencyIds[memberNode.property.value]
|
|
41
64
|
);
|
|
65
|
+
(0, _nullthrows.default)(parentPath).replaceWith(numericLiteral);
|
|
42
66
|
}
|
|
43
67
|
});
|
|
44
68
|
}
|