@granite-js/mpack 0.0.0-dev-20250725013859
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/LICENSE +202 -0
- package/README.md +24 -0
- package/dist/bundler/Bundler.d.ts +24 -0
- package/dist/bundler/Bundler.js +180 -0
- package/dist/bundler/PluginDriver.d.ts +9 -0
- package/dist/bundler/PluginDriver.js +47 -0
- package/dist/bundler/index.d.ts +1 -0
- package/dist/bundler/index.js +22 -0
- package/dist/bundler/internal/presets.d.ts +18 -0
- package/dist/bundler/internal/presets.js +103 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.d.ts +12 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.js +74 -0
- package/dist/bundler/plugins/buildStatusPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/buildStatusPlugin/index.js +28 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/aliasResolver.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/aliasResolver.js +89 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/dependencyAliasPlugin.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/dependencyAliasPlugin.js +43 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/index.js +28 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/protocolResolver.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/protocolResolver.js +53 -0
- package/dist/bundler/plugins/index.d.ts +4 -0
- package/dist/bundler/plugins/index.js +28 -0
- package/dist/bundler/plugins/requireContextPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/requireContextPlugin/index.js +28 -0
- package/dist/bundler/plugins/requireContextPlugin/requireContextPlugin.d.ts +6 -0
- package/dist/bundler/plugins/requireContextPlugin/requireContextPlugin.js +101 -0
- package/dist/bundler/plugins/requireContextPlugin/scripts.d.ts +56 -0
- package/dist/bundler/plugins/requireContextPlugin/scripts.js +65 -0
- package/dist/bundler/plugins/shared/swc.d.ts +11 -0
- package/dist/bundler/plugins/shared/swc.js +70 -0
- package/dist/bundler/plugins/transformPlugin/helpers/preludeScript.d.ts +23 -0
- package/dist/bundler/plugins/transformPlugin/helpers/preludeScript.js +79 -0
- package/dist/bundler/plugins/transformPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/transformPlugin/index.js +28 -0
- package/dist/bundler/plugins/transformPlugin/steps/createCacheSteps.d.ts +10 -0
- package/dist/bundler/plugins/transformPlugin/steps/createCacheSteps.js +56 -0
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.js +120 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.d.ts +6 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.js +91 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.js +100 -0
- package/dist/bundler/plugins/transformPlugin/transformPlugin.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/transformPlugin.js +88 -0
- package/dist/bundler/plugins/types.d.ts +7 -0
- package/dist/bundler/plugins/types.js +16 -0
- package/dist/bundler/types.d.ts +16 -0
- package/dist/bundler/types.js +16 -0
- package/dist/cache/Cache.d.ts +25 -0
- package/dist/cache/Cache.js +87 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +22 -0
- package/dist/constants/index.d.ts +20 -0
- package/dist/constants/index.js +91 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +56 -0
- package/dist/logger/Logger.d.ts +17 -0
- package/dist/logger/Logger.js +115 -0
- package/dist/logger/clientLogger.d.ts +2 -0
- package/dist/logger/clientLogger.js +49 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.js +31 -0
- package/dist/metro/assetRegistry.d.ts +12 -0
- package/dist/metro/assetRegistry.js +57 -0
- package/dist/metro/enhancedResolver.d.ts +7 -0
- package/dist/metro/enhancedResolver.js +127 -0
- package/dist/metro/getMetroConfig.d.ts +27 -0
- package/dist/metro/getMetroConfig.js +137 -0
- package/dist/metro/getMonorepoRoot.d.ts +4 -0
- package/dist/metro/getMonorepoRoot.js +80 -0
- package/dist/metro/index.d.ts +3 -0
- package/dist/metro/index.js +24 -0
- package/dist/metro/pnpapi.d.ts +6 -0
- package/dist/metro/pnpapi.js +32 -0
- package/dist/metro/runBuild.d.ts +10 -0
- package/dist/metro/runBuild.js +57 -0
- package/dist/metro/types.d.ts +92 -0
- package/dist/metro/types.js +16 -0
- package/dist/operations/constants.d.ts +3 -0
- package/dist/operations/constants.js +34 -0
- package/dist/operations/createDebuggerMiddleware.d.ts +11 -0
- package/dist/operations/createDebuggerMiddleware.js +128 -0
- package/dist/operations/experimental/StartMenuHandler.d.ts +13 -0
- package/dist/operations/experimental/StartMenuHandler.js +86 -0
- package/dist/operations/experimental/runServer.d.ts +13 -0
- package/dist/operations/experimental/runServer.js +130 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +26 -0
- package/dist/operations/openDebugger.d.ts +1 -0
- package/dist/operations/openDebugger.js +73 -0
- package/dist/operations/runBundle.d.ts +6 -0
- package/dist/operations/runBundle.js +60 -0
- package/dist/operations/runServer.d.ts +13 -0
- package/dist/operations/runServer.js +131 -0
- package/dist/performance/Performance.d.ts +23 -0
- package/dist/performance/Performance.js +121 -0
- package/dist/performance/index.d.ts +2 -0
- package/dist/performance/index.js +31 -0
- package/dist/performance/printSummary.d.ts +5 -0
- package/dist/performance/printSummary.js +58 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +22 -0
- package/dist/plugins/statusPlugin.d.ts +2 -0
- package/dist/plugins/statusPlugin.js +64 -0
- package/dist/server/DevServer.d.ts +26 -0
- package/dist/server/DevServer.js +215 -0
- package/dist/server/constants.d.ts +1 -0
- package/dist/server/constants.js +28 -0
- package/dist/server/debugger/DebuggerEventHandler.d.ts +41 -0
- package/dist/server/debugger/DebuggerEventHandler.js +169 -0
- package/dist/server/debugger/parseDomain.d.ts +1 -0
- package/dist/server/debugger/parseDomain.js +30 -0
- package/dist/server/helpers/createBundlerForDevServer.d.ts +8 -0
- package/dist/server/helpers/createBundlerForDevServer.js +48 -0
- package/dist/server/helpers/mergeBundles.d.ts +7 -0
- package/dist/server/helpers/mergeBundles.js +129 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +22 -0
- package/dist/server/middlewares/createLiveReloadMiddleware.d.ts +10 -0
- package/dist/server/middlewares/createLiveReloadMiddleware.js +129 -0
- package/dist/server/middlewares/index.d.ts +1 -0
- package/dist/server/middlewares/index.js +22 -0
- package/dist/server/plugins/debuggerPlugin.d.ts +7 -0
- package/dist/server/plugins/debuggerPlugin.js +68 -0
- package/dist/server/plugins/index.d.ts +5 -0
- package/dist/server/plugins/index.js +30 -0
- package/dist/server/plugins/indexPagePlugin.d.ts +4 -0
- package/dist/server/plugins/indexPagePlugin.js +52 -0
- package/dist/server/plugins/reply.d.ts +3 -0
- package/dist/server/plugins/reply.js +38 -0
- package/dist/server/plugins/serveBundlePlugin.d.ts +8 -0
- package/dist/server/plugins/serveBundlePlugin.js +118 -0
- package/dist/server/plugins/statusPlugin.d.ts +7 -0
- package/dist/server/plugins/statusPlugin.js +50 -0
- package/dist/server/plugins/symbolicatePlugin/index.d.ts +1 -0
- package/dist/server/plugins/symbolicatePlugin/index.js +28 -0
- package/dist/server/plugins/symbolicatePlugin/parseStackFrame.d.ts +25 -0
- package/dist/server/plugins/symbolicatePlugin/parseStackFrame.js +51 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicate.d.ts +25 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicate.js +84 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicatePlugin.d.ts +8 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicatePlugin.js +77 -0
- package/dist/server/types.d.ts +92 -0
- package/dist/server/types.js +16 -0
- package/dist/server/wss/WebSocketServerDelegate.d.ts +23 -0
- package/dist/server/wss/WebSocketServerDelegate.js +50 -0
- package/dist/server/wss/WebSocketServerRouter.d.ts +8 -0
- package/dist/server/wss/WebSocketServerRouter.js +66 -0
- package/dist/server/wss/index.d.ts +2 -0
- package/dist/server/wss/index.js +24 -0
- package/dist/shared/PersistentStorage.d.ts +21 -0
- package/dist/shared/PersistentStorage.js +68 -0
- package/dist/transformer/AsyncTransformPipeline.d.ts +4 -0
- package/dist/transformer/AsyncTransformPipeline.js +58 -0
- package/dist/transformer/TransformPipeline.d.ts +37 -0
- package/dist/transformer/TransformPipeline.js +64 -0
- package/dist/transformer/index.d.ts +1 -0
- package/dist/transformer/index.js +28 -0
- package/dist/types/BuildConfig.d.ts +187 -0
- package/dist/types/BuildConfig.js +16 -0
- package/dist/types/BundlerConfig.d.ts +23 -0
- package/dist/types/BundlerConfig.js +16 -0
- package/dist/types/DevServer.d.ts +10 -0
- package/dist/types/DevServer.js +16 -0
- package/dist/types/Id.d.ts +3 -0
- package/dist/types/Id.js +16 -0
- package/dist/types/Plugin.d.ts +28 -0
- package/dist/types/Plugin.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/schemas/buildConfigSchema.d.ts +131 -0
- package/dist/types/schemas/buildConfigSchema.js +70 -0
- package/dist/types/schemas/index.d.ts +1 -0
- package/dist/types/schemas/index.js +22 -0
- package/dist/utils/cleanupOutputDirectory.d.ts +1 -0
- package/dist/utils/cleanupOutputDirectory.js +53 -0
- package/dist/utils/defineStepName.d.ts +2 -0
- package/dist/utils/defineStepName.js +30 -0
- package/dist/utils/esbuildUtils.d.ts +1 -0
- package/dist/utils/esbuildUtils.js +45 -0
- package/dist/utils/getBundleName.d.ts +1 -0
- package/dist/utils/getBundleName.js +30 -0
- package/dist/utils/getBundleOutputs.d.ts +5 -0
- package/dist/utils/getBundleOutputs.js +49 -0
- package/dist/utils/getId.d.ts +2 -0
- package/dist/utils/getId.js +34 -0
- package/dist/utils/getSourcemapName.d.ts +1 -0
- package/dist/utils/getSourcemapName.js +30 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/isDebugMode.d.ts +1 -0
- package/dist/utils/isDebugMode.js +30 -0
- package/dist/utils/md5.d.ts +1 -0
- package/dist/utils/md5.js +41 -0
- package/dist/utils/mergeBabel.d.ts +2 -0
- package/dist/utils/mergeBabel.js +45 -0
- package/dist/utils/mergeBuildConfigs.d.ts +2 -0
- package/dist/utils/mergeBuildConfigs.js +50 -0
- package/dist/utils/mergeEsbuild.d.ts +2 -0
- package/dist/utils/mergeEsbuild.js +54 -0
- package/dist/utils/mergeExtra.d.ts +1 -0
- package/dist/utils/mergeExtra.js +39 -0
- package/dist/utils/mergeResolver.d.ts +2 -0
- package/dist/utils/mergeResolver.js +45 -0
- package/dist/utils/mergeSwc.d.ts +2 -0
- package/dist/utils/mergeSwc.js +43 -0
- package/dist/utils/mergeTransformer.d.ts +2 -0
- package/dist/utils/mergeTransformer.js +69 -0
- package/dist/utils/printLogo.d.ts +1 -0
- package/dist/utils/printLogo.js +56 -0
- package/dist/utils/printSummary.d.ts +7 -0
- package/dist/utils/printSummary.js +55 -0
- package/dist/utils/progressBar.d.ts +9 -0
- package/dist/utils/progressBar.js +97 -0
- package/dist/utils/promiseHandler.d.ts +12 -0
- package/dist/utils/promiseHandler.js +54 -0
- package/dist/utils/replaceModulePath.d.ts +1 -0
- package/dist/utils/replaceModulePath.js +31 -0
- package/dist/utils/replacePlaceholders.d.ts +1 -0
- package/dist/utils/replacePlaceholders.js +33 -0
- package/dist/utils/stripExtension.d.ts +1 -0
- package/dist/utils/stripExtension.js +41 -0
- package/dist/utils/writeBundle.d.ts +2 -0
- package/dist/utils/writeBundle.js +52 -0
- package/dist/vendors/@react-native/dev-middleware/Device.d.ts +5 -0
- package/dist/vendors/@react-native/dev-middleware/Device.js +33 -0
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.d.ts +31 -0
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.js +169 -0
- package/dist/vendors/@react-native/dev-middleware/index.d.ts +3 -0
- package/dist/vendors/@react-native/dev-middleware/index.js +26 -0
- package/dist/vendors/@react-native/dev-middleware/types.d.ts +54 -0
- package/dist/vendors/@react-native/dev-middleware/types.js +16 -0
- package/dist/vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.d.ts +23 -0
- package/dist/vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.js +47 -0
- package/dist/vendors/@react-native-community/cli-server-api/index.d.ts +1 -0
- package/dist/vendors/@react-native-community/cli-server-api/index.js +22 -0
- package/dist/vendors/index.d.ts +27 -0
- package/dist/vendors/index.js +63 -0
- package/dist/vendors/metro/src/Assets.js +159 -0
- package/dist/vendors/metro/src/Bundler/util.js +131 -0
- package/dist/vendors/metro/src/Bundler.js +43 -0
- package/dist/vendors/metro/src/DeltaBundler/DeltaCalculator.js +176 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/baseBytecodeBundle.js +61 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/baseJSBundle.js +45 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getAllFiles.js +30 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getAssets.js +23 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getExplodedSourceMap.js +17 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js +87 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/bytecode.js +51 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +6 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +16 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +21 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/js.js +43 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +13 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/processModules.js +13 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/hmrJSBundle.js +66 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js +63 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapObject.js +18 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapString.js +8 -0
- package/dist/vendors/metro/src/DeltaBundler/Transformer.js +133 -0
- package/dist/vendors/metro/src/DeltaBundler/Worker.flow.js +64 -0
- package/dist/vendors/metro/src/DeltaBundler/Worker.js +6 -0
- package/dist/vendors/metro/src/DeltaBundler/WorkerFarm.js +128 -0
- package/dist/vendors/metro/src/DeltaBundler/getTransformCacheKey.js +20 -0
- package/dist/vendors/metro/src/DeltaBundler/graphOperations.js +420 -0
- package/dist/vendors/metro/src/DeltaBundler/mergeDeltas.js +52 -0
- package/dist/vendors/metro/src/DeltaBundler/types.flow.js +24 -0
- package/dist/vendors/metro/src/DeltaBundler.js +56 -0
- package/dist/vendors/metro/src/HmrServer.js +224 -0
- package/dist/vendors/metro/src/IncrementalBundler/GraphNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler/ResourceNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler/RevisionNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler.js +213 -0
- package/dist/vendors/metro/src/ModuleGraph/module.js +14 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/HasteFS.js +66 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/Module.js +22 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/ModuleCache.js +43 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/Package.js +81 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/node-haste.flow.js +1 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/node-haste.js +127 -0
- package/dist/vendors/metro/src/ModuleGraph/output/indexed-ram-bundle.js +71 -0
- package/dist/vendors/metro/src/ModuleGraph/output/multiple-files-ram-bundle.js +53 -0
- package/dist/vendors/metro/src/ModuleGraph/output/plain-bundle.js +36 -0
- package/dist/vendors/metro/src/ModuleGraph/output/reverse-dependency-map-references.js +53 -0
- package/dist/vendors/metro/src/ModuleGraph/output/util.js +168 -0
- package/dist/vendors/metro/src/ModuleGraph/silent-console.js +5 -0
- package/dist/vendors/metro/src/ModuleGraph/types.flow.js +1 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/JsFileWrapping.js +87 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/Platforms.js +3 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/collectDependencies.js +440 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/generate.js +21 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/generateImportNames.js +19 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/mergeSourceMaps.js +29 -0
- package/dist/vendors/metro/src/Server/MultipartResponse.js +57 -0
- package/dist/vendors/metro/src/Server/symbolicate.js +109 -0
- package/dist/vendors/metro/src/Server.js +855 -0
- package/dist/vendors/metro/src/cli-utils.js +14 -0
- package/dist/vendors/metro/src/cli.js +9 -0
- package/dist/vendors/metro/src/commands/build.js +67 -0
- package/dist/vendors/metro/src/commands/dependencies.js +75 -0
- package/dist/vendors/metro/src/commands/serve.js +56 -0
- package/dist/vendors/metro/src/index.d.ts +8 -0
- package/dist/vendors/metro/src/index.flow.js +279 -0
- package/dist/vendors/metro/src/index.js +6 -0
- package/dist/vendors/metro/src/isPnP.js +13 -0
- package/dist/vendors/metro/src/lib/BatchProcessor.js +69 -0
- package/dist/vendors/metro/src/lib/CountingSet.js +98 -0
- package/dist/vendors/metro/src/lib/JsonReporter.js +21 -0
- package/dist/vendors/metro/src/lib/RamBundleParser.js +36 -0
- package/dist/vendors/metro/src/lib/ReportableEvent.d.ts +152 -0
- package/dist/vendors/metro/src/lib/TerminalReporter.d.ts +18 -0
- package/dist/vendors/metro/src/lib/TerminalReporter.js +258 -0
- package/dist/vendors/metro/src/lib/bundleToBytecode.js +40 -0
- package/dist/vendors/metro/src/lib/bundleToString.js +22 -0
- package/dist/vendors/metro/src/lib/contextModule.js +73 -0
- package/dist/vendors/metro/src/lib/contextModuleTemplates.js +116 -0
- package/dist/vendors/metro/src/lib/countLines.js +4 -0
- package/dist/vendors/metro/src/lib/createModuleIdFactory.js +14 -0
- package/dist/vendors/metro/src/lib/createWebsocketServer.js +54 -0
- package/dist/vendors/metro/src/lib/debounceAsyncQueue.js +33 -0
- package/dist/vendors/metro/src/lib/formatBundlingError.js +76 -0
- package/dist/vendors/metro/src/lib/getAppendScripts.js +131 -0
- package/dist/vendors/metro/src/lib/getGraphId.js +27 -0
- package/dist/vendors/metro/src/lib/getMaxWorkers.js +6 -0
- package/dist/vendors/metro/src/lib/getPreludeCode.js +32 -0
- package/dist/vendors/metro/src/lib/getPrependedScripts.js +93 -0
- package/dist/vendors/metro/src/lib/logToConsole.js +46 -0
- package/dist/vendors/metro/src/lib/parseCustomResolverOptions.js +13 -0
- package/dist/vendors/metro/src/lib/parseCustomTransformOptions.js +13 -0
- package/dist/vendors/metro/src/lib/parseOptionsFromUrl.js +50 -0
- package/dist/vendors/metro/src/lib/relativizeSourceMap.js +14 -0
- package/dist/vendors/metro/src/lib/reporting.js +26 -0
- package/dist/vendors/metro/src/lib/splitBundleOptions.js +32 -0
- package/dist/vendors/metro/src/lib/transformHelpers.js +112 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph/ModuleResolution.js +221 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph/createHasteMap.js +71 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph.js +223 -0
- package/dist/vendors/metro/src/node-haste/Module.js +21 -0
- package/dist/vendors/metro/src/node-haste/ModuleCache.js +81 -0
- package/dist/vendors/metro/src/node-haste/Package.js +98 -0
- package/dist/vendors/metro/src/node-haste/lib/AssetPaths.js +41 -0
- package/dist/vendors/metro/src/node-haste/lib/parsePlatformFilePath.js +19 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/as-assets.js +61 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/as-indexed-file.js +115 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +23 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/magic-number.js +2 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/util.js +94 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/write-sourcemap.js +12 -0
- package/dist/vendors/metro/src/shared/output/RamBundle.js +18 -0
- package/dist/vendors/metro/src/shared/output/bundle.flow.js +42 -0
- package/dist/vendors/metro/src/shared/output/bundle.js +6 -0
- package/dist/vendors/metro/src/shared/output/meta.js +31 -0
- package/dist/vendors/metro/src/shared/output/unbundle.js +2 -0
- package/dist/vendors/metro/src/shared/output/writeFile.js +6 -0
- package/dist/vendors/metro/src/shared/types.flow.js +1 -0
- package/dist/vendors/metro-config/src/configTypes.flow.js +1 -0
- package/dist/vendors/metro-config/src/defaults/defaults.js +66 -0
- package/dist/vendors/metro-config/src/defaults/exclusionList.d.ts +3 -0
- package/dist/vendors/metro-config/src/defaults/exclusionList.js +17 -0
- package/dist/vendors/metro-config/src/defaults/index.d.ts +5 -0
- package/dist/vendors/metro-config/src/defaults/index.js +161 -0
- package/dist/vendors/metro-config/src/defaults/validConfig.js +28 -0
- package/dist/vendors/metro-config/src/index.js +9 -0
- package/dist/vendors/metro-config/src/loadConfig.d.ts +4 -0
- package/dist/vendors/metro-config/src/loadConfig.js +188 -0
- package/dist/vendors/metro-core/src/Logger.js +62 -0
- package/dist/vendors/metro-core/src/Terminal.d.ts +30 -0
- package/dist/vendors/metro-core/src/Terminal.js +100 -0
- package/dist/vendors/metro-core/src/canonicalize.js +17 -0
- package/dist/vendors/metro-core/src/errors/AmbiguousModuleResolutionError.js +11 -0
- package/dist/vendors/metro-core/src/errors/PackageResolutionError.js +18 -0
- package/dist/vendors/metro-core/src/errors.js +7 -0
- package/dist/vendors/metro-core/src/index.js +11 -0
- package/dist/vendors/metro-inspector-proxy/src/Device.js +398 -0
- package/dist/vendors/metro-inspector-proxy/src/InspectorProxy.d.ts +21 -0
- package/dist/vendors/metro-inspector-proxy/src/InspectorProxy.js +153 -0
- package/dist/vendors/metro-inspector-proxy/src/cli.js +15 -0
- package/dist/vendors/metro-inspector-proxy/src/index.js +23 -0
- package/dist/vendors/metro-inspector-proxy/src/types.js +1 -0
- package/dist/vendors/metro-transform-worker/src/index.js +429 -0
- package/dist/vendors/metro-transform-worker/src/utils/assetTransformer.js +20 -0
- package/dist/vendors/metro-transform-worker/src/utils/getMinifier.js +11 -0
- package/package.json +163 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const util = require("util");
|
|
4
|
+
const groupStack = [];
|
|
5
|
+
let collapsedGuardTimer;
|
|
6
|
+
module.exports = (terminal, level, mode, ...data) => {
|
|
7
|
+
const logFunction = console[level] && level !== "trace" ? level : "log";
|
|
8
|
+
const color = level === "error" ? chalk.inverse.red : level === "warn" ? chalk.inverse.yellow : chalk.inverse.white;
|
|
9
|
+
if (level === "group") {
|
|
10
|
+
groupStack.push(level);
|
|
11
|
+
} else if (level === "groupCollapsed") {
|
|
12
|
+
groupStack.push(level);
|
|
13
|
+
clearTimeout(collapsedGuardTimer);
|
|
14
|
+
collapsedGuardTimer = setTimeout(() => {
|
|
15
|
+
if (groupStack.includes("groupCollapsed")) {
|
|
16
|
+
terminal.log(
|
|
17
|
+
chalk.inverse.yellow.bold(" WARN "),
|
|
18
|
+
"Expected `console.groupEnd` to be called after `console.groupCollapsed`."
|
|
19
|
+
);
|
|
20
|
+
groupStack.length = 0;
|
|
21
|
+
}
|
|
22
|
+
}, 3e3);
|
|
23
|
+
return;
|
|
24
|
+
} else if (level === "groupEnd") {
|
|
25
|
+
groupStack.pop();
|
|
26
|
+
if (!groupStack.length) {
|
|
27
|
+
clearTimeout(collapsedGuardTimer);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!groupStack.includes("groupCollapsed")) {
|
|
32
|
+
const lastItem = data[data.length - 1];
|
|
33
|
+
if (typeof lastItem === "string") {
|
|
34
|
+
data[data.length - 1] = lastItem.trimEnd();
|
|
35
|
+
}
|
|
36
|
+
const modePrefix = !mode || mode == "BRIDGE" ? "" : `(${mode.toUpperCase()}) `;
|
|
37
|
+
terminal.log(
|
|
38
|
+
color.bold(` ${modePrefix}${logFunction.toUpperCase()} `) + "".padEnd(groupStack.length * 2, " "),
|
|
39
|
+
// `util.format` actually accepts any arguments.
|
|
40
|
+
// If the first argument is a string, it tries to format it.
|
|
41
|
+
// Otherwise, it just concatenates all arguments.
|
|
42
|
+
// $FlowIssue[incompatible-call] util.format expected the first argument to be a string
|
|
43
|
+
util.format(...data)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const nullthrows = require("nullthrows");
|
|
3
|
+
const PREFIX = "resolver.";
|
|
4
|
+
module.exports = function parseCustomResolverOptions(urlObj) {
|
|
5
|
+
const customResolverOptions = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
const query = nullthrows(urlObj.query);
|
|
7
|
+
Object.keys(query).forEach((key) => {
|
|
8
|
+
if (key.startsWith(PREFIX)) {
|
|
9
|
+
customResolverOptions[key.substr(PREFIX.length)] = query[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return customResolverOptions;
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const nullthrows = require("nullthrows");
|
|
3
|
+
const PREFIX = "transform.";
|
|
4
|
+
module.exports = function parseCustomTransformOptions(urlObj) {
|
|
5
|
+
const customTransformOptions = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
const query = nullthrows(urlObj.query);
|
|
7
|
+
Object.keys(query).forEach((key) => {
|
|
8
|
+
if (key.startsWith(PREFIX)) {
|
|
9
|
+
customTransformOptions[key.substr(PREFIX.length)] = query[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return customTransformOptions;
|
|
13
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const parsePlatformFilePath = require("../node-haste/lib/parsePlatformFilePath");
|
|
3
|
+
const parseCustomResolverOptions = require("./parseCustomResolverOptions");
|
|
4
|
+
const parseCustomTransformOptions = require("./parseCustomTransformOptions");
|
|
5
|
+
const nullthrows = require("nullthrows");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const url = require("url");
|
|
8
|
+
const getBoolean = (query, opt, defaultValue) => query[opt] == null ? defaultValue : query[opt] === "true" || query[opt] === "1";
|
|
9
|
+
const getNumber = (query, opt, defaultValue) => {
|
|
10
|
+
const number = parseInt(query[opt], 10);
|
|
11
|
+
return Number.isNaN(number) ? defaultValue : number;
|
|
12
|
+
};
|
|
13
|
+
const getBundleType = (bundleType) => bundleType === "map" ? bundleType : "bundle";
|
|
14
|
+
const getTransformProfile = (transformProfile) => transformProfile === "hermes-stable" || transformProfile === "hermes-canary" ? transformProfile : "default";
|
|
15
|
+
module.exports = function parseOptionsFromUrl(requestUrl, platforms, bytecodeVersion) {
|
|
16
|
+
const parsedURL = nullthrows(url.parse(requestUrl, true));
|
|
17
|
+
const query = nullthrows(parsedURL.query);
|
|
18
|
+
const pathname = query.bundleEntry || (parsedURL.pathname != null ? decodeURIComponent(parsedURL.pathname) : "");
|
|
19
|
+
const platform = query.platform || parsePlatformFilePath(pathname, platforms).platform;
|
|
20
|
+
const bundleType = getBundleType(path.extname(pathname).substr(1));
|
|
21
|
+
const runtimeBytecodeVersion = getNumber(query, "runtimeBytecodeVersion", null);
|
|
22
|
+
return {
|
|
23
|
+
bundleType,
|
|
24
|
+
runtimeBytecodeVersion: bytecodeVersion === runtimeBytecodeVersion ? bytecodeVersion : null,
|
|
25
|
+
customResolverOptions: parseCustomResolverOptions(parsedURL),
|
|
26
|
+
customTransformOptions: parseCustomTransformOptions(parsedURL),
|
|
27
|
+
dev: getBoolean(query, "dev", true),
|
|
28
|
+
entryFile: pathname.replace(/^(?:\.?\/)?/, "./").replace(/\.[^/.]+$/, ""),
|
|
29
|
+
excludeSource: getBoolean(query, "excludeSource", false),
|
|
30
|
+
hot: true,
|
|
31
|
+
inlineSourceMap: getBoolean(query, "inlineSourceMap", false),
|
|
32
|
+
minify: getBoolean(query, "minify", false),
|
|
33
|
+
modulesOnly: getBoolean(query, "modulesOnly", false),
|
|
34
|
+
onProgress: null,
|
|
35
|
+
platform,
|
|
36
|
+
runModule: getBoolean(query, "runModule", true),
|
|
37
|
+
shallow: getBoolean(query, "shallow", false),
|
|
38
|
+
sourceMapUrl: url.format({
|
|
39
|
+
...parsedURL,
|
|
40
|
+
// The Chrome Debugger loads bundles via Blob urls, whose
|
|
41
|
+
// protocol is blob:http. This breaks loading source maps through
|
|
42
|
+
// protocol-relative URLs, which is why we must force the HTTP protocol
|
|
43
|
+
// when loading the bundle for either Android or iOS.
|
|
44
|
+
protocol: platform != null && platform.match(/^(android|ios)$/) ? "http" : "",
|
|
45
|
+
pathname: pathname.replace(/\.(bundle|delta)$/, ".map")
|
|
46
|
+
}),
|
|
47
|
+
sourceUrl: requestUrl,
|
|
48
|
+
unstable_transformProfile: getTransformProfile(query.unstable_transformProfile)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
function relativizeSourceMapInline(sourceMap, sourcesRoot) {
|
|
4
|
+
if (sourceMap.mappings === void 0) {
|
|
5
|
+
for (let i = 0; i < sourceMap.sections.length; i++) {
|
|
6
|
+
relativizeSourceMapInline(sourceMap.sections[i].map, sourcesRoot);
|
|
7
|
+
}
|
|
8
|
+
} else {
|
|
9
|
+
for (let i = 0; i < sourceMap.sources.length; i++) {
|
|
10
|
+
sourceMap.sources[i] = path.relative(sourcesRoot, sourceMap.sources[i]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
module.exports = relativizeSourceMapInline;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const stripAnsi = require("strip-ansi");
|
|
4
|
+
const util = require("util");
|
|
5
|
+
function logWarning(terminal, format, ...args) {
|
|
6
|
+
const str = util.format(format, ...args);
|
|
7
|
+
terminal.log("%s: %s", chalk.yellow("warning"), str);
|
|
8
|
+
}
|
|
9
|
+
function logError(terminal, format, ...args) {
|
|
10
|
+
terminal.log(
|
|
11
|
+
"%s: %s",
|
|
12
|
+
chalk.red("error"),
|
|
13
|
+
// Syntax errors may have colors applied for displaying code frames
|
|
14
|
+
// in various places outside of where Metro is currently running.
|
|
15
|
+
// If the current terminal does not support color, we'll strip the colors
|
|
16
|
+
// here.
|
|
17
|
+
util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
const nullReporter = { update() {
|
|
21
|
+
} };
|
|
22
|
+
module.exports = {
|
|
23
|
+
logWarning,
|
|
24
|
+
logError,
|
|
25
|
+
nullReporter
|
|
26
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function splitBundleOptions(options) {
|
|
3
|
+
return {
|
|
4
|
+
entryFile: options.entryFile,
|
|
5
|
+
resolverOptions: {
|
|
6
|
+
customResolverOptions: options.customResolverOptions
|
|
7
|
+
},
|
|
8
|
+
transformOptions: {
|
|
9
|
+
customTransformOptions: options.customTransformOptions,
|
|
10
|
+
dev: options.dev,
|
|
11
|
+
hot: options.hot,
|
|
12
|
+
minify: options.minify,
|
|
13
|
+
platform: options.platform,
|
|
14
|
+
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
15
|
+
type: "module",
|
|
16
|
+
unstable_transformProfile: options.unstable_transformProfile
|
|
17
|
+
},
|
|
18
|
+
serializerOptions: {
|
|
19
|
+
excludeSource: options.excludeSource,
|
|
20
|
+
inlineSourceMap: options.inlineSourceMap,
|
|
21
|
+
modulesOnly: options.modulesOnly,
|
|
22
|
+
runModule: options.runModule,
|
|
23
|
+
sourceMapUrl: options.sourceMapUrl,
|
|
24
|
+
sourceUrl: options.sourceUrl
|
|
25
|
+
},
|
|
26
|
+
graphOptions: {
|
|
27
|
+
shallow: options.shallow
|
|
28
|
+
},
|
|
29
|
+
onProgress: options.onProgress
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
module.exports = splitBundleOptions;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_contextModuleTemplates = require("./contextModuleTemplates");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const baseIgnoredInlineRequires = ["React", "react", "react-native"];
|
|
5
|
+
async function calcTransformerOptions(entryFiles, bundler, deltaBundler, config, options, resolverOptions) {
|
|
6
|
+
const baseOptions = {
|
|
7
|
+
customTransformOptions: options.customTransformOptions,
|
|
8
|
+
dev: options.dev,
|
|
9
|
+
hot: options.hot,
|
|
10
|
+
inlineRequires: false,
|
|
11
|
+
inlinePlatform: true,
|
|
12
|
+
minify: options.minify,
|
|
13
|
+
platform: options.platform,
|
|
14
|
+
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
15
|
+
unstable_transformProfile: options.unstable_transformProfile
|
|
16
|
+
};
|
|
17
|
+
if (options.type === "script") {
|
|
18
|
+
return {
|
|
19
|
+
...baseOptions,
|
|
20
|
+
type: "script"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const getDependencies = async (path2) => {
|
|
24
|
+
const dependencies = await deltaBundler.getDependencies([path2], {
|
|
25
|
+
resolve: await getResolveDependencyFn(bundler, options.platform, resolverOptions),
|
|
26
|
+
transform: await getTransformFn(
|
|
27
|
+
[path2],
|
|
28
|
+
bundler,
|
|
29
|
+
deltaBundler,
|
|
30
|
+
config,
|
|
31
|
+
{
|
|
32
|
+
...options,
|
|
33
|
+
minify: false
|
|
34
|
+
},
|
|
35
|
+
resolverOptions
|
|
36
|
+
),
|
|
37
|
+
transformOptions: options,
|
|
38
|
+
onProgress: null,
|
|
39
|
+
experimentalImportBundleSupport: config.transformer.experimentalImportBundleSupport,
|
|
40
|
+
unstable_allowRequireContext: config.transformer.unstable_allowRequireContext,
|
|
41
|
+
shallow: false
|
|
42
|
+
});
|
|
43
|
+
return Array.from(dependencies.keys());
|
|
44
|
+
};
|
|
45
|
+
const { transform } = await config.transformer.getTransformOptions(
|
|
46
|
+
entryFiles,
|
|
47
|
+
{ dev: options.dev, hot: options.hot, platform: options.platform },
|
|
48
|
+
getDependencies
|
|
49
|
+
);
|
|
50
|
+
return {
|
|
51
|
+
...baseOptions,
|
|
52
|
+
inlineRequires: transform.inlineRequires || false,
|
|
53
|
+
experimentalImportSupport: transform.experimentalImportSupport || false,
|
|
54
|
+
unstable_disableES6Transforms: transform.unstable_disableES6Transforms || false,
|
|
55
|
+
nonInlinedRequires: transform.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
56
|
+
type: "module"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function removeInlineRequiresBlockListFromOptions(path2, inlineRequires) {
|
|
60
|
+
if (typeof inlineRequires === "object") {
|
|
61
|
+
return !(path2 in inlineRequires.blockList);
|
|
62
|
+
}
|
|
63
|
+
return inlineRequires;
|
|
64
|
+
}
|
|
65
|
+
async function getTransformFn(entryFiles, bundler, deltaBundler, config, options, resolverOptions) {
|
|
66
|
+
const { inlineRequires, ...transformOptions } = await calcTransformerOptions(
|
|
67
|
+
entryFiles,
|
|
68
|
+
bundler,
|
|
69
|
+
deltaBundler,
|
|
70
|
+
config,
|
|
71
|
+
options,
|
|
72
|
+
resolverOptions
|
|
73
|
+
);
|
|
74
|
+
return async (modulePath, requireContext) => {
|
|
75
|
+
let templateBuffer;
|
|
76
|
+
if (requireContext) {
|
|
77
|
+
const graph = await bundler.getDependencyGraph();
|
|
78
|
+
const files = graph.matchFilesWithContext(requireContext.from, {
|
|
79
|
+
filter: requireContext.filter,
|
|
80
|
+
recursive: requireContext.recursive
|
|
81
|
+
});
|
|
82
|
+
const template = (0, import_contextModuleTemplates.getContextModuleTemplate)(requireContext.mode, requireContext.from, files);
|
|
83
|
+
templateBuffer = Buffer.from(template);
|
|
84
|
+
}
|
|
85
|
+
return await bundler.transformFile(
|
|
86
|
+
modulePath,
|
|
87
|
+
{
|
|
88
|
+
...transformOptions,
|
|
89
|
+
type: getType(transformOptions.type, modulePath, config.resolver.assetExts),
|
|
90
|
+
inlineRequires: removeInlineRequiresBlockListFromOptions(modulePath, inlineRequires)
|
|
91
|
+
},
|
|
92
|
+
templateBuffer
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function getType(type, filePath, assetExts) {
|
|
97
|
+
if (type === "script") {
|
|
98
|
+
return type;
|
|
99
|
+
}
|
|
100
|
+
if (assetExts.indexOf(path.extname(filePath).slice(1)) !== -1) {
|
|
101
|
+
return "asset";
|
|
102
|
+
}
|
|
103
|
+
return "module";
|
|
104
|
+
}
|
|
105
|
+
async function getResolveDependencyFn(bundler, platform, resolverOptions) {
|
|
106
|
+
const dependencyGraph = await await bundler.getDependencyGraph();
|
|
107
|
+
return (from, to) => dependencyGraph.resolveDependency(from, to, platform ?? null, resolverOptions);
|
|
108
|
+
}
|
|
109
|
+
module.exports = {
|
|
110
|
+
getTransformFn,
|
|
111
|
+
getResolveDependencyFn
|
|
112
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const invariant = require("invariant");
|
|
5
|
+
const Resolver = require("metro-resolver");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const util = require("util");
|
|
8
|
+
class ModuleResolver {
|
|
9
|
+
_options;
|
|
10
|
+
// A module representing the project root, used as the origin when resolving `emptyModulePath`.
|
|
11
|
+
_projectRootFakeModule;
|
|
12
|
+
// An empty module, the result of resolving `emptyModulePath` from the project root.
|
|
13
|
+
_cachedEmptyModule;
|
|
14
|
+
// $FlowFixMe[missing-local-annot]
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this._options = options;
|
|
17
|
+
const { projectRoot, moduleCache } = this._options;
|
|
18
|
+
this._projectRootFakeModule = {
|
|
19
|
+
path: path.join(projectRoot, "_"),
|
|
20
|
+
getPackage: () => moduleCache.getPackageOf(this._projectRootFakeModule.path),
|
|
21
|
+
isHaste() {
|
|
22
|
+
throw new Error("not implemented");
|
|
23
|
+
},
|
|
24
|
+
getName() {
|
|
25
|
+
throw new Error("not implemented");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
_getEmptyModule() {
|
|
30
|
+
let emptyModule = this._cachedEmptyModule;
|
|
31
|
+
if (!emptyModule) {
|
|
32
|
+
emptyModule = this.resolveDependency(
|
|
33
|
+
this._projectRootFakeModule,
|
|
34
|
+
this._options.emptyModulePath,
|
|
35
|
+
false,
|
|
36
|
+
null,
|
|
37
|
+
/* resolverOptions */
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
this._cachedEmptyModule = emptyModule;
|
|
41
|
+
}
|
|
42
|
+
return emptyModule;
|
|
43
|
+
}
|
|
44
|
+
_redirectRequire(fromModule, modulePath) {
|
|
45
|
+
const moduleCache = this._options.moduleCache;
|
|
46
|
+
try {
|
|
47
|
+
if (modulePath.startsWith(".")) {
|
|
48
|
+
const fromPackage = fromModule.getPackage();
|
|
49
|
+
if (fromPackage) {
|
|
50
|
+
const fromPackagePath = "./" + path.relative(path.dirname(fromPackage.path), path.resolve(path.dirname(fromModule.path), modulePath));
|
|
51
|
+
let redirectedPath = fromPackage.redirectRequire(fromPackagePath, this._options.mainFields);
|
|
52
|
+
if (redirectedPath !== false) {
|
|
53
|
+
redirectedPath = "./" + path.relative(
|
|
54
|
+
path.dirname(fromModule.path),
|
|
55
|
+
path.resolve(path.dirname(fromPackage.path), redirectedPath)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return redirectedPath;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
const pck = path.isAbsolute(modulePath) ? moduleCache.getPackageOf(modulePath) : fromModule.getPackage();
|
|
62
|
+
if (pck) {
|
|
63
|
+
return pck.redirectRequire(modulePath, this._options.mainFields);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
}
|
|
68
|
+
return modulePath;
|
|
69
|
+
}
|
|
70
|
+
resolveDependency(fromModule, moduleName, allowHaste, platform, resolverOptions) {
|
|
71
|
+
try {
|
|
72
|
+
const result = Resolver.resolve(
|
|
73
|
+
{
|
|
74
|
+
...this._options,
|
|
75
|
+
customResolverOptions: resolverOptions.customResolverOptions ?? {},
|
|
76
|
+
originModulePath: fromModule.path,
|
|
77
|
+
redirectModulePath: (modulePath) => this._redirectRequire(fromModule, modulePath),
|
|
78
|
+
allowHaste,
|
|
79
|
+
platform,
|
|
80
|
+
resolveHasteModule: (name) => this._options.moduleMap.getModule(name, platform, true),
|
|
81
|
+
resolveHastePackage: (name) => this._options.moduleMap.getPackage(name, platform, true),
|
|
82
|
+
getPackageMainPath: this._getPackageMainPath
|
|
83
|
+
},
|
|
84
|
+
moduleName,
|
|
85
|
+
platform
|
|
86
|
+
);
|
|
87
|
+
return this._getFileResolvedModule(result);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof Resolver.FailedToResolvePathError) {
|
|
90
|
+
const { candidates } = error;
|
|
91
|
+
throw new UnableToResolveError(
|
|
92
|
+
fromModule.path,
|
|
93
|
+
moduleName,
|
|
94
|
+
[
|
|
95
|
+
"\n\nNone of these files exist:",
|
|
96
|
+
` * ${Resolver.formatFileCandidates(this._removeRoot(candidates.file))}`,
|
|
97
|
+
` * ${Resolver.formatFileCandidates(this._removeRoot(candidates.dir))}`
|
|
98
|
+
].join("\n"),
|
|
99
|
+
{
|
|
100
|
+
cause: error
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (error instanceof Resolver.FailedToResolveNameError) {
|
|
105
|
+
const dirPaths = error.dirPaths;
|
|
106
|
+
const extraPaths = error.extraPaths;
|
|
107
|
+
const displayDirPaths = dirPaths.filter((dirPath) => this._options.dirExists(dirPath)).map((dirPath) => path.relative(this._options.projectRoot, dirPath)).concat(extraPaths);
|
|
108
|
+
const hint = displayDirPaths.length ? " or in these directories:" : "";
|
|
109
|
+
throw new UnableToResolveError(
|
|
110
|
+
fromModule.path,
|
|
111
|
+
moduleName,
|
|
112
|
+
[
|
|
113
|
+
`${moduleName} could not be found within the project${hint || "."}`,
|
|
114
|
+
...displayDirPaths.map((dirPath) => ` ${dirPath}`)
|
|
115
|
+
].join("\n"),
|
|
116
|
+
{
|
|
117
|
+
cause: error
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_getPackageMainPath = (packageJsonPath) => {
|
|
125
|
+
const package_ = this._options.moduleCache.getPackage(packageJsonPath);
|
|
126
|
+
return package_.getMain(this._options.mainFields);
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* FIXME: get rid of this function and of the reliance on `TModule`
|
|
130
|
+
* altogether, return strongly typed resolutions at the top-level instead.
|
|
131
|
+
*/
|
|
132
|
+
_getFileResolvedModule(resolution) {
|
|
133
|
+
switch (resolution.type) {
|
|
134
|
+
case "sourceFile":
|
|
135
|
+
return this._options.moduleCache.getModule(resolution.filePath);
|
|
136
|
+
case "assetFiles":
|
|
137
|
+
const arbitrary = getArrayLowestItem(resolution.filePaths);
|
|
138
|
+
invariant(arbitrary != null, "invalid asset resolution");
|
|
139
|
+
return this._options.moduleCache.getModule(arbitrary);
|
|
140
|
+
case "empty":
|
|
141
|
+
return this._getEmptyModule();
|
|
142
|
+
default:
|
|
143
|
+
resolution.type;
|
|
144
|
+
throw new Error("invalid type");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
_removeRoot(candidates) {
|
|
148
|
+
if (candidates.filePathPrefix) {
|
|
149
|
+
candidates.filePathPrefix = path.relative(this._options.projectRoot, candidates.filePathPrefix);
|
|
150
|
+
}
|
|
151
|
+
return candidates;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function getArrayLowestItem(a) {
|
|
155
|
+
if (a.length === 0) {
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
let lowest = a[0];
|
|
159
|
+
for (let i = 1; i < a.length; ++i) {
|
|
160
|
+
if (a[i] < lowest) {
|
|
161
|
+
lowest = a[i];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return lowest;
|
|
165
|
+
}
|
|
166
|
+
class UnableToResolveError extends Error {
|
|
167
|
+
/**
|
|
168
|
+
* File path of the module that tried to require a module, ex. `/js/foo.js`.
|
|
169
|
+
*/
|
|
170
|
+
originModulePath;
|
|
171
|
+
/**
|
|
172
|
+
* The name of the module that was required, no necessarily a path,
|
|
173
|
+
* ex. `./bar`, or `invariant`.
|
|
174
|
+
*/
|
|
175
|
+
targetModuleName;
|
|
176
|
+
/**
|
|
177
|
+
* Original error that causes this error
|
|
178
|
+
*/
|
|
179
|
+
cause;
|
|
180
|
+
constructor(originModulePath, targetModuleName, message, options) {
|
|
181
|
+
super();
|
|
182
|
+
this.originModulePath = originModulePath;
|
|
183
|
+
this.targetModuleName = targetModuleName;
|
|
184
|
+
const codeFrameMessage = this.buildCodeFrameMessage();
|
|
185
|
+
this.message = util.format("Unable to resolve module %s from %s: %s", targetModuleName, originModulePath, message) + (codeFrameMessage ? "\n" + codeFrameMessage : "");
|
|
186
|
+
this.cause = options?.cause;
|
|
187
|
+
}
|
|
188
|
+
buildCodeFrameMessage() {
|
|
189
|
+
let file;
|
|
190
|
+
try {
|
|
191
|
+
file = fs.readFileSync(this.originModulePath, "utf8");
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error.code === "ENOENT" || error.code === "EISDIR") {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
const lines = file.split("\n");
|
|
199
|
+
let lineNumber = 0;
|
|
200
|
+
let column = -1;
|
|
201
|
+
for (let line = 0; line < lines.length; line++) {
|
|
202
|
+
const columnLocation = lines[line].lastIndexOf(this.targetModuleName);
|
|
203
|
+
if (columnLocation >= 0) {
|
|
204
|
+
lineNumber = line;
|
|
205
|
+
column = columnLocation;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return codeFrameColumns(
|
|
210
|
+
fs.readFileSync(this.originModulePath, "utf8"),
|
|
211
|
+
{
|
|
212
|
+
start: { column: column + 1, line: lineNumber + 1 }
|
|
213
|
+
},
|
|
214
|
+
{ forceColor: process.env.NODE_ENV !== "test" }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
module.exports = {
|
|
219
|
+
ModuleResolver,
|
|
220
|
+
UnableToResolveError
|
|
221
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_metro_file_map = __toESM(require("metro-file-map"));
|
|
25
|
+
const ci = require("ci-info");
|
|
26
|
+
const path = require("path");
|
|
27
|
+
function getIgnorePattern(config) {
|
|
28
|
+
const { blockList, blacklistRE } = config.resolver;
|
|
29
|
+
const ignorePattern = blacklistRE || blockList;
|
|
30
|
+
if (!ignorePattern) {
|
|
31
|
+
return / ^/;
|
|
32
|
+
}
|
|
33
|
+
const combine = (regexes) => new RegExp(regexes.map((regex) => "(" + regex.source.replace(/\//g, path.sep) + ")").join("|"));
|
|
34
|
+
if (Array.isArray(ignorePattern)) {
|
|
35
|
+
return combine(ignorePattern);
|
|
36
|
+
}
|
|
37
|
+
return ignorePattern;
|
|
38
|
+
}
|
|
39
|
+
function createHasteMap(config, options) {
|
|
40
|
+
const dependencyExtractor = options?.extractDependencies === false ? null : config.resolver.dependencyExtractor;
|
|
41
|
+
const computeDependencies = dependencyExtractor != null;
|
|
42
|
+
return import_metro_file_map.default.create({
|
|
43
|
+
cacheManagerFactory: config?.unstable_fileMapCacheManagerFactory ?? ((buildParameters) => new import_metro_file_map.DiskCacheManager({
|
|
44
|
+
buildParameters,
|
|
45
|
+
cacheDirectory: config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
|
|
46
|
+
cacheFilePrefix: options?.cacheFilePrefix
|
|
47
|
+
})),
|
|
48
|
+
perfLogger: config.unstable_perfLogger?.subSpan("hasteMap") ?? null,
|
|
49
|
+
computeDependencies,
|
|
50
|
+
computeSha1: true,
|
|
51
|
+
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
52
|
+
extensions: Array.from(
|
|
53
|
+
/* @__PURE__ */ new Set([...config.resolver.sourceExts, ...config.resolver.assetExts, ...config.watcher.additionalExts])
|
|
54
|
+
),
|
|
55
|
+
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
56
|
+
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
57
|
+
ignorePattern: getIgnorePattern(config),
|
|
58
|
+
maxWorkers: config.maxWorkers,
|
|
59
|
+
mocksPattern: "",
|
|
60
|
+
platforms: config.resolver.platforms,
|
|
61
|
+
retainAllFiles: true,
|
|
62
|
+
resetCache: config.resetCache,
|
|
63
|
+
rootDir: config.projectRoot,
|
|
64
|
+
roots: config.watchFolders,
|
|
65
|
+
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
66
|
+
useWatchman: config.resolver.useWatchman,
|
|
67
|
+
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
68
|
+
watchmanDeferStates: config.watcher.watchman.deferStates
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
module.exports = createHasteMap;
|