metro 0.66.0 → 0.68.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 +27 -27
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +17 -15
- package/src/Bundler/util.js.flow +12 -10
- package/src/Bundler.js +22 -9
- package/src/Bundler.js.flow +20 -7
- package/src/DeltaBundler/DeltaCalculator.js +17 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +9 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +18 -8
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +19 -10
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +15 -14
- package/src/DeltaBundler/Transformer.js.flow +14 -15
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +15 -18
- package/src/DeltaBundler/WorkerFarm.js.flow +9 -11
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +15 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +73 -55
- package/src/HmrServer.js.flow +42 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +46 -32
- package/src/IncrementalBundler.js.flow +32 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +5 -3
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +3 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +42 -32
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -23
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +62 -41
- package/src/ModuleGraph/output/util.js.flow +51 -29
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +47 -31
- package/src/ModuleGraph/worker/JsFileWrapping.js +16 -16
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +16 -18
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +204 -150
- package/src/Server.js.flow +131 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +19 -19
- package/src/commands/serve.js.flow +7 -9
- package/src/index.js +117 -50
- package/src/index.js.flow +108 -40
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +2 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +17 -17
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +10 -6
- package/src/lib/BatchProcessor.js.flow +6 -1
- package/src/lib/JsonReporter.js +3 -2
- package/src/lib/JsonReporter.js.flow +2 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +15 -15
- package/src/lib/TerminalReporter.js.flow +10 -11
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +12 -21
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +6 -8
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +16 -15
- package/src/lib/getPrependedScripts.js.flow +8 -8
- package/src/lib/logToConsole.js +5 -3
- package/src/lib/logToConsole.js.flow +13 -5
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +17 -3
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +11 -10
- package/src/lib/transformHelpers.js.flow +6 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +46 -42
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +51 -118
- package/src/node-haste/DependencyGraph.js.flow +38 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +7 -9
- package/src/node-haste/Package.js.flow +1 -8
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +7 -6
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-assets.js +14 -15
- package/src/shared/output/RamBundle/as-assets.js.flow +9 -11
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +6 -4
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.0",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.0.0",
|
|
17
|
-
"@babel/core": "^7.
|
|
18
|
-
"@babel/generator": "^7.
|
|
19
|
-
"@babel/parser": "^7.
|
|
17
|
+
"@babel/core": "^7.14.0",
|
|
18
|
+
"@babel/generator": "^7.14.0",
|
|
19
|
+
"@babel/parser": "^7.14.0",
|
|
20
20
|
"@babel/template": "^7.0.0",
|
|
21
|
-
"@babel/traverse": "^7.
|
|
21
|
+
"@babel/traverse": "^7.14.0",
|
|
22
22
|
"@babel/types": "^7.0.0",
|
|
23
23
|
"absolute-path": "^0.0.0",
|
|
24
24
|
"accepts": "^1.3.7",
|
|
@@ -31,27 +31,27 @@
|
|
|
31
31
|
"error-stack-parser": "^2.0.6",
|
|
32
32
|
"fs-extra": "^1.0.0",
|
|
33
33
|
"graceful-fs": "^4.1.3",
|
|
34
|
+
"hermes-parser": "0.5.0",
|
|
34
35
|
"image-size": "^0.6.0",
|
|
35
36
|
"invariant": "^2.2.4",
|
|
36
|
-
"jest-haste-map": "^
|
|
37
|
+
"jest-haste-map": "^27.3.1",
|
|
37
38
|
"jest-worker": "^26.0.0",
|
|
38
39
|
"lodash.throttle": "^4.1.1",
|
|
39
|
-
"metro-babel-
|
|
40
|
-
"metro-
|
|
41
|
-
"metro-cache": "0.
|
|
42
|
-
"metro-
|
|
43
|
-
"metro-
|
|
44
|
-
"metro-
|
|
45
|
-
"metro-
|
|
46
|
-
"metro-
|
|
47
|
-
"metro-
|
|
48
|
-
"metro-
|
|
49
|
-
"metro-
|
|
50
|
-
"metro-
|
|
51
|
-
"metro-
|
|
52
|
-
"metro-
|
|
53
|
-
"metro-transform-
|
|
54
|
-
"metro-transform-worker": "0.66.0",
|
|
40
|
+
"metro-babel-transformer": "0.68.0",
|
|
41
|
+
"metro-cache": "0.68.0",
|
|
42
|
+
"metro-cache-key": "0.68.0",
|
|
43
|
+
"metro-config": "0.68.0",
|
|
44
|
+
"metro-core": "0.68.0",
|
|
45
|
+
"metro-hermes-compiler": "0.68.0",
|
|
46
|
+
"metro-inspector-proxy": "0.68.0",
|
|
47
|
+
"metro-minify-uglify": "0.68.0",
|
|
48
|
+
"metro-react-native-babel-preset": "0.68.0",
|
|
49
|
+
"metro-resolver": "0.68.0",
|
|
50
|
+
"metro-runtime": "0.68.0",
|
|
51
|
+
"metro-source-map": "0.68.0",
|
|
52
|
+
"metro-symbolicate": "0.68.0",
|
|
53
|
+
"metro-transform-plugins": "0.68.0",
|
|
54
|
+
"metro-transform-worker": "0.68.0",
|
|
55
55
|
"mime-types": "^2.1.27",
|
|
56
56
|
"mkdirp": "^0.5.1",
|
|
57
57
|
"node-fetch": "^2.2.0",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"strip-ansi": "^6.0.0",
|
|
63
63
|
"temp": "0.8.3",
|
|
64
64
|
"throat": "^5.0.0",
|
|
65
|
-
"ws": "^
|
|
65
|
+
"ws": "^7.5.1",
|
|
66
66
|
"yargs": "^15.3.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
|
|
70
70
|
"acorn": "^5.1.2",
|
|
71
|
-
"babel-jest": "^26.
|
|
71
|
+
"babel-jest": "^26.6.3",
|
|
72
72
|
"dedent": "^0.7.0",
|
|
73
73
|
"jest-snapshot": "^26.5.2",
|
|
74
|
-
"metro-memory-fs": "0.
|
|
75
|
-
"metro-react-native-babel-preset": "0.
|
|
76
|
-
"metro-react-native-babel-transformer": "0.
|
|
74
|
+
"metro-memory-fs": "0.68.0",
|
|
75
|
+
"metro-react-native-babel-preset": "0.68.0",
|
|
76
|
+
"metro-react-native-babel-transformer": "0.68.0",
|
|
77
77
|
"stack-trace": "^0.0.10"
|
|
78
78
|
},
|
|
79
79
|
"license": "MIT"
|
package/src/Assets.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
+
const { isAssetTypeAnImage } = require("./Bundler/util");
|
|
13
|
+
|
|
12
14
|
const AssetPaths = require("./node-haste/lib/AssetPaths");
|
|
13
15
|
|
|
14
16
|
const crypto = require("crypto");
|
|
@@ -21,8 +23,6 @@ const imageSize = require("image-size");
|
|
|
21
23
|
|
|
22
24
|
const path = require("path");
|
|
23
25
|
|
|
24
|
-
const { isAssetTypeAnImage } = require("./Bundler/util");
|
|
25
|
-
|
|
26
26
|
const readDir = denodeify(fs.readdir);
|
|
27
27
|
const readFile = denodeify(fs.readFile);
|
|
28
28
|
const hashFiles = denodeify(function hashFilesCb(files, hash, callback) {
|
|
@@ -45,9 +45,9 @@ const hashFiles = denodeify(function hashFilesCb(files, hash, callback) {
|
|
|
45
45
|
|
|
46
46
|
function buildAssetMap(dir, files, platform) {
|
|
47
47
|
const platforms = new Set(platform != null ? [platform] : []);
|
|
48
|
-
const assets = files.map(file => AssetPaths.tryParse(file, platforms));
|
|
48
|
+
const assets = files.map((file) => AssetPaths.tryParse(file, platforms));
|
|
49
49
|
const map = new Map();
|
|
50
|
-
assets.forEach(function(asset, i) {
|
|
50
|
+
assets.forEach(function (asset, i) {
|
|
51
51
|
if (asset == null) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
@@ -59,7 +59,7 @@ function buildAssetMap(dir, files, platform) {
|
|
|
59
59
|
if (!record) {
|
|
60
60
|
record = {
|
|
61
61
|
scales: [],
|
|
62
|
-
files: []
|
|
62
|
+
files: [],
|
|
63
63
|
};
|
|
64
64
|
map.set(assetKey, record);
|
|
65
65
|
}
|
|
@@ -134,7 +134,7 @@ async function getAbsoluteAssetInfo(assetPath, platform = null) {
|
|
|
134
134
|
hash: hasher.digest("hex"),
|
|
135
135
|
name,
|
|
136
136
|
scales,
|
|
137
|
-
type
|
|
137
|
+
type,
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -173,7 +173,7 @@ async function getAssetData(
|
|
|
173
173
|
files: assetInfo.files,
|
|
174
174
|
hash: assetInfo.hash,
|
|
175
175
|
name: assetInfo.name,
|
|
176
|
-
type: assetInfo.type
|
|
176
|
+
type: assetInfo.type,
|
|
177
177
|
};
|
|
178
178
|
return await applyAssetDataPlugins(assetDataPlugins, assetData);
|
|
179
179
|
}
|
|
@@ -259,5 +259,5 @@ function pathBelongsToRoots(pathToCheck, roots) {
|
|
|
259
259
|
module.exports = {
|
|
260
260
|
getAsset,
|
|
261
261
|
getAssetData,
|
|
262
|
-
getAssetFiles
|
|
262
|
+
getAssetFiles,
|
|
263
263
|
};
|
package/src/Assets.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,21 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import type {AssetPath} from './node-haste/lib/AssetPaths';
|
|
14
14
|
|
|
15
|
+
const {isAssetTypeAnImage} = require('./Bundler/util');
|
|
16
|
+
const AssetPaths = require('./node-haste/lib/AssetPaths');
|
|
15
17
|
const crypto = require('crypto');
|
|
16
18
|
const denodeify = require('denodeify');
|
|
17
19
|
const fs = require('fs');
|
|
18
20
|
const imageSize = require('image-size');
|
|
19
21
|
const path = require('path');
|
|
20
22
|
|
|
21
|
-
const {isAssetTypeAnImage} = require('./Bundler/util');
|
|
22
|
-
|
|
23
23
|
const readDir = denodeify(fs.readdir);
|
|
24
24
|
const readFile = denodeify(fs.readFile);
|
|
25
25
|
|
|
26
|
-
import type {AssetPath} from './node-haste/lib/AssetPaths';
|
|
27
|
-
|
|
28
26
|
export type AssetInfo = {|
|
|
29
27
|
+files: Array<string>,
|
|
30
28
|
+hash: string,
|
|
@@ -92,7 +90,7 @@ function buildAssetMap(
|
|
|
92
90
|
AssetPaths.tryParse(file, platforms),
|
|
93
91
|
);
|
|
94
92
|
const map = new Map();
|
|
95
|
-
assets.forEach(function(asset: ?AssetPath, i: number) {
|
|
93
|
+
assets.forEach(function (asset: ?AssetPath, i: number) {
|
|
96
94
|
if (asset == null) {
|
|
97
95
|
return;
|
|
98
96
|
}
|
package/src/Bundler/util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const babelTypes = require("@babel/types");
|
|
13
|
-
|
|
14
12
|
const babylon = require("@babel/parser");
|
|
15
13
|
|
|
16
|
-
const nullthrows = require("nullthrows");
|
|
17
|
-
|
|
18
14
|
const template = require("@babel/template").default;
|
|
19
15
|
|
|
16
|
+
const babelTypes = require("@babel/types");
|
|
17
|
+
|
|
18
|
+
const nullthrows = require("nullthrows"); // Structure of the object: dir.name.scale = asset
|
|
19
|
+
|
|
20
20
|
const assetPropertyBlockList = new Set(["files", "fileSystemLocation", "path"]);
|
|
21
21
|
|
|
22
22
|
function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
@@ -37,8 +37,8 @@ function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
|
37
37
|
t.program([
|
|
38
38
|
buildRequire({
|
|
39
39
|
ASSET_REGISTRY_PATH: t.stringLiteral(assetRegistryPath),
|
|
40
|
-
DESCRIPTOR_AST: descriptorAst
|
|
41
|
-
})
|
|
40
|
+
DESCRIPTOR_AST: descriptorAst,
|
|
41
|
+
}),
|
|
42
42
|
])
|
|
43
43
|
);
|
|
44
44
|
}
|
|
@@ -92,8 +92,8 @@ function generateRemoteAssetCodeFileAst(
|
|
|
92
92
|
Object.keys(descriptor)
|
|
93
93
|
.map(Number)
|
|
94
94
|
.sort((a, b) => a - b)
|
|
95
|
-
.map(scale => t.numericLiteral(scale))
|
|
96
|
-
)
|
|
95
|
+
.map((scale) => t.numericLiteral(scale))
|
|
96
|
+
),
|
|
97
97
|
})
|
|
98
98
|
);
|
|
99
99
|
} // Test extension against all types supported by image-size module.
|
|
@@ -122,13 +122,13 @@ function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
|
122
122
|
// by path or (numeric) module id;
|
|
123
123
|
const byPath = new Map();
|
|
124
124
|
const byId = new Map();
|
|
125
|
-
groupableModules.forEach(m => {
|
|
125
|
+
groupableModules.forEach((m) => {
|
|
126
126
|
byPath.set(m.sourcePath, m);
|
|
127
127
|
byId.set(m.id, m.sourcePath);
|
|
128
128
|
}); // build a map of group root IDs to an array of module IDs in the group
|
|
129
129
|
|
|
130
130
|
const result = new Map(
|
|
131
|
-
ramGroups.map(modulePath => {
|
|
131
|
+
ramGroups.map((modulePath) => {
|
|
132
132
|
const root = byPath.get(modulePath);
|
|
133
133
|
|
|
134
134
|
if (root == null) {
|
|
@@ -137,7 +137,7 @@ function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
|
137
137
|
|
|
138
138
|
return [
|
|
139
139
|
root.id, // `subtree` yields the IDs of all transitive dependencies of a module
|
|
140
|
-
new Set(subtree(root, byPath))
|
|
140
|
+
new Set(subtree(root, byPath)),
|
|
141
141
|
];
|
|
142
142
|
})
|
|
143
143
|
);
|
|
@@ -155,11 +155,13 @@ function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
|
155
155
|
const doubles = filter(all, ([, parents]) => parents.length > 1);
|
|
156
156
|
|
|
157
157
|
for (const [moduleId, parents] of doubles) {
|
|
158
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
158
159
|
const parentNames = parents.map(byId.get, byId);
|
|
159
160
|
const lastName = parentNames.pop();
|
|
160
161
|
throw new Error(
|
|
161
|
-
`Module ${
|
|
162
|
-
|
|
162
|
+
`Module ${
|
|
163
|
+
byId.get(moduleId) || moduleId
|
|
164
|
+
} belongs to groups ${parentNames.join(", ")}, and ${String(
|
|
163
165
|
lastName
|
|
164
166
|
)}. Ensure that each module is only part of one group.`
|
|
165
167
|
);
|
|
@@ -194,5 +196,5 @@ module.exports = {
|
|
|
194
196
|
createRamBundleGroups,
|
|
195
197
|
generateAssetCodeFileAst,
|
|
196
198
|
generateRemoteAssetCodeFileAst,
|
|
197
|
-
isAssetTypeAnImage
|
|
199
|
+
isAssetTypeAnImage,
|
|
198
200
|
};
|
package/src/Bundler/util.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const babelTypes = require('@babel/types');
|
|
14
|
-
const babylon = require('@babel/parser');
|
|
15
|
-
const nullthrows = require('nullthrows');
|
|
16
|
-
const template = require('@babel/template').default;
|
|
17
|
-
|
|
18
13
|
import type {AssetDataFiltered, AssetDataWithoutFiles} from '../Assets';
|
|
19
14
|
import type {ModuleTransportLike} from '../shared/types.flow';
|
|
20
15
|
import type {File} from '@babel/types';
|
|
21
16
|
|
|
17
|
+
const babylon = require('@babel/parser');
|
|
18
|
+
const template = require('@babel/template').default;
|
|
19
|
+
const babelTypes = require('@babel/types');
|
|
20
|
+
const nullthrows = require('nullthrows');
|
|
21
|
+
|
|
22
22
|
// Structure of the object: dir.name.scale = asset
|
|
23
23
|
export type RemoteFileMap = {
|
|
24
24
|
[string]: {
|
|
@@ -28,9 +28,9 @@ export type RemoteFileMap = {
|
|
|
28
28
|
hash: string,
|
|
29
29
|
...
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
...
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
...
|
|
34
34
|
},
|
|
35
35
|
__proto__: null,
|
|
36
36
|
...
|
|
@@ -203,11 +203,13 @@ function createRamBundleGroups<T: ModuleTransportLike>(
|
|
|
203
203
|
// find all module IDs that are part of more than one group
|
|
204
204
|
const doubles = filter(all, ([, parents]) => parents.length > 1);
|
|
205
205
|
for (const [moduleId, parents] of doubles) {
|
|
206
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
206
207
|
const parentNames = parents.map(byId.get, byId);
|
|
207
208
|
const lastName = parentNames.pop();
|
|
208
209
|
throw new Error(
|
|
209
|
-
`Module ${
|
|
210
|
-
|
|
210
|
+
`Module ${
|
|
211
|
+
byId.get(moduleId) || moduleId
|
|
212
|
+
} belongs to groups ${parentNames.join(', ')}, and ${String(
|
|
211
213
|
lastName,
|
|
212
214
|
)}. Ensure that each module is only part of one group.`,
|
|
213
215
|
);
|
package/src/Bundler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -9,23 +9,32 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const DependencyGraph = require("./node-haste/DependencyGraph");
|
|
13
|
-
|
|
14
12
|
const Transformer = require("./DeltaBundler/Transformer");
|
|
15
13
|
|
|
14
|
+
const DependencyGraph = require("./node-haste/DependencyGraph");
|
|
15
|
+
|
|
16
16
|
class Bundler {
|
|
17
17
|
constructor(config, options) {
|
|
18
18
|
this._depGraphPromise = DependencyGraph.load(config, options);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
this._readyPromise = this._depGraphPromise
|
|
20
|
+
.then((dependencyGraph) => {
|
|
21
|
+
config.reporter.update({
|
|
22
|
+
type: "transformer_load_started",
|
|
23
|
+
});
|
|
22
24
|
this._transformer = new Transformer(
|
|
23
|
-
config,
|
|
25
|
+
config, // $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
24
26
|
dependencyGraph.getSha1.bind(dependencyGraph)
|
|
25
27
|
);
|
|
28
|
+
config.reporter.update({
|
|
29
|
+
type: "transformer_load_done",
|
|
30
|
+
});
|
|
26
31
|
})
|
|
27
|
-
.catch(error => {
|
|
32
|
+
.catch((error) => {
|
|
28
33
|
console.error("Failed to construct transformer: ", error);
|
|
34
|
+
config.reporter.update({
|
|
35
|
+
type: "transformer_load_failed",
|
|
36
|
+
error,
|
|
37
|
+
});
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -34,7 +43,7 @@ class Bundler {
|
|
|
34
43
|
|
|
35
44
|
this._transformer.end();
|
|
36
45
|
|
|
37
|
-
dependencyGraph.
|
|
46
|
+
dependencyGraph.end();
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
async getDependencyGraph() {
|
|
@@ -46,6 +55,10 @@ class Bundler {
|
|
|
46
55
|
// TODO: Remove this ugly hack!
|
|
47
56
|
await this._depGraphPromise;
|
|
48
57
|
return this._transformer.transformFile(filePath, transformOptions);
|
|
58
|
+
} // Waits for the bundler to become ready.
|
|
59
|
+
|
|
60
|
+
async ready() {
|
|
61
|
+
await this._readyPromise;
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
|
package/src/Bundler.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const DependencyGraph = require('./node-haste/DependencyGraph');
|
|
14
|
-
const Transformer = require('./DeltaBundler/Transformer');
|
|
15
|
-
|
|
16
|
-
import type {TransformOptions} from './DeltaBundler/Worker';
|
|
17
13
|
import type {TransformResultWithSource} from './DeltaBundler';
|
|
14
|
+
import type {TransformOptions} from './DeltaBundler/Worker';
|
|
18
15
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
19
16
|
|
|
17
|
+
const Transformer = require('./DeltaBundler/Transformer');
|
|
18
|
+
const DependencyGraph = require('./node-haste/DependencyGraph');
|
|
19
|
+
|
|
20
20
|
export type BundlerOptions = $ReadOnly<{|
|
|
21
21
|
hasReducedPerformance?: boolean,
|
|
22
22
|
watch?: boolean,
|
|
@@ -24,20 +24,28 @@ export type BundlerOptions = $ReadOnly<{|
|
|
|
24
24
|
|
|
25
25
|
class Bundler {
|
|
26
26
|
_depGraphPromise: Promise<DependencyGraph>;
|
|
27
|
+
_readyPromise: Promise<void>;
|
|
27
28
|
_transformer: Transformer;
|
|
28
29
|
|
|
29
30
|
constructor(config: ConfigT, options?: BundlerOptions) {
|
|
30
31
|
this._depGraphPromise = DependencyGraph.load(config, options);
|
|
31
32
|
|
|
32
|
-
this._depGraphPromise
|
|
33
|
+
this._readyPromise = this._depGraphPromise
|
|
33
34
|
.then((dependencyGraph: DependencyGraph) => {
|
|
35
|
+
config.reporter.update({type: 'transformer_load_started'});
|
|
34
36
|
this._transformer = new Transformer(
|
|
35
37
|
config,
|
|
38
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
36
39
|
dependencyGraph.getSha1.bind(dependencyGraph),
|
|
37
40
|
);
|
|
41
|
+
config.reporter.update({type: 'transformer_load_done'});
|
|
38
42
|
})
|
|
39
43
|
.catch(error => {
|
|
40
44
|
console.error('Failed to construct transformer: ', error);
|
|
45
|
+
config.reporter.update({
|
|
46
|
+
type: 'transformer_load_failed',
|
|
47
|
+
error,
|
|
48
|
+
});
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -45,7 +53,7 @@ class Bundler {
|
|
|
45
53
|
const dependencyGraph = await this._depGraphPromise;
|
|
46
54
|
|
|
47
55
|
this._transformer.end();
|
|
48
|
-
dependencyGraph.
|
|
56
|
+
dependencyGraph.end();
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
async getDependencyGraph(): Promise<DependencyGraph> {
|
|
@@ -62,6 +70,11 @@ class Bundler {
|
|
|
62
70
|
|
|
63
71
|
return this._transformer.transformFile(filePath, transformOptions);
|
|
64
72
|
}
|
|
73
|
+
|
|
74
|
+
// Waits for the bundler to become ready.
|
|
75
|
+
async ready(): Promise<void> {
|
|
76
|
+
await this._readyPromise;
|
|
77
|
+
}
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
module.exports = Bundler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
const {
|
|
13
13
|
initialTraverseDependencies,
|
|
14
14
|
reorderGraph,
|
|
15
|
-
traverseDependencies
|
|
15
|
+
traverseDependencies,
|
|
16
16
|
} = require("./traverseDependencies");
|
|
17
17
|
|
|
18
18
|
const { EventEmitter } = require("events");
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
20
|
* This class is in charge of calculating the delta of changed modules that
|
|
22
21
|
* happen between calls. To do so, it subscribes to file changes, so it can
|
|
23
22
|
* traverse the files that have been changed between calls and avoid having to
|
|
24
23
|
* traverse the whole dependency tree for trivial small changes.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
class DeltaCalculator extends EventEmitter {
|
|
27
27
|
_deletedFiles = new Set();
|
|
28
28
|
_modifiedFiles = new Set();
|
|
@@ -34,7 +34,8 @@ class DeltaCalculator extends EventEmitter {
|
|
|
34
34
|
this._graph = {
|
|
35
35
|
dependencies: new Map(),
|
|
36
36
|
entryPoints,
|
|
37
|
-
importBundleNames: new Set()
|
|
37
|
+
importBundleNames: new Set(),
|
|
38
|
+
transformOptions: this._options.transformOptions,
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
this._dependencyGraph
|
|
@@ -55,7 +56,8 @@ class DeltaCalculator extends EventEmitter {
|
|
|
55
56
|
this._graph = {
|
|
56
57
|
dependencies: new Map(),
|
|
57
58
|
entryPoints: this._graph.entryPoints,
|
|
58
|
-
importBundleNames: new Set()
|
|
59
|
+
importBundleNames: new Set(),
|
|
60
|
+
transformOptions: this._options.transformOptions,
|
|
59
61
|
};
|
|
60
62
|
this._modifiedFiles = new Set();
|
|
61
63
|
this._deletedFiles = new Set();
|
|
@@ -95,8 +97,8 @@ class DeltaCalculator extends EventEmitter {
|
|
|
95
97
|
// processed (since we haven't actually created any delta). If we do not
|
|
96
98
|
// do so, asking for a delta after an error will produce an empty Delta,
|
|
97
99
|
// which is not correct.
|
|
98
|
-
modifiedFiles.forEach(file => this._modifiedFiles.add(file));
|
|
99
|
-
deletedFiles.forEach(file => this._deletedFiles.add(file)); // If after an error the number of modules has changed, we could be in
|
|
100
|
+
modifiedFiles.forEach((file) => this._modifiedFiles.add(file));
|
|
101
|
+
deletedFiles.forEach((file) => this._deletedFiles.add(file)); // If after an error the number of modules has changed, we could be in
|
|
100
102
|
// a weird state. As a safe net we clean the dependency modules to force
|
|
101
103
|
// a clean traversal of the graph next time.
|
|
102
104
|
|
|
@@ -111,13 +113,13 @@ class DeltaCalculator extends EventEmitter {
|
|
|
111
113
|
|
|
112
114
|
if (reset) {
|
|
113
115
|
reorderGraph(this._graph, {
|
|
114
|
-
shallow
|
|
116
|
+
shallow,
|
|
115
117
|
});
|
|
116
118
|
return {
|
|
117
119
|
added: this._graph.dependencies,
|
|
118
120
|
modified: new Map(),
|
|
119
121
|
deleted: new Set(),
|
|
120
|
-
reset: true
|
|
122
|
+
reset: true,
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
|
|
@@ -167,16 +169,16 @@ class DeltaCalculator extends EventEmitter {
|
|
|
167
169
|
added,
|
|
168
170
|
modified: new Map(),
|
|
169
171
|
deleted: new Set(),
|
|
170
|
-
reset: true
|
|
172
|
+
reset: true,
|
|
171
173
|
};
|
|
172
174
|
} // If a file has been deleted, we want to invalidate any other file that
|
|
173
175
|
// depends on it, so we can process it and correctly return an error.
|
|
174
176
|
|
|
175
|
-
deletedFiles.forEach(filePath => {
|
|
177
|
+
deletedFiles.forEach((filePath) => {
|
|
176
178
|
const module = this._graph.dependencies.get(filePath);
|
|
177
179
|
|
|
178
180
|
if (module) {
|
|
179
|
-
module.inverseDependencies.forEach(path => {
|
|
181
|
+
module.inverseDependencies.forEach((path) => {
|
|
180
182
|
// Only mark the inverse dependency as modified if it's not already
|
|
181
183
|
// marked as deleted (in that case we can just ignore it).
|
|
182
184
|
if (!deletedFiles.has(path)) {
|
|
@@ -186,7 +188,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
186
188
|
}
|
|
187
189
|
}); // We only want to process files that are in the bundle.
|
|
188
190
|
|
|
189
|
-
const modifiedDependencies = Array.from(modifiedFiles).filter(filePath =>
|
|
191
|
+
const modifiedDependencies = Array.from(modifiedFiles).filter((filePath) =>
|
|
190
192
|
this._graph.dependencies.has(filePath)
|
|
191
193
|
); // No changes happened. Return empty delta.
|
|
192
194
|
|
|
@@ -195,7 +197,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
195
197
|
added: new Map(),
|
|
196
198
|
modified: new Map(),
|
|
197
199
|
deleted: new Set(),
|
|
198
|
-
reset: false
|
|
200
|
+
reset: false,
|
|
199
201
|
};
|
|
200
202
|
}
|
|
201
203
|
|
|
@@ -208,7 +210,7 @@ class DeltaCalculator extends EventEmitter {
|
|
|
208
210
|
added,
|
|
209
211
|
modified,
|
|
210
212
|
deleted,
|
|
211
|
-
reset: false
|
|
213
|
+
reset: false,
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
216
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
import type DependencyGraph from '../node-haste/DependencyGraph';
|
|
14
|
+
import type {DeltaResult, Graph, Options} from './types.flow';
|
|
15
|
+
|
|
13
16
|
const {
|
|
14
17
|
initialTraverseDependencies,
|
|
15
18
|
reorderGraph,
|
|
@@ -17,9 +20,6 @@ const {
|
|
|
17
20
|
} = require('./traverseDependencies');
|
|
18
21
|
const {EventEmitter} = require('events');
|
|
19
22
|
|
|
20
|
-
import type DependencyGraph from '../node-haste/DependencyGraph';
|
|
21
|
-
import type {DeltaResult, Graph, Options} from './types.flow';
|
|
22
|
-
|
|
23
23
|
/**
|
|
24
24
|
* This class is in charge of calculating the delta of changed modules that
|
|
25
25
|
* happen between calls. To do so, it subscribes to file changes, so it can
|
|
@@ -50,6 +50,7 @@ class DeltaCalculator<T> extends EventEmitter {
|
|
|
50
50
|
dependencies: new Map(),
|
|
51
51
|
entryPoints,
|
|
52
52
|
importBundleNames: new Set(),
|
|
53
|
+
transformOptions: this._options.transformOptions,
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
this._dependencyGraph
|
|
@@ -72,6 +73,7 @@ class DeltaCalculator<T> extends EventEmitter {
|
|
|
72
73
|
dependencies: new Map(),
|
|
73
74
|
entryPoints: this._graph.entryPoints,
|
|
74
75
|
importBundleNames: new Set(),
|
|
76
|
+
transformOptions: this._options.transformOptions,
|
|
75
77
|
};
|
|
76
78
|
this._modifiedFiles = new Set();
|
|
77
79
|
this._deletedFiles = new Set();
|
|
@@ -226,9 +228,9 @@ class DeltaCalculator<T> extends EventEmitter {
|
|
|
226
228
|
});
|
|
227
229
|
|
|
228
230
|
// We only want to process files that are in the bundle.
|
|
229
|
-
const modifiedDependencies = Array.from(
|
|
230
|
-
|
|
231
|
-
)
|
|
231
|
+
const modifiedDependencies = Array.from(modifiedFiles).filter(
|
|
232
|
+
(filePath: string) => this._graph.dependencies.has(filePath),
|
|
233
|
+
);
|
|
232
234
|
|
|
233
235
|
// No changes happened. Return empty delta.
|
|
234
236
|
if (modifiedDependencies.length === 0) {
|