metro 0.71.3 → 0.72.2
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 +23 -21
- package/src/Assets.js +3 -2
- package/src/Assets.js.flow +3 -2
- package/src/Bundler.js +11 -2
- package/src/Bundler.js.flow +7 -1
- package/src/DeltaBundler/DeltaCalculator.js +83 -21
- package/src/DeltaBundler/DeltaCalculator.js.flow +61 -8
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +3 -2
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +2 -1
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +2 -1
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +1 -3
- package/src/DeltaBundler/Transformer.js +27 -4
- package/src/DeltaBundler/Transformer.js.flow +18 -2
- package/src/DeltaBundler/Worker.flow.js +45 -1
- package/src/DeltaBundler/Worker.flow.js.flow +42 -1
- package/src/DeltaBundler/WorkerFarm.js +3 -2
- package/src/DeltaBundler/WorkerFarm.js.flow +3 -1
- package/src/DeltaBundler/graphOperations.js +170 -63
- package/src/DeltaBundler/graphOperations.js.flow +144 -64
- package/src/DeltaBundler/types.flow.js.flow +11 -5
- package/src/DeltaBundler.js.flow +1 -1
- package/src/HmrServer.js +11 -5
- package/src/HmrServer.js.flow +11 -4
- package/src/IncrementalBundler.js +22 -4
- package/src/IncrementalBundler.js.flow +23 -4
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
- package/src/ModuleGraph/node-haste/Package.js.flow +5 -5
- package/src/ModuleGraph/node-haste/node-haste.js +19 -8
- package/src/ModuleGraph/node-haste/node-haste.js.flow +43 -16
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +5 -13
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +4 -14
- package/src/ModuleGraph/output/util.js +3 -4
- package/src/ModuleGraph/output/util.js.flow +3 -3
- package/src/ModuleGraph/types.flow.js.flow +28 -5
- package/src/ModuleGraph/worker/collectDependencies.js +19 -30
- package/src/ModuleGraph/worker/collectDependencies.js.flow +23 -41
- package/src/Server.js +90 -32
- package/src/Server.js.flow +143 -44
- package/src/cli-utils.js.flow +1 -1
- package/src/commands/build.js +1 -2
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +1 -1
- package/src/commands/serve.js +2 -1
- package/src/commands/serve.js.flow +7 -8
- package/src/index.flow.js +27 -16
- package/src/index.flow.js.flow +24 -15
- package/src/integration_tests/basic_bundle/require-context/conflict.js +25 -0
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +27 -0
- package/src/integration_tests/basic_bundle/require-context/empty.js +29 -0
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +26 -0
- package/src/integration_tests/basic_bundle/require-context/matching.js +26 -0
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +27 -0
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js +22 -0
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +24 -0
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +22 -0
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +24 -0
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +22 -0
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +24 -0
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js +20 -0
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +22 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/a.js +12 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/a.js.flow +11 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/b.js +18 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/b.js.flow +11 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/c.js +12 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/c.js.flow +11 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js +12 -0
- package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js.flow +11 -0
- package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js +12 -0
- package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js.flow +11 -0
- package/src/integration_tests/basic_bundle/require-context/utils.js +29 -0
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +44 -0
- package/src/lib/CountingSet.js +1 -0
- package/src/lib/CountingSet.js.flow +1 -0
- package/src/lib/RamBundleParser.js +1 -0
- package/src/lib/RamBundleParser.js.flow +1 -0
- package/src/lib/bundleToBytecode.js +3 -2
- package/src/lib/bundleToBytecode.js.flow +2 -2
- package/src/lib/contextModule.js +80 -0
- package/src/lib/contextModule.js.flow +86 -0
- package/src/lib/contextModuleTemplates.js +186 -0
- package/src/lib/contextModuleTemplates.js.flow +148 -0
- package/src/lib/getGraphId.js +17 -3
- package/src/lib/getGraphId.js.flow +12 -9
- package/src/lib/getPrependedScripts.js +15 -5
- package/src/lib/getPrependedScripts.js.flow +8 -1
- package/src/lib/parseCustomResolverOptions.js +26 -0
- package/src/lib/parseCustomResolverOptions.js.flow +38 -0
- package/src/lib/parseOptionsFromUrl.js +3 -0
- package/src/lib/parseOptionsFromUrl.js.flow +9 -18
- package/src/lib/splitBundleOptions.js +3 -0
- package/src/lib/splitBundleOptions.js.flow +3 -0
- package/src/lib/transformHelpers.js +68 -22
- package/src/lib/transformHelpers.js.flow +73 -16
- package/src/node-haste/DependencyGraph/ModuleResolution.js +19 -2
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +8 -2
- package/src/node-haste/DependencyGraph/createHasteMap.js +7 -1
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +7 -1
- package/src/node-haste/DependencyGraph.js +39 -9
- package/src/node-haste/DependencyGraph.js.flow +63 -12
- package/src/node-haste/Module.js +1 -0
- package/src/node-haste/Module.js.flow +1 -0
- package/src/shared/output/bundle.flow.js +67 -0
- package/src/shared/output/bundle.flow.js.flow +89 -0
- package/src/shared/output/bundle.js +8 -55
- package/src/shared/output/bundle.js.flow +8 -75
- package/src/shared/types.flow.js.flow +7 -0
package/src/index.flow.js.flow
CHANGED
|
@@ -424,14 +424,20 @@ exports.buildGraph = async function (
|
|
|
424
424
|
const bundler = new IncrementalBundler(mergedConfig);
|
|
425
425
|
|
|
426
426
|
try {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
427
|
+
const {customResolverOptions, ...defaultTransformInputOptions} =
|
|
428
|
+
MetroServer.DEFAULT_GRAPH_OPTIONS;
|
|
429
|
+
return await bundler.buildGraphForEntries(
|
|
430
|
+
entries,
|
|
431
|
+
{
|
|
432
|
+
...defaultTransformInputOptions,
|
|
433
|
+
customTransformOptions,
|
|
434
|
+
dev,
|
|
435
|
+
minify,
|
|
436
|
+
platform,
|
|
437
|
+
type,
|
|
438
|
+
},
|
|
439
|
+
{customResolverOptions},
|
|
440
|
+
);
|
|
435
441
|
} finally {
|
|
436
442
|
bundler.end();
|
|
437
443
|
}
|
|
@@ -448,20 +454,23 @@ exports.attachMetroCli = function (
|
|
|
448
454
|
serve: ServeCommandOptions,
|
|
449
455
|
dependencies: any,
|
|
450
456
|
...
|
|
451
|
-
}
|
|
457
|
+
}
|
|
458
|
+
// prettier-ignore
|
|
459
|
+
// $FlowFixMe[prop-missing]
|
|
460
|
+
= {},
|
|
452
461
|
): Yargs {
|
|
462
|
+
yargs.strict();
|
|
463
|
+
|
|
453
464
|
if (build) {
|
|
454
|
-
|
|
455
|
-
yargs.command(command, description, builder, handler);
|
|
465
|
+
yargs.command(makeBuildCommand());
|
|
456
466
|
}
|
|
457
467
|
if (serve) {
|
|
458
|
-
|
|
459
|
-
yargs.command(command, description, builder, handler);
|
|
468
|
+
yargs.command(makeServeCommand());
|
|
460
469
|
}
|
|
461
470
|
if (dependencies) {
|
|
462
|
-
|
|
463
|
-
yargs.command(command, description, builder, handler);
|
|
471
|
+
yargs.command(makeDependenciesCommand());
|
|
464
472
|
}
|
|
473
|
+
|
|
465
474
|
return yargs;
|
|
466
475
|
};
|
|
467
476
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
const normalModule = require("./subdir-conflict");
|
|
15
|
+
|
|
16
|
+
const contextModule = require.context("./subdir-conflict");
|
|
17
|
+
|
|
18
|
+
function main() {
|
|
19
|
+
return {
|
|
20
|
+
normalModule,
|
|
21
|
+
contextModule: (0, _utils.copyContextToObject)(contextModule),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = main();
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
const normalModule = require('./subdir-conflict');
|
|
18
|
+
const contextModule = require.context('./subdir-conflict');
|
|
19
|
+
|
|
20
|
+
function main() {
|
|
21
|
+
return {
|
|
22
|
+
normalModule,
|
|
23
|
+
contextModule: copyContextToObject(contextModule),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const empty = require.context("./no-such-dir");
|
|
13
|
+
|
|
14
|
+
function main() {
|
|
15
|
+
try {
|
|
16
|
+
empty("./no-such-file.js");
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return {
|
|
19
|
+
error: {
|
|
20
|
+
message: e.message,
|
|
21
|
+
code: e.code,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = main();
|
|
@@ -0,0 +1,26 @@
|
|
|
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 empty = require.context('./no-such-dir');
|
|
16
|
+
|
|
17
|
+
function main() {
|
|
18
|
+
try {
|
|
19
|
+
empty('./no-such-file.js');
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return {error: {message: e.message, code: e.code}};
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const ab = require.context("./subdir", false, /\/(a|b)\.js$/);
|
|
13
|
+
|
|
14
|
+
const abc = require.context("./subdir", false);
|
|
15
|
+
|
|
16
|
+
const abcd = require.context("./subdir", true);
|
|
17
|
+
|
|
18
|
+
function main() {
|
|
19
|
+
return {
|
|
20
|
+
ab: ab.keys(),
|
|
21
|
+
abc: abc.keys(),
|
|
22
|
+
abcd: abcd.keys(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = main();
|
|
@@ -0,0 +1,27 @@
|
|
|
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('./subdir', false, /\/(a|b)\.js$/);
|
|
16
|
+
const abc = require.context('./subdir', false);
|
|
17
|
+
const abcd = require.context('./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(): mixed);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function main() {
|
|
15
|
+
return (0, _utils.awaitProperties)(
|
|
16
|
+
(0, _utils.copyContextToObject)(
|
|
17
|
+
require.context("./subdir", undefined, undefined, "eager")
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = main();
|
|
@@ -0,0 +1,24 @@
|
|
|
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 {copyContextToObject, awaitProperties} from './utils';
|
|
12
|
+
import type {RequireWithContext} from './utils';
|
|
13
|
+
|
|
14
|
+
declare var require: RequireWithContext;
|
|
15
|
+
|
|
16
|
+
function main() {
|
|
17
|
+
return awaitProperties(
|
|
18
|
+
copyContextToObject(
|
|
19
|
+
require.context('./subdir', undefined, undefined, 'eager'),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function main() {
|
|
15
|
+
return (0, _utils.awaitProperties)(
|
|
16
|
+
(0, _utils.copyContextToObject)(
|
|
17
|
+
require.context("./subdir", undefined, undefined, "lazy-once")
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = main();
|
|
@@ -0,0 +1,24 @@
|
|
|
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 {copyContextToObject, awaitProperties} from './utils';
|
|
12
|
+
import type {RequireWithContext} from './utils';
|
|
13
|
+
|
|
14
|
+
declare var require: RequireWithContext;
|
|
15
|
+
|
|
16
|
+
function main() {
|
|
17
|
+
return awaitProperties(
|
|
18
|
+
copyContextToObject(
|
|
19
|
+
require.context('./subdir', undefined, undefined, 'lazy-once'),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function main() {
|
|
15
|
+
return (0, _utils.awaitProperties)(
|
|
16
|
+
(0, _utils.copyContextToObject)(
|
|
17
|
+
require.context("./subdir", undefined, undefined, "lazy")
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = main();
|
|
@@ -0,0 +1,24 @@
|
|
|
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 {copyContextToObject, awaitProperties} from './utils';
|
|
12
|
+
import type {RequireWithContext} from './utils';
|
|
13
|
+
|
|
14
|
+
declare var require: RequireWithContext;
|
|
15
|
+
|
|
16
|
+
function main() {
|
|
17
|
+
return awaitProperties(
|
|
18
|
+
copyContextToObject(
|
|
19
|
+
require.context('./subdir', undefined, undefined, 'lazy'),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function main() {
|
|
15
|
+
return (0, _utils.copyContextToObject)(
|
|
16
|
+
require.context("./subdir", undefined, undefined, "sync")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = main();
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {copyContextToObject} from './utils';
|
|
12
|
+
import type {RequireWithContext} from './utils';
|
|
13
|
+
|
|
14
|
+
declare var require: RequireWithContext;
|
|
15
|
+
|
|
16
|
+
function main() {
|
|
17
|
+
return copyContextToObject(
|
|
18
|
+
require.context('./subdir', undefined, undefined, 'sync'),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = (main(): mixed);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
module.exports = "a";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
* @format
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
var _default = "b";
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
module.exports = "c";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
module.exports = "d";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
module.exports = "contents of subdir-conflict/index.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
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';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.copyContextToObject = copyContextToObject;
|
|
7
|
+
exports.awaitProperties = awaitProperties;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
* @format
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
function copyContextToObject(ctx) {
|
|
19
|
+
return Object.fromEntries(ctx.keys().map((key) => [key, ctx(key)]));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function awaitProperties(obj) {
|
|
23
|
+
const result = {};
|
|
24
|
+
return Promise.all(
|
|
25
|
+
Object.keys(obj).map((key) => {
|
|
26
|
+
return obj[key].then((value) => (result[key] = value));
|
|
27
|
+
})
|
|
28
|
+
).then(() => result);
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 = {};
|
|
39
|
+
return Promise.all(
|
|
40
|
+
Object.keys(obj).map(key => {
|
|
41
|
+
return obj[key].then(value => (result[key] = value));
|
|
42
|
+
}),
|
|
43
|
+
).then(() => result);
|
|
44
|
+
}
|
package/src/lib/CountingSet.js
CHANGED