metro 0.83.3 → 0.84.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 +28 -25
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.js +139 -39
- package/src/Server.js.flow +158 -47
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.flow.js +30 -26
- package/src/index.flow.js.flow +25 -20
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +31 -27
- package/src/lib/TerminalReporter.js.flow +15 -15
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/lib/AssetPaths.js +2 -2
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/Bundler.d.ts +0 -39
- package/src/DeltaBundler/Graph.d.ts +0 -40
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/src/DeltaBundler/Worker.d.ts +0 -45
- package/src/DeltaBundler/types.d.ts +0 -166
- package/src/DeltaBundler.d.ts +0 -58
- package/src/IncrementalBundler.d.ts +0 -98
- package/src/ModuleGraph/test-helpers.js +0 -75
- package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/src/Server/MultipartResponse.d.ts +0 -31
- package/src/Server/symbolicate.d.ts +0 -31
- package/src/Server.d.ts +0 -118
- package/src/index.d.ts +0 -193
- package/src/lib/CountingSet.d.ts +0 -48
- package/src/lib/TerminalReporter.d.ts +0 -27
- package/src/lib/contextModule.d.ts +0 -22
- package/src/lib/getGraphId.d.ts +0 -11
- package/src/lib/reporting.d.ts +0 -144
- package/src/node-haste/DependencyGraph.d.ts +0 -62
- package/src/shared/output/bundle.d.ts +0 -35
- package/src/shared/types.d.ts +0 -130
|
@@ -11,28 +11,32 @@ var transformHelpers = _interopRequireWildcard(require("./transformHelpers"));
|
|
|
11
11
|
var defaults = _interopRequireWildcard(
|
|
12
12
|
require("metro-config/private/defaults/defaults"),
|
|
13
13
|
);
|
|
14
|
-
function
|
|
15
|
-
if ("function"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var n = { __proto__: null },
|
|
29
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
|
-
for (var u in e)
|
|
31
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
32
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
33
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
14
|
+
function _interopRequireWildcard(e, t) {
|
|
15
|
+
if ("function" == typeof WeakMap)
|
|
16
|
+
var r = new WeakMap(),
|
|
17
|
+
n = new WeakMap();
|
|
18
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
19
|
+
if (!t && e && e.__esModule) return e;
|
|
20
|
+
var o,
|
|
21
|
+
i,
|
|
22
|
+
f = { __proto__: null, default: e };
|
|
23
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
24
|
+
return f;
|
|
25
|
+
if ((o = t ? n : r)) {
|
|
26
|
+
if (o.has(e)) return o.get(e);
|
|
27
|
+
o.set(e, f);
|
|
34
28
|
}
|
|
35
|
-
|
|
29
|
+
for (const t in e)
|
|
30
|
+
"default" !== t &&
|
|
31
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
32
|
+
((i =
|
|
33
|
+
(o = Object.defineProperty) &&
|
|
34
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
35
|
+
(i.get || i.set)
|
|
36
|
+
? o(f, t, i)
|
|
37
|
+
: (f[t] = e[t]));
|
|
38
|
+
return f;
|
|
39
|
+
})(e, t);
|
|
36
40
|
}
|
|
37
41
|
function _interopRequireDefault(e) {
|
|
38
42
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -76,6 +80,8 @@ async function getPrependedScripts(
|
|
|
76
80
|
lazy: false,
|
|
77
81
|
unstable_enablePackageExports:
|
|
78
82
|
config.resolver.unstable_enablePackageExports,
|
|
83
|
+
unstable_incrementalResolution:
|
|
84
|
+
config.resolver.unstable_incrementalResolution,
|
|
79
85
|
shallow: false,
|
|
80
86
|
},
|
|
81
87
|
);
|
|
@@ -84,15 +90,23 @@ async function getPrependedScripts(
|
|
|
84
90
|
dev: options.dev,
|
|
85
91
|
globalPrefix: config.transformer.globalPrefix,
|
|
86
92
|
requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
|
|
93
|
+
unstable_forceFullRefreshPatterns:
|
|
94
|
+
config.resolver.unstable_forceFullRefreshPatterns,
|
|
87
95
|
}),
|
|
88
96
|
...dependencies.values(),
|
|
89
97
|
];
|
|
90
98
|
}
|
|
91
|
-
function _getPrelude({
|
|
99
|
+
function _getPrelude({
|
|
100
|
+
dev,
|
|
101
|
+
globalPrefix,
|
|
102
|
+
requireCycleIgnorePatterns,
|
|
103
|
+
unstable_forceFullRefreshPatterns,
|
|
104
|
+
}) {
|
|
92
105
|
const code = (0, _getPreludeCode.default)({
|
|
93
106
|
isDev: dev,
|
|
94
107
|
globalPrefix,
|
|
95
108
|
requireCycleIgnorePatterns,
|
|
109
|
+
unstable_forceFullRefreshPatterns,
|
|
96
110
|
});
|
|
97
111
|
const name = "__prelude__";
|
|
98
112
|
return {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type Bundler from '../Bundler';
|
|
13
|
-
import type
|
|
13
|
+
import type {Module, default as DeltaBundler} from '../DeltaBundler';
|
|
14
14
|
import type {TransformInputOptions} from '../DeltaBundler/types';
|
|
15
15
|
import type {ResolverInputOptions} from '../shared/types';
|
|
16
16
|
import type {ConfigT} from 'metro-config';
|
|
@@ -27,7 +27,7 @@ export default async function getPrependedScripts(
|
|
|
27
27
|
resolverOptions: ResolverInputOptions,
|
|
28
28
|
bundler: Bundler,
|
|
29
29
|
deltaBundler: DeltaBundler<>,
|
|
30
|
-
): Promise
|
|
30
|
+
): Promise<ReadonlyArray<Module<>>> {
|
|
31
31
|
// Get all the polyfills from the relevant option params (the
|
|
32
32
|
// `getPolyfills()` method and the `polyfillModuleNames` variable).
|
|
33
33
|
const polyfillModuleNames = config.serializer
|
|
@@ -64,6 +64,8 @@ export default async function getPrependedScripts(
|
|
|
64
64
|
lazy: false,
|
|
65
65
|
unstable_enablePackageExports:
|
|
66
66
|
config.resolver.unstable_enablePackageExports,
|
|
67
|
+
unstable_incrementalResolution:
|
|
68
|
+
config.resolver.unstable_incrementalResolution,
|
|
67
69
|
shallow: false,
|
|
68
70
|
},
|
|
69
71
|
);
|
|
@@ -73,6 +75,8 @@ export default async function getPrependedScripts(
|
|
|
73
75
|
dev: options.dev,
|
|
74
76
|
globalPrefix: config.transformer.globalPrefix,
|
|
75
77
|
requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
|
|
78
|
+
unstable_forceFullRefreshPatterns:
|
|
79
|
+
config.resolver.unstable_forceFullRefreshPatterns,
|
|
76
80
|
}),
|
|
77
81
|
...dependencies.values(),
|
|
78
82
|
];
|
|
@@ -82,16 +86,19 @@ function _getPrelude({
|
|
|
82
86
|
dev,
|
|
83
87
|
globalPrefix,
|
|
84
88
|
requireCycleIgnorePatterns,
|
|
89
|
+
unstable_forceFullRefreshPatterns,
|
|
85
90
|
}: {
|
|
86
91
|
dev: boolean,
|
|
87
92
|
globalPrefix: string,
|
|
88
|
-
requireCycleIgnorePatterns:
|
|
93
|
+
requireCycleIgnorePatterns: ReadonlyArray<RegExp>,
|
|
94
|
+
unstable_forceFullRefreshPatterns: ReadonlyArray<RegExp>,
|
|
89
95
|
...
|
|
90
96
|
}): Module<> {
|
|
91
97
|
const code = getPreludeCode({
|
|
92
98
|
isDev: dev,
|
|
93
99
|
globalPrefix,
|
|
94
100
|
requireCycleIgnorePatterns,
|
|
101
|
+
unstable_forceFullRefreshPatterns,
|
|
95
102
|
});
|
|
96
103
|
const name = '__prelude__';
|
|
97
104
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @format
|
|
8
7
|
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/* eslint-disable no-console */
|
|
@@ -18,7 +18,7 @@ import util from 'util';
|
|
|
18
18
|
const groupStack = [];
|
|
19
19
|
let collapsedGuardTimer;
|
|
20
20
|
|
|
21
|
-
export default (terminal: Terminal, level: string, ...data: Array<
|
|
21
|
+
export default (terminal: Terminal, level: string, ...data: Array<unknown>) => {
|
|
22
22
|
// $FlowFixMe[invalid-computed-prop]
|
|
23
23
|
const logFunction = console[level] && level !== 'trace' ? level : 'log';
|
|
24
24
|
const color =
|
|
@@ -16,28 +16,32 @@ var _parseCustomTransformOptions = _interopRequireDefault(
|
|
|
16
16
|
);
|
|
17
17
|
var jscSafeUrl = _interopRequireWildcard(require("jsc-safe-url"));
|
|
18
18
|
var _path = _interopRequireDefault(require("path"));
|
|
19
|
-
function
|
|
20
|
-
if ("function"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var n = { __proto__: null },
|
|
34
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
|
-
for (var u in e)
|
|
36
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
37
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
38
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
19
|
+
function _interopRequireWildcard(e, t) {
|
|
20
|
+
if ("function" == typeof WeakMap)
|
|
21
|
+
var r = new WeakMap(),
|
|
22
|
+
n = new WeakMap();
|
|
23
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
24
|
+
if (!t && e && e.__esModule) return e;
|
|
25
|
+
var o,
|
|
26
|
+
i,
|
|
27
|
+
f = { __proto__: null, default: e };
|
|
28
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
29
|
+
return f;
|
|
30
|
+
if ((o = t ? n : r)) {
|
|
31
|
+
if (o.has(e)) return o.get(e);
|
|
32
|
+
o.set(e, f);
|
|
39
33
|
}
|
|
40
|
-
|
|
34
|
+
for (const t in e)
|
|
35
|
+
"default" !== t &&
|
|
36
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
37
|
+
((i =
|
|
38
|
+
(o = Object.defineProperty) &&
|
|
39
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
40
|
+
(i.get || i.set)
|
|
41
|
+
? o(f, t, i)
|
|
42
|
+
: (f[t] = e[t]));
|
|
43
|
+
return f;
|
|
44
|
+
})(e, t);
|
|
41
45
|
}
|
|
42
46
|
function _interopRequireDefault(e) {
|
|
43
47
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type {CustomResolverOptions} from '
|
|
12
|
+
import type {CustomResolverOptions} from 'metro-resolver';
|
|
13
13
|
|
|
14
14
|
const PREFIX = 'resolver.';
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ export default function parseCustomResolverOptions(
|
|
|
18
18
|
): CustomResolverOptions {
|
|
19
19
|
const customResolverOptions: {
|
|
20
20
|
__proto__: null,
|
|
21
|
-
[string]:
|
|
21
|
+
[string]: unknown,
|
|
22
22
|
...
|
|
23
23
|
} = Object.create(null);
|
|
24
24
|
|
|
@@ -14,13 +14,23 @@ import type {IncomingMessage} from 'http';
|
|
|
14
14
|
const CONTENT_TYPE = 'application/json';
|
|
15
15
|
const SIZE_LIMIT = 100 * 1024 * 1024; // 100MB
|
|
16
16
|
|
|
17
|
+
export type JsonData =
|
|
18
|
+
| {
|
|
19
|
+
[string]: JsonData,
|
|
20
|
+
}
|
|
21
|
+
| Array<JsonData>
|
|
22
|
+
| string
|
|
23
|
+
| number
|
|
24
|
+
| boolean
|
|
25
|
+
| null;
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* Attempt to parse a request body as JSON.
|
|
19
29
|
*/
|
|
20
30
|
export default function parseJsonBody(
|
|
21
31
|
req: IncomingMessage,
|
|
22
32
|
options: {strict?: boolean} = {},
|
|
23
|
-
): Promise
|
|
33
|
+
): Promise<JsonData> {
|
|
24
34
|
const {strict = true} = options;
|
|
25
35
|
|
|
26
36
|
return new Promise((resolve, reject) => {
|
package/src/lib/pathUtils.js
CHANGED
|
@@ -5,28 +5,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.normalizePathSeparatorsToPosix = void 0;
|
|
7
7
|
var path = _interopRequireWildcard(require("path"));
|
|
8
|
-
function
|
|
9
|
-
if ("function"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var n = { __proto__: null },
|
|
23
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
24
|
-
for (var u in e)
|
|
25
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
26
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
27
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
8
|
+
function _interopRequireWildcard(e, t) {
|
|
9
|
+
if ("function" == typeof WeakMap)
|
|
10
|
+
var r = new WeakMap(),
|
|
11
|
+
n = new WeakMap();
|
|
12
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
13
|
+
if (!t && e && e.__esModule) return e;
|
|
14
|
+
var o,
|
|
15
|
+
i,
|
|
16
|
+
f = { __proto__: null, default: e };
|
|
17
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
18
|
+
return f;
|
|
19
|
+
if ((o = t ? n : r)) {
|
|
20
|
+
if (o.has(e)) return o.get(e);
|
|
21
|
+
o.set(e, f);
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
for (const t in e)
|
|
24
|
+
"default" !== t &&
|
|
25
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
26
|
+
((i =
|
|
27
|
+
(o = Object.defineProperty) &&
|
|
28
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
29
|
+
(i.get || i.set)
|
|
30
|
+
? o(f, t, i)
|
|
31
|
+
: (f[t] = e[t]));
|
|
32
|
+
return f;
|
|
33
|
+
})(e, t);
|
|
30
34
|
}
|
|
31
35
|
const normalizePathSeparatorsToPosix = (exports.normalizePathSeparatorsToPosix =
|
|
32
36
|
path.sep === "/"
|
|
@@ -126,7 +126,7 @@ export type ReportableEvent =
|
|
|
126
126
|
| 'groupCollapsed'
|
|
127
127
|
| 'groupEnd'
|
|
128
128
|
| 'debug',
|
|
129
|
-
data: Array<
|
|
129
|
+
data: Array<unknown>,
|
|
130
130
|
...
|
|
131
131
|
}
|
|
132
132
|
| {
|
|
@@ -187,7 +187,7 @@ export type Reporter = interface {update(event: ReportableEvent): void};
|
|
|
187
187
|
export function logWarning(
|
|
188
188
|
terminal: Terminal,
|
|
189
189
|
format: string,
|
|
190
|
-
...args: Array<
|
|
190
|
+
...args: Array<unknown>
|
|
191
191
|
): void {
|
|
192
192
|
const str = util.format(format, ...args);
|
|
193
193
|
terminal.log('%s %s', chalk.yellow.inverse.bold(' WARN '), str);
|
|
@@ -199,7 +199,7 @@ export function logWarning(
|
|
|
199
199
|
export function logError(
|
|
200
200
|
terminal: Terminal,
|
|
201
201
|
format: string,
|
|
202
|
-
...args: Array<
|
|
202
|
+
...args: Array<unknown>
|
|
203
203
|
): void {
|
|
204
204
|
terminal.log(
|
|
205
205
|
'%s %s',
|
|
@@ -221,7 +221,7 @@ export function logError(
|
|
|
221
221
|
export function logInfo(
|
|
222
222
|
terminal: Terminal,
|
|
223
223
|
format: string,
|
|
224
|
-
...args: Array<
|
|
224
|
+
...args: Array<unknown>
|
|
225
225
|
): void {
|
|
226
226
|
const str = util.format(format, ...args);
|
|
227
227
|
terminal.log('%s %s', chalk.cyan.inverse.bold(' INFO '), str);
|
|
@@ -31,8 +31,8 @@ async function calcTransformerOptions(
|
|
|
31
31
|
const baseOptions = {
|
|
32
32
|
customTransformOptions: options.customTransformOptions,
|
|
33
33
|
dev: options.dev,
|
|
34
|
-
inlineRequires: false,
|
|
35
34
|
inlinePlatform: true,
|
|
35
|
+
inlineRequires: false,
|
|
36
36
|
minify: options.minify,
|
|
37
37
|
platform: options.platform,
|
|
38
38
|
unstable_transformProfile: options.unstable_transformProfile,
|
|
@@ -45,11 +45,14 @@ async function calcTransformerOptions(
|
|
|
45
45
|
}
|
|
46
46
|
const getDependencies = async (path) => {
|
|
47
47
|
const dependencies = await deltaBundler.getDependencies([path], {
|
|
48
|
+
lazy: false,
|
|
49
|
+
onProgress: null,
|
|
48
50
|
resolve: await getResolveDependencyFn(
|
|
49
51
|
bundler,
|
|
50
52
|
options.platform,
|
|
51
53
|
resolverOptions,
|
|
52
54
|
),
|
|
55
|
+
shallow: false,
|
|
53
56
|
transform: await getTransformFn(
|
|
54
57
|
[path],
|
|
55
58
|
bundler,
|
|
@@ -62,13 +65,12 @@ async function calcTransformerOptions(
|
|
|
62
65
|
resolverOptions,
|
|
63
66
|
),
|
|
64
67
|
transformOptions: options,
|
|
65
|
-
onProgress: null,
|
|
66
|
-
lazy: false,
|
|
67
68
|
unstable_allowRequireContext:
|
|
68
69
|
config.transformer.unstable_allowRequireContext,
|
|
69
70
|
unstable_enablePackageExports:
|
|
70
71
|
config.resolver.unstable_enablePackageExports,
|
|
71
|
-
|
|
72
|
+
unstable_incrementalResolution:
|
|
73
|
+
config.resolver.unstable_incrementalResolution,
|
|
72
74
|
});
|
|
73
75
|
return Array.from(dependencies.keys());
|
|
74
76
|
};
|
|
@@ -83,15 +85,15 @@ async function calcTransformerOptions(
|
|
|
83
85
|
);
|
|
84
86
|
return {
|
|
85
87
|
...baseOptions,
|
|
86
|
-
inlineRequires: transform?.inlineRequires || false,
|
|
87
88
|
experimentalImportSupport: transform?.experimentalImportSupport || false,
|
|
89
|
+
inlineRequires: transform?.inlineRequires || false,
|
|
90
|
+
nonInlinedRequires:
|
|
91
|
+
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
92
|
+
type: "module",
|
|
88
93
|
unstable_memoizeInlineRequires:
|
|
89
94
|
transform?.unstable_memoizeInlineRequires || false,
|
|
90
95
|
unstable_nonMemoizedInlineRequires:
|
|
91
96
|
transform?.unstable_nonMemoizedInlineRequires || [],
|
|
92
|
-
nonInlinedRequires:
|
|
93
|
-
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
94
|
-
type: "module",
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
99
|
function removeInlineRequiresBlockListFromOptions(path, inlineRequires) {
|
|
@@ -138,11 +140,11 @@ async function getTransformFn(
|
|
|
138
140
|
modulePath,
|
|
139
141
|
{
|
|
140
142
|
...transformOptions,
|
|
141
|
-
type: getType(transformOptions.type, modulePath, assetExts),
|
|
142
143
|
inlineRequires: removeInlineRequiresBlockListFromOptions(
|
|
143
144
|
modulePath,
|
|
144
145
|
inlineRequires,
|
|
145
146
|
),
|
|
147
|
+
type: getType(transformOptions.type, modulePath, assetExts),
|
|
146
148
|
},
|
|
147
149
|
templateBuffer,
|
|
148
150
|
);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type Bundler from '../Bundler';
|
|
13
|
-
import type
|
|
13
|
+
import type {TransformFn, default as DeltaBundler} from '../DeltaBundler';
|
|
14
14
|
import type {
|
|
15
15
|
BundlerResolution,
|
|
16
16
|
TransformInputOptions,
|
|
@@ -26,10 +26,10 @@ import {getContextModuleTemplate} from './contextModuleTemplates';
|
|
|
26
26
|
import isAssetFile from 'metro-resolver/private/utils/isAssetFile';
|
|
27
27
|
|
|
28
28
|
type InlineRequiresRaw =
|
|
29
|
-
|
|
|
29
|
+
| Readonly<{blockList: Readonly<{[string]: true, ...}>, ...}>
|
|
30
30
|
| boolean;
|
|
31
31
|
|
|
32
|
-
type TransformOptionsWithRawInlines =
|
|
32
|
+
type TransformOptionsWithRawInlines = Readonly<{
|
|
33
33
|
...TransformOptions,
|
|
34
34
|
inlineRequires: InlineRequiresRaw,
|
|
35
35
|
}>;
|
|
@@ -44,7 +44,7 @@ const baseIgnoredInlineRequires = [
|
|
|
44
44
|
];
|
|
45
45
|
|
|
46
46
|
async function calcTransformerOptions(
|
|
47
|
-
entryFiles:
|
|
47
|
+
entryFiles: ReadonlyArray<string>,
|
|
48
48
|
bundler: Bundler,
|
|
49
49
|
deltaBundler: DeltaBundler<>,
|
|
50
50
|
config: ConfigT,
|
|
@@ -54,8 +54,8 @@ async function calcTransformerOptions(
|
|
|
54
54
|
const baseOptions = {
|
|
55
55
|
customTransformOptions: options.customTransformOptions,
|
|
56
56
|
dev: options.dev,
|
|
57
|
-
inlineRequires: false,
|
|
58
57
|
inlinePlatform: true,
|
|
58
|
+
inlineRequires: false,
|
|
59
59
|
minify: options.minify,
|
|
60
60
|
platform: options.platform,
|
|
61
61
|
unstable_transformProfile: options.unstable_transformProfile,
|
|
@@ -73,11 +73,14 @@ async function calcTransformerOptions(
|
|
|
73
73
|
|
|
74
74
|
const getDependencies = async (path: string) => {
|
|
75
75
|
const dependencies = await deltaBundler.getDependencies([path], {
|
|
76
|
+
lazy: false,
|
|
77
|
+
onProgress: null,
|
|
76
78
|
resolve: await getResolveDependencyFn(
|
|
77
79
|
bundler,
|
|
78
80
|
options.platform,
|
|
79
81
|
resolverOptions,
|
|
80
82
|
),
|
|
83
|
+
shallow: false,
|
|
81
84
|
transform: await getTransformFn(
|
|
82
85
|
[path],
|
|
83
86
|
bundler,
|
|
@@ -90,13 +93,12 @@ async function calcTransformerOptions(
|
|
|
90
93
|
resolverOptions,
|
|
91
94
|
),
|
|
92
95
|
transformOptions: options,
|
|
93
|
-
onProgress: null,
|
|
94
|
-
lazy: false,
|
|
95
96
|
unstable_allowRequireContext:
|
|
96
97
|
config.transformer.unstable_allowRequireContext,
|
|
97
98
|
unstable_enablePackageExports:
|
|
98
99
|
config.resolver.unstable_enablePackageExports,
|
|
99
|
-
|
|
100
|
+
unstable_incrementalResolution:
|
|
101
|
+
config.resolver.unstable_incrementalResolution,
|
|
100
102
|
});
|
|
101
103
|
|
|
102
104
|
return Array.from(dependencies.keys());
|
|
@@ -110,15 +112,15 @@ async function calcTransformerOptions(
|
|
|
110
112
|
|
|
111
113
|
return {
|
|
112
114
|
...baseOptions,
|
|
113
|
-
inlineRequires: transform?.inlineRequires || false,
|
|
114
115
|
experimentalImportSupport: transform?.experimentalImportSupport || false,
|
|
116
|
+
inlineRequires: transform?.inlineRequires || false,
|
|
117
|
+
nonInlinedRequires:
|
|
118
|
+
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
119
|
+
type: 'module',
|
|
115
120
|
unstable_memoizeInlineRequires:
|
|
116
121
|
transform?.unstable_memoizeInlineRequires || false,
|
|
117
122
|
unstable_nonMemoizedInlineRequires:
|
|
118
123
|
transform?.unstable_nonMemoizedInlineRequires || [],
|
|
119
|
-
nonInlinedRequires:
|
|
120
|
-
transform?.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
121
|
-
type: 'module',
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -134,7 +136,7 @@ function removeInlineRequiresBlockListFromOptions(
|
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
export async function getTransformFn(
|
|
137
|
-
entryFiles:
|
|
139
|
+
entryFiles: ReadonlyArray<string>,
|
|
138
140
|
bundler: Bundler,
|
|
139
141
|
deltaBundler: DeltaBundler<>,
|
|
140
142
|
config: ConfigT,
|
|
@@ -181,11 +183,11 @@ export async function getTransformFn(
|
|
|
181
183
|
modulePath,
|
|
182
184
|
{
|
|
183
185
|
...transformOptions,
|
|
184
|
-
type: getType(transformOptions.type, modulePath, assetExts),
|
|
185
186
|
inlineRequires: removeInlineRequiresBlockListFromOptions(
|
|
186
187
|
modulePath,
|
|
187
188
|
inlineRequires,
|
|
188
189
|
),
|
|
190
|
+
type: getType(transformOptions.type, modulePath, assetExts),
|
|
189
191
|
},
|
|
190
192
|
templateBuffer,
|
|
191
193
|
);
|
|
@@ -195,7 +197,7 @@ export async function getTransformFn(
|
|
|
195
197
|
function getType(
|
|
196
198
|
type: string,
|
|
197
199
|
filePath: string,
|
|
198
|
-
assetExts:
|
|
200
|
+
assetExts: ReadonlySet<string>,
|
|
199
201
|
): Type {
|
|
200
202
|
if (type === 'script') {
|
|
201
203
|
return type;
|