metro 0.85.0 → 0.87.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 +14 -14
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +3 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +3 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +2 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +4 -4
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +7 -5
- package/src/Server/symbolicate.js +66 -33
- package/src/Server/symbolicate.js.flow +79 -40
- package/src/index.d.ts +1 -23
- package/src/index.flow.js +1 -15
- package/src/index.flow.js.flow +0 -20
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +3 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +23 -30
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +23 -37
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +0 -17
- package/src/integration_tests/basic_bundle/AssetRegistry.js +0 -7
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +0 -17
- package/src/integration_tests/basic_bundle/Bar.js +0 -7
- package/src/integration_tests/basic_bundle/Bar.js.flow +0 -15
- package/src/integration_tests/basic_bundle/ErrorBundle.js +0 -8
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +0 -23
- package/src/integration_tests/basic_bundle/Foo.js +0 -7
- package/src/integration_tests/basic_bundle/Foo.js.flow +0 -15
- package/src/integration_tests/basic_bundle/TestBigInt.js +0 -5
- package/src/integration_tests/basic_bundle/TestBigInt.js.flow +0 -17
- package/src/integration_tests/basic_bundle/TestBundle.js +0 -13
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +0 -21
- package/src/integration_tests/basic_bundle/TestPolyfill.js +0 -3
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +0 -13
- package/src/integration_tests/basic_bundle/TypeScript.ts +0 -16
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +0 -7
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +0 -17
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +0 -29
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +0 -29
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +0 -17
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +0 -17
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +0 -19
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +0 -7
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +0 -17
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js +0 -4
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +0 -17
- package/src/integration_tests/basic_bundle/excluded_from_file_map.js +0 -7
- package/src/integration_tests/basic_bundle/excluded_from_file_map.js.flow +0 -11
- package/src/integration_tests/basic_bundle/import-export/export-1.js +0 -12
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +0 -19
- package/src/integration_tests/basic_bundle/import-export/export-2.js +0 -12
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +0 -19
- package/src/integration_tests/basic_bundle/import-export/export-3.js +0 -12
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +0 -19
- package/src/integration_tests/basic_bundle/import-export/export-4.js +0 -12
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +0 -19
- package/src/integration_tests/basic_bundle/import-export/export-5.js +0 -5
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/export-6.js +0 -8
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/export-7.js +0 -5
- package/src/integration_tests/basic_bundle/import-export/export-7.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/export-8.js +0 -8
- package/src/integration_tests/basic_bundle/import-export/export-8.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/export-null.js +0 -8
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +0 -8
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +0 -15
- package/src/integration_tests/basic_bundle/import-export/index.js +0 -76
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +0 -43
- package/src/integration_tests/basic_bundle/import-export/utils.js +0 -1
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +0 -14
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js +0 -6
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +0 -20
- package/src/integration_tests/basic_bundle/not_a_source_file.xyz +0 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js +0 -20
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +0 -34
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-b.js +0 -3
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-b.js.flow +0 -11
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-c.js +0 -3
- package/src/integration_tests/basic_bundle/optional-dependencies/optional-c.js.flow +0 -11
- package/src/integration_tests/basic_bundle/optional-dependencies/required-a.js +0 -3
- package/src/integration_tests/basic_bundle/optional-dependencies/required-a.js.flow +0 -11
- package/src/integration_tests/basic_bundle/polyfill.js +0 -3
- package/src/integration_tests/basic_bundle/require-context/conflict.js +0 -12
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +0 -27
- package/src/integration_tests/basic_bundle/require-context/empty.js +0 -17
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +0 -26
- package/src/integration_tests/basic_bundle/require-context/matching.js +0 -13
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +0 -27
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js +0 -11
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +0 -25
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +0 -11
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +0 -25
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +0 -11
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +0 -25
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js +0 -9
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +0 -24
- package/src/integration_tests/basic_bundle/require-context/subdir/a.js +0 -3
- package/src/integration_tests/basic_bundle/require-context/subdir/a.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-context/subdir/b.js +0 -7
- package/src/integration_tests/basic_bundle/require-context/subdir/b.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-context/subdir/c.js +0 -3
- package/src/integration_tests/basic_bundle/require-context/subdir/c.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js +0 -3
- package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js +0 -3
- package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-context/utils.js +0 -18
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +0 -44
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js +0 -13
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +0 -33
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js +0 -10
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +0 -23
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js +0 -8
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +0 -21
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js +0 -13
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +0 -33
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js +0 -9
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js.flow +0 -18
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js +0 -3
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js.flow +0 -11
- package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js +0 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js.flow +0 -14
- package/src/integration_tests/basic_bundle/test.png +0 -0
- package/src/integration_tests/execBundle.js +0 -12
- package/src/integration_tests/execBundle.js.flow +0 -19
- package/src/integration_tests/metro.config.js +0 -46
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithContext} from './utils';
|
|
12
|
-
|
|
13
|
-
declare var require: RequireWithContext;
|
|
14
|
-
|
|
15
|
-
const ab = require.context<$FlowFixMe>('./subdir', false, /\/(a|b)\.js$/);
|
|
16
|
-
const abc = require.context<$FlowFixMe>('./subdir', false);
|
|
17
|
-
const abcd = require.context<$FlowFixMe>('./subdir', true);
|
|
18
|
-
|
|
19
|
-
function main() {
|
|
20
|
-
return {
|
|
21
|
-
ab: ab.keys(),
|
|
22
|
-
abc: abc.keys(),
|
|
23
|
-
abcd: abcd.keys(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = main() as unknown;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithContext} from './utils';
|
|
12
|
-
|
|
13
|
-
import {awaitProperties, copyContextToObject} from './utils';
|
|
14
|
-
|
|
15
|
-
declare var require: RequireWithContext;
|
|
16
|
-
|
|
17
|
-
function main() {
|
|
18
|
-
return awaitProperties<$FlowFixMe>(
|
|
19
|
-
copyContextToObject<$FlowFixMe>(
|
|
20
|
-
require.context('./subdir', undefined, undefined, 'eager'),
|
|
21
|
-
),
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = main() as unknown;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithContext} from './utils';
|
|
12
|
-
|
|
13
|
-
import {awaitProperties, copyContextToObject} from './utils';
|
|
14
|
-
|
|
15
|
-
declare var require: RequireWithContext;
|
|
16
|
-
|
|
17
|
-
function main() {
|
|
18
|
-
return awaitProperties<$FlowFixMe>(
|
|
19
|
-
copyContextToObject<$FlowFixMe>(
|
|
20
|
-
require.context('./subdir', undefined, undefined, 'lazy-once'),
|
|
21
|
-
),
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = main() as unknown;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithContext} from './utils';
|
|
12
|
-
|
|
13
|
-
import {awaitProperties, copyContextToObject} from './utils';
|
|
14
|
-
|
|
15
|
-
declare var require: RequireWithContext;
|
|
16
|
-
|
|
17
|
-
function main() {
|
|
18
|
-
return awaitProperties<$FlowFixMe>(
|
|
19
|
-
copyContextToObject<$FlowFixMe>(
|
|
20
|
-
require.context('./subdir', undefined, undefined, 'lazy'),
|
|
21
|
-
),
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = main() as unknown;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithContext} from './utils';
|
|
12
|
-
|
|
13
|
-
import {copyContextToObject} from './utils';
|
|
14
|
-
|
|
15
|
-
declare var require: RequireWithContext;
|
|
16
|
-
|
|
17
|
-
function main(): unknown {
|
|
18
|
-
return copyContextToObject(
|
|
19
|
-
// $FlowFixMe[underconstrained-implicit-instantiation]
|
|
20
|
-
require.context('./subdir', undefined, undefined, 'sync'),
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = main() as unknown;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
module.exports = 'contents of subdir-conflict/index.js';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.awaitProperties = awaitProperties;
|
|
7
|
-
exports.copyContextToObject = copyContextToObject;
|
|
8
|
-
function copyContextToObject(ctx) {
|
|
9
|
-
return Object.fromEntries(ctx.keys().map((key) => [key, ctx(key)]));
|
|
10
|
-
}
|
|
11
|
-
function awaitProperties(obj) {
|
|
12
|
-
const result = {};
|
|
13
|
-
return Promise.all(
|
|
14
|
-
Object.keys(obj).map((key) => {
|
|
15
|
-
return obj[key].then((value) => (result[key] = value));
|
|
16
|
-
}),
|
|
17
|
-
).then(() => result);
|
|
18
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
type ContextModule<T> = {
|
|
12
|
-
(key: string): T,
|
|
13
|
-
keys(): Array<string>,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type RequireWithContext = {
|
|
17
|
-
(id: string): any,
|
|
18
|
-
resolve: (id: string, options?: {paths?: Array<string>, ...}) => string,
|
|
19
|
-
cache: any,
|
|
20
|
-
main: typeof module,
|
|
21
|
-
context<T>(
|
|
22
|
-
name: string,
|
|
23
|
-
recursive?: boolean,
|
|
24
|
-
filter?: RegExp,
|
|
25
|
-
mode?: 'sync' | 'eager' | 'lazy' | 'lazy-once',
|
|
26
|
-
): ContextModule<T>,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function copyContextToObject<T>(ctx: ContextModule<T>): {
|
|
30
|
-
[key: string]: T,
|
|
31
|
-
} {
|
|
32
|
-
return Object.fromEntries(ctx.keys().map(key => [key, ctx(key)]));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function awaitProperties<T>(
|
|
36
|
-
obj: Readonly<{[key: string]: Promise<T>}>,
|
|
37
|
-
): Promise<{[key: string]: T}> {
|
|
38
|
-
const result: {[string]: T} = {};
|
|
39
|
-
return Promise.all(
|
|
40
|
-
Object.keys(obj).map(key => {
|
|
41
|
-
return obj[key].then(value => (result[key] = value));
|
|
42
|
-
}),
|
|
43
|
-
).then(() => result);
|
|
44
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
async function main() {
|
|
4
|
-
const moduleId = require.resolveWeak("./subdir/counter-module");
|
|
5
|
-
(await import("./subdir/counter-module.js")).increment();
|
|
6
|
-
const dynamicRequire = require;
|
|
7
|
-
const timesIncremented = dynamicRequire(moduleId).increment();
|
|
8
|
-
return {
|
|
9
|
-
moduleId,
|
|
10
|
-
timesIncremented,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
module.exports = main();
|
package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithResolveWeak} from './utils';
|
|
12
|
-
|
|
13
|
-
declare var require: RequireWithResolveWeak;
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
const moduleId = require.resolveWeak('./subdir/counter-module');
|
|
17
|
-
|
|
18
|
-
// Require the module statically via its path, spelled slightly differently
|
|
19
|
-
(await import('./subdir/counter-module.js')).increment();
|
|
20
|
-
|
|
21
|
-
const dynamicRequire = require;
|
|
22
|
-
|
|
23
|
-
// Require the module dynamically via its ID
|
|
24
|
-
const timesIncremented = dynamicRequire(moduleId).increment();
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
moduleId,
|
|
28
|
-
// Should be 2, proving there's just one module instance
|
|
29
|
-
timesIncremented,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = main() as unknown;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
async function main() {
|
|
4
|
-
return {
|
|
5
|
-
counterModuleId1: require.resolveWeak("./subdir/counter-module"),
|
|
6
|
-
counterModuleId2: require.resolveWeak("./subdir/counter-module.js"),
|
|
7
|
-
throwingModuleId: require.resolveWeak("./subdir/throwing-module.js"),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
module.exports = main();
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithResolveWeak} from './utils';
|
|
12
|
-
|
|
13
|
-
declare var require: RequireWithResolveWeak;
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
return {
|
|
17
|
-
counterModuleId1: require.resolveWeak('./subdir/counter-module'),
|
|
18
|
-
counterModuleId2: require.resolveWeak('./subdir/counter-module.js'),
|
|
19
|
-
throwingModuleId: require.resolveWeak('./subdir/throwing-module.js'),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = main() as unknown;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithResolveWeak} from './utils';
|
|
12
|
-
|
|
13
|
-
declare var require: RequireWithResolveWeak;
|
|
14
|
-
|
|
15
|
-
function main() {
|
|
16
|
-
return {
|
|
17
|
-
moduleId: require.resolveWeak('./subdir/throwing-module'),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = main() as unknown;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function main() {
|
|
4
|
-
const moduleId = require.resolveWeak("./subdir/counter-module");
|
|
5
|
-
const dynamicRequire = require;
|
|
6
|
-
dynamicRequire(moduleId).increment();
|
|
7
|
-
const timesIncremented = require("./subdir/counter-module.js").increment();
|
|
8
|
-
return {
|
|
9
|
-
moduleId,
|
|
10
|
-
timesIncremented,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
module.exports = main();
|
package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {RequireWithResolveWeak} from './utils';
|
|
12
|
-
|
|
13
|
-
declare var require: RequireWithResolveWeak;
|
|
14
|
-
|
|
15
|
-
function main() {
|
|
16
|
-
const moduleId = require.resolveWeak('./subdir/counter-module');
|
|
17
|
-
|
|
18
|
-
const dynamicRequire = require;
|
|
19
|
-
|
|
20
|
-
// Require the module dynamically via its ID
|
|
21
|
-
dynamicRequire(moduleId).increment();
|
|
22
|
-
|
|
23
|
-
// Require the module statically via its path, spelled slightly differently
|
|
24
|
-
const timesIncremented = require('./subdir/counter-module.js').increment();
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
moduleId,
|
|
28
|
-
// Should be 2, proving there's just one module instance
|
|
29
|
-
timesIncremented,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = main() as unknown;
|
package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js.flow
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
let count: number = 0;
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
increment(): number {
|
|
15
|
-
++count;
|
|
16
|
-
return count;
|
|
17
|
-
},
|
|
18
|
-
};
|
package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js.flow
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow strict-local
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
throw new Error('This module cannot be evaluated.');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export type RequireWithResolveWeak = {
|
|
12
|
-
(id: string | number): any,
|
|
13
|
-
resolveWeak: (id: string) => string | number,
|
|
14
|
-
};
|
|
Binary file
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vm = _interopRequireDefault(require("vm"));
|
|
4
|
-
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule ? e : { default: e };
|
|
6
|
-
}
|
|
7
|
-
module.exports = function execBundle(code, context = {}) {
|
|
8
|
-
if (_vm.default.isContext(context)) {
|
|
9
|
-
return _vm.default.runInContext(code, context);
|
|
10
|
-
}
|
|
11
|
-
return _vm.default.runInNewContext(code, context);
|
|
12
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import vm from 'vm';
|
|
13
|
-
|
|
14
|
-
module.exports = function execBundle(code: string, context: any = {}): unknown {
|
|
15
|
-
if (vm.isContext(context)) {
|
|
16
|
-
return vm.runInContext(code, context);
|
|
17
|
-
}
|
|
18
|
-
return vm.runInNewContext(code, context);
|
|
19
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const ROOT_PATH = path.resolve(__dirname, "basic_bundle");
|
|
5
|
-
module.exports = {
|
|
6
|
-
cacheStores: [],
|
|
7
|
-
maxWorkers: 1,
|
|
8
|
-
projectRoot: ROOT_PATH,
|
|
9
|
-
reporter: {
|
|
10
|
-
update() {},
|
|
11
|
-
},
|
|
12
|
-
watchFolders: [path.resolve(__dirname, "../../../")],
|
|
13
|
-
server: {
|
|
14
|
-
port: 0,
|
|
15
|
-
},
|
|
16
|
-
resolver: {
|
|
17
|
-
blockList: [/excluded_from_file_map\.js$/],
|
|
18
|
-
useWatchman: false,
|
|
19
|
-
},
|
|
20
|
-
transformer: {
|
|
21
|
-
assetRegistryPath: path.join(ROOT_PATH, "AssetRegistry"),
|
|
22
|
-
asyncRequireModulePath: require.resolve(
|
|
23
|
-
"metro-runtime/src/modules/asyncRequire",
|
|
24
|
-
),
|
|
25
|
-
babelTransformerPath: require.resolve(
|
|
26
|
-
"@react-native/metro-babel-transformer",
|
|
27
|
-
),
|
|
28
|
-
enableBabelRCLookup: false,
|
|
29
|
-
enableBabelRuntime: false,
|
|
30
|
-
getTransformOptions: async (entryFiles) => ({
|
|
31
|
-
transform: {
|
|
32
|
-
experimentalImportSupport: true,
|
|
33
|
-
inlineRequires: entryFiles.some((filePath) =>
|
|
34
|
-
filePath.includes("inline-requires"),
|
|
35
|
-
),
|
|
36
|
-
},
|
|
37
|
-
preloadedModules: false,
|
|
38
|
-
ramGroups: [],
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
serializer: {
|
|
42
|
-
getPolyfills: () => [
|
|
43
|
-
require.resolve("./basic_bundle/loadBundleAsyncForTest"),
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
};
|