@wyw-in-js/transform 1.1.0 → 2.0.0-alpha.1
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/esm/cache.js +433 -289
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js +171 -134
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/eval/broker.js +2275 -0
- package/esm/eval/broker.js.map +1 -0
- package/esm/eval/lru.js +36 -0
- package/esm/eval/lru.js.map +1 -0
- package/esm/eval/prepareModuleOnDemand.js +21 -0
- package/esm/eval/prepareModuleOnDemand.js.map +1 -0
- package/esm/eval/protocol.js +2 -0
- package/esm/eval/protocol.js.map +1 -0
- package/esm/eval/runner.js +1878 -0
- package/esm/eval/runner.js.map +1 -0
- package/esm/eval/serialize.js +333 -0
- package/esm/eval/serialize.js.map +1 -0
- package/esm/eval/writeQueue.js +81 -0
- package/esm/eval/writeQueue.js.map +1 -0
- package/esm/evaluators/index.js +11 -12
- package/esm/evaluators/index.js.map +1 -1
- package/esm/index.js +25 -29
- package/esm/index.js.map +1 -1
- package/esm/module.js +923 -520
- package/esm/module.js.map +1 -1
- package/esm/shaker.js +14 -80
- package/esm/shaker.js.map +1 -1
- package/esm/transform/BaseEntrypoint.js +162 -164
- package/esm/transform/BaseEntrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.helpers.js +96 -253
- package/esm/transform/Entrypoint.helpers.js.map +1 -1
- package/esm/transform/Entrypoint.js +336 -270
- package/esm/transform/Entrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.types.js +1 -1
- package/esm/transform/Entrypoint.types.js.map +1 -1
- package/esm/transform/EvaluatedEntrypoint.js +10 -4
- package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
- package/esm/transform/actions/AbortError.js +6 -6
- package/esm/transform/actions/AbortError.js.map +1 -1
- package/esm/transform/actions/BaseAction.js +140 -136
- package/esm/transform/actions/BaseAction.js.map +1 -1
- package/esm/transform/actions/UnprocessedEntrypointError.js +6 -6
- package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -1
- package/esm/transform/actions/actionRunner.js +63 -66
- package/esm/transform/actions/actionRunner.js.map +1 -1
- package/esm/transform/actions/types.js +1 -1
- package/esm/transform/actions/types.js.map +1 -1
- package/esm/transform/barrelManifest.types.js +2 -0
- package/esm/transform/barrelManifest.types.js.map +1 -0
- package/esm/transform/generators/baseProcessingHandlers.js +15 -17
- package/esm/transform/generators/baseProcessingHandlers.js.map +1 -1
- package/esm/transform/generators/collect.js +27 -55
- package/esm/transform/generators/collect.js.map +1 -1
- package/esm/transform/generators/createStylisPreprocessor.js +353 -321
- package/esm/transform/generators/createStylisPreprocessor.js.map +1 -1
- package/esm/transform/generators/evalFile.js +48 -47
- package/esm/transform/generators/evalFile.js.map +1 -1
- package/esm/transform/generators/extract.js +78 -90
- package/esm/transform/generators/extract.js.map +1 -1
- package/esm/transform/generators/getExports.js +57 -74
- package/esm/transform/generators/getExports.js.map +1 -1
- package/esm/transform/generators/index.js +11 -11
- package/esm/transform/generators/index.js.map +1 -1
- package/esm/transform/generators/processEntrypoint.js +93 -67
- package/esm/transform/generators/processEntrypoint.js.map +1 -1
- package/esm/transform/generators/processImports.js +102 -67
- package/esm/transform/generators/processImports.js.map +1 -1
- package/esm/transform/generators/resolveImports.js +212 -197
- package/esm/transform/generators/resolveImports.js.map +1 -1
- package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
- package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
- package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
- package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
- package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
- package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
- package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
- package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
- package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
- package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
- package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
- package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
- package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
- package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
- package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
- package/esm/transform/generators/resolveStaticOxcValues.js +2 -0
- package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -0
- package/esm/transform/generators/rewriteOxcBarrelImports.js +822 -0
- package/esm/transform/generators/rewriteOxcBarrelImports.js.map +1 -0
- package/esm/transform/generators/transform.js +251 -248
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/generators/workflow.js +87 -90
- package/esm/transform/generators/workflow.js.map +1 -1
- package/esm/transform/helpers/loadWywOptions.js +183 -74
- package/esm/transform/helpers/loadWywOptions.js.map +1 -1
- package/esm/transform/helpers/withDefaultServices.js +13 -22
- package/esm/transform/helpers/withDefaultServices.js.map +1 -1
- package/esm/transform/isStaticallyEvaluatableModule.js +140 -152
- package/esm/transform/isStaticallyEvaluatableModule.js.map +1 -1
- package/esm/transform/oxcBarrelManifest.js +349 -0
- package/esm/transform/oxcBarrelManifest.js.map +1 -0
- package/esm/transform/rootLog.js +3 -3
- package/esm/transform/rootLog.js.map +1 -1
- package/esm/transform/syntax.js +2 -0
- package/esm/transform/syntax.js.map +1 -0
- package/esm/transform/types.js +2 -2
- package/esm/transform/types.js.map +1 -1
- package/esm/transform.js +125 -147
- package/esm/transform.js.map +1 -1
- package/esm/types.js +4 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/EventEmitter.js +79 -48
- package/esm/utils/EventEmitter.js.map +1 -1
- package/esm/utils/ShakerMetadata.js +2 -2
- package/esm/utils/ShakerMetadata.js.map +1 -1
- package/esm/utils/TransformDiagnostics.js +9 -9
- package/esm/utils/TransformDiagnostics.js.map +1 -1
- package/esm/utils/TransformMetadata.js +24 -26
- package/esm/utils/TransformMetadata.js.map +1 -1
- package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
- package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
- package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
- package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
- package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
- package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
- package/esm/utils/applyOxcProcessors/displayName.js +93 -0
- package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
- package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
- package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
- package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
- package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
- package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
- package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
- package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
- package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
- package/esm/utils/applyOxcProcessors/shared.js +29 -0
- package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
- package/esm/utils/applyOxcProcessors/types.js +2 -0
- package/esm/utils/applyOxcProcessors/types.js.map +1 -0
- package/esm/utils/applyOxcProcessors.js +2 -0
- package/esm/utils/applyOxcProcessors.js.map +1 -0
- package/esm/utils/collectOxcExportsAndImports.js +934 -0
- package/esm/utils/collectOxcExportsAndImports.js.map +1 -0
- package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
- package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
- package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
- package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
- package/esm/utils/collectOxcRuntime/types.js +2 -0
- package/esm/utils/collectOxcRuntime/types.js.map +1 -0
- package/esm/utils/collectOxcRuntime.js +32 -0
- package/esm/utils/collectOxcRuntime.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
- package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
- package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
- package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
- package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
- package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies.js +4 -0
- package/esm/utils/collectOxcTemplateDependencies.js.map +1 -0
- package/esm/utils/dispose-polyfill.js +3 -4
- package/esm/utils/dispose-polyfill.js.map +1 -1
- package/esm/utils/getFileIdx.js +6 -6
- package/esm/utils/getFileIdx.js.map +1 -1
- package/esm/utils/getPluginKey.js +12 -12
- package/esm/utils/getPluginKey.js.map +1 -1
- package/esm/utils/getVisitorKeys.js +9 -3
- package/esm/utils/getVisitorKeys.js.map +1 -1
- package/esm/utils/hasCachedWywPrevalExport.js +23 -0
- package/esm/utils/hasCachedWywPrevalExport.js.map +1 -0
- package/esm/utils/hasWywPreval.js +5 -5
- package/esm/utils/hasWywPreval.js.map +1 -1
- package/esm/utils/importOverrides.js +75 -90
- package/esm/utils/importOverrides.js.map +1 -1
- package/esm/utils/isNode.js +2 -2
- package/esm/utils/isNode.js.map +1 -1
- package/esm/utils/isNotNull.js +2 -2
- package/esm/utils/isNotNull.js.map +1 -1
- package/esm/utils/isSerializable.js +11 -11
- package/esm/utils/isSerializable.js.map +1 -1
- package/esm/utils/nativeResolver.js +93 -0
- package/esm/utils/nativeResolver.js.map +1 -0
- package/esm/utils/oxc/ast.js +28 -0
- package/esm/utils/oxc/ast.js.map +1 -0
- package/esm/utils/oxc/parse.js +3 -0
- package/esm/utils/oxc/parse.js.map +1 -0
- package/esm/utils/oxc/replacements.js +14 -0
- package/esm/utils/oxc/replacements.js.map +1 -0
- package/esm/utils/oxc/sourceLocations.js +59 -0
- package/esm/utils/oxc/sourceLocations.js.map +1 -0
- package/esm/utils/oxcAstService.js +121 -0
- package/esm/utils/oxcAstService.js.map +1 -0
- package/esm/utils/oxcEmit.js +447 -0
- package/esm/utils/oxcEmit.js.map +1 -0
- package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
- package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
- package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
- package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
- package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
- package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
- package/esm/utils/oxcPreevalStage/processors.js +17 -0
- package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
- package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
- package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
- package/esm/utils/oxcPreevalStage/types.js +2 -0
- package/esm/utils/oxcPreevalStage/types.js.map +1 -0
- package/esm/utils/oxcPreevalStage.js +41 -0
- package/esm/utils/oxcPreevalStage.js.map +1 -0
- package/esm/utils/oxcPreevalTransforms.js +1065 -0
- package/esm/utils/oxcPreevalTransforms.js.map +1 -0
- package/esm/utils/oxcShaker.js +662 -0
- package/esm/utils/oxcShaker.js.map +1 -0
- package/esm/utils/parseOxc.js +37 -0
- package/esm/utils/parseOxc.js.map +1 -0
- package/esm/utils/parseRequest.js +27 -27
- package/esm/utils/parseRequest.js.map +1 -1
- package/esm/utils/peek.js +1 -1
- package/esm/utils/peek.js.map +1 -1
- package/esm/utils/processorLookup.js +125 -0
- package/esm/utils/processorLookup.js.map +1 -0
- package/esm/utils/processorStaticSemantics.js +157 -0
- package/esm/utils/processorStaticSemantics.js.map +1 -0
- package/esm/utils/resolveWithConditions.js +99 -0
- package/esm/utils/resolveWithConditions.js.map +1 -0
- package/esm/vm/createVmContext.js +140 -141
- package/esm/vm/createVmContext.js.map +1 -1
- package/esm/vm/process.js +11 -13
- package/esm/vm/process.js.map +1 -1
- package/package.json +19 -26
- package/types/cache.d.ts +17 -8
- package/types/cache.js +245 -95
- package/types/debug/fileReporter.js +68 -23
- package/types/eval/broker.d.ts +92 -0
- package/types/eval/broker.js +2411 -0
- package/types/eval/lru.d.ts +10 -0
- package/types/eval/lru.js +36 -0
- package/types/eval/prepareModuleOnDemand.d.ts +7 -0
- package/types/eval/prepareModuleOnDemand.js +24 -0
- package/types/eval/protocol.d.ts +111 -0
- package/types/eval/protocol.js +1 -0
- package/types/eval/serialize.d.ts +78 -0
- package/types/eval/serialize.js +357 -0
- package/types/eval/writeQueue.d.ts +13 -0
- package/types/eval/writeQueue.js +80 -0
- package/types/evaluators/index.d.ts +2 -2
- package/types/evaluators/index.js +6 -9
- package/types/index.d.ts +3 -6
- package/types/index.js +24 -82
- package/types/module.d.ts +38 -7
- package/types/module.js +613 -192
- package/types/shaker.d.ts +2 -10
- package/types/shaker.js +10 -100
- package/types/transform/BaseEntrypoint.js +6 -11
- package/types/transform/Entrypoint.d.ts +15 -15
- package/types/transform/Entrypoint.helpers.d.ts +2 -5
- package/types/transform/Entrypoint.helpers.js +43 -203
- package/types/transform/Entrypoint.js +130 -53
- package/types/transform/Entrypoint.types.d.ts +31 -6
- package/types/transform/Entrypoint.types.js +1 -2
- package/types/transform/EvaluatedEntrypoint.d.ts +13 -2
- package/types/transform/EvaluatedEntrypoint.js +7 -6
- package/types/transform/actions/AbortError.js +2 -7
- package/types/transform/actions/BaseAction.js +4 -8
- package/types/transform/actions/UnprocessedEntrypointError.js +2 -7
- package/types/transform/actions/actionRunner.js +8 -12
- package/types/transform/actions/types.d.ts +2 -2
- package/types/transform/actions/types.js +1 -2
- package/types/transform/{barrelManifest.d.ts → barrelManifest.types.d.ts} +0 -2
- package/types/transform/barrelManifest.types.js +1 -0
- package/types/transform/generators/baseProcessingHandlers.d.ts +4 -5
- package/types/transform/generators/baseProcessingHandlers.js +10 -14
- package/types/transform/generators/collect.js +13 -39
- package/types/transform/generators/createStylisPreprocessor.js +19 -60
- package/types/transform/generators/evalFile.d.ts +2 -2
- package/types/transform/generators/evalFile.js +26 -28
- package/types/transform/generators/extract.js +5 -8
- package/types/transform/generators/getExports.js +23 -30
- package/types/transform/generators/index.d.ts +2 -2
- package/types/transform/generators/index.js +11 -14
- package/types/transform/generators/processEntrypoint.d.ts +2 -2
- package/types/transform/generators/processEntrypoint.js +60 -26
- package/types/transform/generators/processImports.d.ts +0 -3
- package/types/transform/generators/processImports.js +60 -20
- package/types/transform/generators/resolveImports.d.ts +3 -1
- package/types/transform/generators/resolveImports.js +66 -23
- package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
- package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
- package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
- package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
- package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
- package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
- package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
- package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
- package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
- package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
- package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
- package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
- package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
- package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
- package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
- package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
- package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
- package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
- package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
- package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
- package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
- package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
- package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
- package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
- package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
- package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
- package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
- package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
- package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
- package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -0
- package/types/transform/generators/resolveStaticOxcValues.js +1 -0
- package/types/transform/generators/{rewriteBarrelImports.d.ts → rewriteOxcBarrelImports.d.ts} +2 -3
- package/types/transform/generators/{rewriteBarrelImports.js → rewriteOxcBarrelImports.js} +282 -225
- package/types/transform/generators/transform.d.ts +3 -7
- package/types/transform/generators/transform.js +217 -199
- package/types/transform/generators/workflow.js +62 -45
- package/types/transform/helpers/loadWywOptions.js +115 -21
- package/types/transform/helpers/withDefaultServices.d.ts +1 -1
- package/types/transform/helpers/withDefaultServices.js +6 -44
- package/types/transform/isStaticallyEvaluatableModule.d.ts +1 -2
- package/types/transform/isStaticallyEvaluatableModule.js +125 -126
- package/types/transform/oxcBarrelManifest.d.ts +2 -0
- package/types/transform/{barrelManifest.js → oxcBarrelManifest.js} +156 -97
- package/types/transform/rootLog.js +2 -5
- package/types/transform/syntax.d.ts +38 -0
- package/types/transform/syntax.js +1 -0
- package/types/transform/types.d.ts +9 -6
- package/types/transform/types.js +1 -4
- package/types/transform.d.ts +2 -2
- package/types/transform.js +90 -101
- package/types/types.d.ts +0 -23
- package/types/types.js +1 -2
- package/types/utils/EventEmitter.d.ts +16 -1
- package/types/utils/EventEmitter.js +47 -18
- package/types/utils/ShakerMetadata.js +1 -5
- package/types/utils/TransformDiagnostics.js +3 -7
- package/types/utils/TransformMetadata.js +8 -16
- package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
- package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
- package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
- package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
- package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
- package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
- package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
- package/types/utils/applyOxcProcessors/displayName.js +113 -0
- package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
- package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
- package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
- package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
- package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
- package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
- package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
- package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
- package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
- package/types/utils/applyOxcProcessors/shared.js +37 -0
- package/types/utils/applyOxcProcessors/types.d.ts +88 -0
- package/types/utils/applyOxcProcessors/types.js +1 -0
- package/types/utils/applyOxcProcessors.d.ts +1 -0
- package/types/utils/applyOxcProcessors.js +1 -0
- package/types/utils/collectOxcExportsAndImports.d.ts +35 -0
- package/types/utils/collectOxcExportsAndImports.js +957 -0
- package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
- package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
- package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
- package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
- package/types/utils/collectOxcRuntime/types.d.ts +16 -0
- package/types/utils/collectOxcRuntime/types.js +1 -0
- package/types/utils/collectOxcRuntime.d.ts +4 -0
- package/types/utils/collectOxcRuntime.js +31 -0
- package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
- package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
- package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
- package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
- package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
- package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
- package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
- package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
- package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
- package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
- package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
- package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
- package/types/utils/collectOxcTemplateDependencies.d.ts +4 -0
- package/types/utils/collectOxcTemplateDependencies.js +3 -0
- package/types/utils/getFileIdx.js +1 -4
- package/types/utils/getPluginKey.d.ts +5 -2
- package/types/utils/getPluginKey.js +2 -6
- package/types/utils/getVisitorKeys.d.ts +4 -4
- package/types/utils/getVisitorKeys.js +9 -6
- package/types/utils/hasCachedWywPrevalExport.d.ts +14 -0
- package/types/utils/hasCachedWywPrevalExport.js +30 -0
- package/types/utils/hasWywPreval.js +1 -4
- package/types/utils/importOverrides.js +17 -27
- package/types/utils/isNode.d.ts +2 -2
- package/types/utils/isNode.js +2 -6
- package/types/utils/isNotNull.js +1 -4
- package/types/utils/isSerializable.js +3 -6
- package/types/utils/nativeResolver.d.ts +13 -0
- package/types/utils/nativeResolver.js +91 -0
- package/types/utils/oxc/ast.d.ts +4 -0
- package/types/utils/oxc/ast.js +37 -0
- package/types/utils/oxc/parse.d.ts +3 -0
- package/types/utils/oxc/parse.js +2 -0
- package/types/utils/oxc/replacements.d.ts +12 -0
- package/types/utils/oxc/replacements.js +18 -0
- package/types/utils/oxc/sourceLocations.d.ts +5 -0
- package/types/utils/oxc/sourceLocations.js +63 -0
- package/types/utils/oxcAstService.d.ts +11 -0
- package/types/utils/oxcAstService.js +79 -0
- package/types/utils/oxcEmit.d.ts +19 -0
- package/types/utils/oxcEmit.js +506 -0
- package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
- package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
- package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
- package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
- package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
- package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
- package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
- package/types/utils/oxcPreevalStage/processors.js +16 -0
- package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
- package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
- package/types/utils/oxcPreevalStage/types.d.ts +22 -0
- package/types/utils/oxcPreevalStage/types.js +1 -0
- package/types/utils/oxcPreevalStage.d.ts +4 -0
- package/types/utils/oxcPreevalStage.js +40 -0
- package/types/utils/oxcPreevalTransforms.d.ts +13 -0
- package/types/utils/oxcPreevalTransforms.js +1192 -0
- package/types/utils/oxcShaker.d.ts +13 -0
- package/types/utils/oxcShaker.js +751 -0
- package/types/utils/parseOxc.d.ts +11 -0
- package/types/utils/parseOxc.js +38 -0
- package/types/utils/parseRequest.js +2 -7
- package/types/utils/peek.js +1 -5
- package/types/utils/processorLookup.d.ts +8 -0
- package/types/utils/processorLookup.js +135 -0
- package/types/utils/processorStaticSemantics.d.ts +13 -0
- package/types/utils/processorStaticSemantics.js +191 -0
- package/types/utils/resolveWithConditions.d.ts +12 -0
- package/types/utils/resolveWithConditions.js +103 -0
- package/types/vm/createVmContext.d.ts +2 -2
- package/types/vm/createVmContext.js +25 -62
- package/types/vm/process.js +20 -26
- package/esm/babel.js +0 -2
- package/esm/babel.js.map +0 -1
- package/esm/options/buildOptions.js +0 -168
- package/esm/options/buildOptions.js.map +0 -1
- package/esm/options/buildOptions.test.js +0 -138
- package/esm/options/buildOptions.test.js.map +0 -1
- package/esm/options/loadBabelOptions.js +0 -24
- package/esm/options/loadBabelOptions.js.map +0 -1
- package/esm/plugins/babel-transform.js +0 -53
- package/esm/plugins/babel-transform.js.map +0 -1
- package/esm/plugins/collector.js +0 -60
- package/esm/plugins/collector.js.map +0 -1
- package/esm/plugins/dynamic-import.js +0 -56
- package/esm/plugins/dynamic-import.js.map +0 -1
- package/esm/plugins/preeval.js +0 -73
- package/esm/plugins/preeval.js.map +0 -1
- package/esm/plugins/shaker.js +0 -680
- package/esm/plugins/shaker.js.map +0 -1
- package/esm/transform/barrelManifest.js +0 -291
- package/esm/transform/barrelManifest.js.map +0 -1
- package/esm/transform/generators/explodeReexports.js +0 -64
- package/esm/transform/generators/explodeReexports.js.map +0 -1
- package/esm/transform/generators/rewriteBarrelImports.js +0 -733
- package/esm/transform/generators/rewriteBarrelImports.js.map +0 -1
- package/esm/utils/addIdentifierToWywPreval.js +0 -68
- package/esm/utils/addIdentifierToWywPreval.js.map +0 -1
- package/esm/utils/collectExportsAndImports.js +0 -1157
- package/esm/utils/collectExportsAndImports.js.map +0 -1
- package/esm/utils/collectTemplateDependencies.js +0 -228
- package/esm/utils/collectTemplateDependencies.js.map +0 -1
- package/esm/utils/createId.js +0 -6
- package/esm/utils/createId.js.map +0 -1
- package/esm/utils/findIdentifiers.js +0 -62
- package/esm/utils/findIdentifiers.js.map +0 -1
- package/esm/utils/getConstantStringValue.js +0 -58
- package/esm/utils/getConstantStringValue.js.map +0 -1
- package/esm/utils/getMemberExpressionPropertyName.js +0 -11
- package/esm/utils/getMemberExpressionPropertyName.js.map +0 -1
- package/esm/utils/getScope.js +0 -6
- package/esm/utils/getScope.js.map +0 -1
- package/esm/utils/getSource.js +0 -15
- package/esm/utils/getSource.js.map +0 -1
- package/esm/utils/getTagProcessor.js +0 -404
- package/esm/utils/getTagProcessor.js.map +0 -1
- package/esm/utils/isExports.js +0 -22
- package/esm/utils/isExports.js.map +0 -1
- package/esm/utils/isGlobal.js +0 -6
- package/esm/utils/isGlobal.js.map +0 -1
- package/esm/utils/isNodePath.js +0 -4
- package/esm/utils/isNodePath.js.map +0 -1
- package/esm/utils/isRemoved.js +0 -46
- package/esm/utils/isRemoved.js.map +0 -1
- package/esm/utils/isRequire.js +0 -13
- package/esm/utils/isRequire.js.map +0 -1
- package/esm/utils/isTypedNode.js +0 -6
- package/esm/utils/isTypedNode.js.map +0 -1
- package/esm/utils/isUnnecessaryReactCall.js +0 -72
- package/esm/utils/isUnnecessaryReactCall.js.map +0 -1
- package/esm/utils/removeDangerousCode.js +0 -276
- package/esm/utils/removeDangerousCode.js.map +0 -1
- package/esm/utils/replaceImportMetaEnv.js +0 -44
- package/esm/utils/replaceImportMetaEnv.js.map +0 -1
- package/esm/utils/scopeHelpers.js +0 -527
- package/esm/utils/scopeHelpers.js.map +0 -1
- package/esm/utils/traversalCache.js +0 -23
- package/esm/utils/traversalCache.js.map +0 -1
- package/esm/utils/unwrapExpression.js +0 -18
- package/esm/utils/unwrapExpression.js.map +0 -1
- package/esm/utils/unwrapSequence.js +0 -14
- package/esm/utils/unwrapSequence.js.map +0 -1
- package/esm/utils/valueToLiteral.js +0 -59
- package/esm/utils/valueToLiteral.js.map +0 -1
- package/esm/utils/visitors/JSXElementsRemover.js +0 -51
- package/esm/utils/visitors/JSXElementsRemover.js.map +0 -1
- package/lib/babel.js +0 -2
- package/lib/babel.js.map +0 -1
- package/lib/cache.js +0 -308
- package/lib/cache.js.map +0 -1
- package/lib/debug/fileReporter.js +0 -153
- package/lib/debug/fileReporter.js.map +0 -1
- package/lib/evaluators/index.js +0 -20
- package/lib/evaluators/index.js.map +0 -1
- package/lib/index.js +0 -286
- package/lib/index.js.map +0 -1
- package/lib/module.js +0 -552
- package/lib/module.js.map +0 -1
- package/lib/options/buildOptions.js +0 -176
- package/lib/options/buildOptions.js.map +0 -1
- package/lib/options/buildOptions.test.js +0 -141
- package/lib/options/buildOptions.test.js.map +0 -1
- package/lib/options/loadBabelOptions.js +0 -31
- package/lib/options/loadBabelOptions.js.map +0 -1
- package/lib/plugins/babel-transform.js +0 -60
- package/lib/plugins/babel-transform.js.map +0 -1
- package/lib/plugins/collector.js +0 -70
- package/lib/plugins/collector.js.map +0 -1
- package/lib/plugins/dynamic-import.js +0 -61
- package/lib/plugins/dynamic-import.js.map +0 -1
- package/lib/plugins/preeval.js +0 -81
- package/lib/plugins/preeval.js.map +0 -1
- package/lib/plugins/shaker.js +0 -691
- package/lib/plugins/shaker.js.map +0 -1
- package/lib/shaker.js +0 -95
- package/lib/shaker.js.map +0 -1
- package/lib/transform/BaseEntrypoint.js +0 -179
- package/lib/transform/BaseEntrypoint.js.map +0 -1
- package/lib/transform/Entrypoint.helpers.js +0 -279
- package/lib/transform/Entrypoint.helpers.js.map +0 -1
- package/lib/transform/Entrypoint.js +0 -289
- package/lib/transform/Entrypoint.js.map +0 -1
- package/lib/transform/Entrypoint.types.js +0 -2
- package/lib/transform/Entrypoint.types.js.map +0 -1
- package/lib/transform/EvaluatedEntrypoint.js +0 -13
- package/lib/transform/EvaluatedEntrypoint.js.map +0 -1
- package/lib/transform/actions/AbortError.js +0 -16
- package/lib/transform/actions/AbortError.js.map +0 -1
- package/lib/transform/actions/BaseAction.js +0 -150
- package/lib/transform/actions/BaseAction.js.map +0 -1
- package/lib/transform/actions/UnprocessedEntrypointError.js +0 -16
- package/lib/transform/actions/UnprocessedEntrypointError.js.map +0 -1
- package/lib/transform/actions/actionRunner.js +0 -82
- package/lib/transform/actions/actionRunner.js.map +0 -1
- package/lib/transform/actions/types.js +0 -2
- package/lib/transform/actions/types.js.map +0 -1
- package/lib/transform/barrelManifest.js +0 -300
- package/lib/transform/barrelManifest.js.map +0 -1
- package/lib/transform/generators/baseProcessingHandlers.js +0 -27
- package/lib/transform/generators/baseProcessingHandlers.js.map +0 -1
- package/lib/transform/generators/collect.js +0 -66
- package/lib/transform/generators/collect.js.map +0 -1
- package/lib/transform/generators/createStylisPreprocessor.js +0 -372
- package/lib/transform/generators/createStylisPreprocessor.js.map +0 -1
- package/lib/transform/generators/evalFile.js +0 -57
- package/lib/transform/generators/evalFile.js.map +0 -1
- package/lib/transform/generators/explodeReexports.js +0 -71
- package/lib/transform/generators/explodeReexports.js.map +0 -1
- package/lib/transform/generators/extract.js +0 -102
- package/lib/transform/generators/extract.js.map +0 -1
- package/lib/transform/generators/getExports.js +0 -85
- package/lib/transform/generators/getExports.js.map +0 -1
- package/lib/transform/generators/index.js +0 -19
- package/lib/transform/generators/index.js.map +0 -1
- package/lib/transform/generators/processEntrypoint.js +0 -76
- package/lib/transform/generators/processEntrypoint.js.map +0 -1
- package/lib/transform/generators/processImports.js +0 -82
- package/lib/transform/generators/processImports.js.map +0 -1
- package/lib/transform/generators/resolveImports.js +0 -221
- package/lib/transform/generators/resolveImports.js.map +0 -1
- package/lib/transform/generators/rewriteBarrelImports.js +0 -743
- package/lib/transform/generators/rewriteBarrelImports.js.map +0 -1
- package/lib/transform/generators/transform.js +0 -272
- package/lib/transform/generators/transform.js.map +0 -1
- package/lib/transform/generators/workflow.js +0 -100
- package/lib/transform/generators/workflow.js.map +0 -1
- package/lib/transform/helpers/loadWywOptions.js +0 -88
- package/lib/transform/helpers/loadWywOptions.js.map +0 -1
- package/lib/transform/helpers/withDefaultServices.js +0 -31
- package/lib/transform/helpers/withDefaultServices.js.map +0 -1
- package/lib/transform/isStaticallyEvaluatableModule.js +0 -159
- package/lib/transform/isStaticallyEvaluatableModule.js.map +0 -1
- package/lib/transform/rootLog.js +0 -9
- package/lib/transform/rootLog.js.map +0 -1
- package/lib/transform/types.js +0 -8
- package/lib/transform/types.js.map +0 -1
- package/lib/transform.js +0 -160
- package/lib/transform.js.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/utils/EventEmitter.js +0 -61
- package/lib/utils/EventEmitter.js.map +0 -1
- package/lib/utils/ShakerMetadata.js +0 -9
- package/lib/utils/ShakerMetadata.js.map +0 -1
- package/lib/utils/TransformDiagnostics.js +0 -20
- package/lib/utils/TransformDiagnostics.js.map +0 -1
- package/lib/utils/TransformMetadata.js +0 -45
- package/lib/utils/TransformMetadata.js.map +0 -1
- package/lib/utils/addIdentifierToWywPreval.js +0 -75
- package/lib/utils/addIdentifierToWywPreval.js.map +0 -1
- package/lib/utils/collectExportsAndImports.js +0 -1173
- package/lib/utils/collectExportsAndImports.js.map +0 -1
- package/lib/utils/collectTemplateDependencies.js +0 -242
- package/lib/utils/collectTemplateDependencies.js.map +0 -1
- package/lib/utils/createId.js +0 -13
- package/lib/utils/createId.js.map +0 -1
- package/lib/utils/dispose-polyfill.js +0 -9
- package/lib/utils/dispose-polyfill.js.map +0 -1
- package/lib/utils/findIdentifiers.js +0 -73
- package/lib/utils/findIdentifiers.js.map +0 -1
- package/lib/utils/getConstantStringValue.js +0 -66
- package/lib/utils/getConstantStringValue.js.map +0 -1
- package/lib/utils/getFileIdx.js +0 -16
- package/lib/utils/getFileIdx.js.map +0 -1
- package/lib/utils/getMemberExpressionPropertyName.js +0 -18
- package/lib/utils/getMemberExpressionPropertyName.js.map +0 -1
- package/lib/utils/getPluginKey.js +0 -21
- package/lib/utils/getPluginKey.js.map +0 -1
- package/lib/utils/getScope.js +0 -12
- package/lib/utils/getScope.js.map +0 -1
- package/lib/utils/getSource.js +0 -24
- package/lib/utils/getSource.js.map +0 -1
- package/lib/utils/getTagProcessor.js +0 -424
- package/lib/utils/getTagProcessor.js.map +0 -1
- package/lib/utils/getVisitorKeys.js +0 -11
- package/lib/utils/getVisitorKeys.js.map +0 -1
- package/lib/utils/hasWywPreval.js +0 -13
- package/lib/utils/hasWywPreval.js.map +0 -1
- package/lib/utils/importOverrides.js +0 -119
- package/lib/utils/importOverrides.js.map +0 -1
- package/lib/utils/isExports.js +0 -27
- package/lib/utils/isExports.js.map +0 -1
- package/lib/utils/isGlobal.js +0 -13
- package/lib/utils/isGlobal.js.map +0 -1
- package/lib/utils/isNode.js +0 -9
- package/lib/utils/isNode.js.map +0 -1
- package/lib/utils/isNodePath.js +0 -10
- package/lib/utils/isNodePath.js.map +0 -1
- package/lib/utils/isNotNull.js +0 -10
- package/lib/utils/isNotNull.js.map +0 -1
- package/lib/utils/isRemoved.js +0 -52
- package/lib/utils/isRemoved.js.map +0 -1
- package/lib/utils/isRequire.js +0 -18
- package/lib/utils/isRequire.js.map +0 -1
- package/lib/utils/isSerializable.js +0 -19
- package/lib/utils/isSerializable.js.map +0 -1
- package/lib/utils/isTypedNode.js +0 -13
- package/lib/utils/isTypedNode.js.map +0 -1
- package/lib/utils/isUnnecessaryReactCall.js +0 -81
- package/lib/utils/isUnnecessaryReactCall.js.map +0 -1
- package/lib/utils/parseRequest.js +0 -37
- package/lib/utils/parseRequest.js.map +0 -1
- package/lib/utils/peek.js +0 -9
- package/lib/utils/peek.js.map +0 -1
- package/lib/utils/removeDangerousCode.js +0 -284
- package/lib/utils/removeDangerousCode.js.map +0 -1
- package/lib/utils/replaceImportMetaEnv.js +0 -50
- package/lib/utils/replaceImportMetaEnv.js.map +0 -1
- package/lib/utils/scopeHelpers.js +0 -557
- package/lib/utils/scopeHelpers.js.map +0 -1
- package/lib/utils/traversalCache.js +0 -31
- package/lib/utils/traversalCache.js.map +0 -1
- package/lib/utils/unwrapExpression.js +0 -25
- package/lib/utils/unwrapExpression.js.map +0 -1
- package/lib/utils/unwrapSequence.js +0 -20
- package/lib/utils/unwrapSequence.js.map +0 -1
- package/lib/utils/valueToLiteral.js +0 -65
- package/lib/utils/valueToLiteral.js.map +0 -1
- package/lib/utils/visitors/JSXElementsRemover.js +0 -57
- package/lib/utils/visitors/JSXElementsRemover.js.map +0 -1
- package/lib/vm/createVmContext.js +0 -166
- package/lib/vm/createVmContext.js.map +0 -1
- package/lib/vm/process.js +0 -38
- package/lib/vm/process.js.map +0 -1
- package/types/babel.d.ts +0 -2
- package/types/babel.js +0 -2
- package/types/options/buildOptions.d.ts +0 -6
- package/types/options/buildOptions.js +0 -178
- package/types/options/loadBabelOptions.d.ts +0 -3
- package/types/options/loadBabelOptions.js +0 -26
- package/types/plugins/babel-transform.d.ts +0 -4
- package/types/plugins/babel-transform.js +0 -49
- package/types/plugins/collector.d.ts +0 -23
- package/types/plugins/collector.js +0 -62
- package/types/plugins/dynamic-import.d.ts +0 -6
- package/types/plugins/dynamic-import.js +0 -60
- package/types/plugins/preeval.d.ts +0 -16
- package/types/plugins/preeval.js +0 -69
- package/types/plugins/shaker.d.ts +0 -14
- package/types/plugins/shaker.js +0 -724
- package/types/transform/generators/explodeReexports.d.ts +0 -7
- package/types/transform/generators/explodeReexports.js +0 -65
- package/types/utils/addIdentifierToWywPreval.d.ts +0 -4
- package/types/utils/addIdentifierToWywPreval.js +0 -74
- package/types/utils/collectExportsAndImports.d.ts +0 -31
- package/types/utils/collectExportsAndImports.js +0 -1147
- package/types/utils/collectTemplateDependencies.d.ts +0 -17
- package/types/utils/collectTemplateDependencies.js +0 -220
- package/types/utils/createId.d.ts +0 -2
- package/types/utils/createId.js +0 -9
- package/types/utils/findIdentifiers.d.ts +0 -6
- package/types/utils/findIdentifiers.js +0 -67
- package/types/utils/getConstantStringValue.d.ts +0 -2
- package/types/utils/getConstantStringValue.js +0 -94
- package/types/utils/getMemberExpressionPropertyName.d.ts +0 -2
- package/types/utils/getMemberExpressionPropertyName.js +0 -46
- package/types/utils/getScope.d.ts +0 -2
- package/types/utils/getScope.js +0 -10
- package/types/utils/getSource.d.ts +0 -2
- package/types/utils/getSource.js +0 -22
- package/types/utils/getTagProcessor.d.ts +0 -13
- package/types/utils/getTagProcessor.js +0 -411
- package/types/utils/isExports.d.ts +0 -6
- package/types/utils/isExports.js +0 -19
- package/types/utils/isGlobal.d.ts +0 -2
- package/types/utils/isGlobal.js +0 -9
- package/types/utils/isNodePath.d.ts +0 -3
- package/types/utils/isNodePath.js +0 -6
- package/types/utils/isRemoved.d.ts +0 -5
- package/types/utils/isRemoved.js +0 -41
- package/types/utils/isRequire.d.ts +0 -6
- package/types/utils/isRequire.js +0 -14
- package/types/utils/isTypedNode.d.ts +0 -5
- package/types/utils/isTypedNode.js +0 -9
- package/types/utils/isUnnecessaryReactCall.d.ts +0 -3
- package/types/utils/isUnnecessaryReactCall.js +0 -75
- package/types/utils/removeDangerousCode.d.ts +0 -4
- package/types/utils/removeDangerousCode.js +0 -326
- package/types/utils/replaceImportMetaEnv.d.ts +0 -3
- package/types/utils/replaceImportMetaEnv.js +0 -39
- package/types/utils/scopeHelpers.d.ts +0 -12
- package/types/utils/scopeHelpers.js +0 -580
- package/types/utils/traversalCache.d.ts +0 -4
- package/types/utils/traversalCache.js +0 -27
- package/types/utils/unwrapExpression.d.ts +0 -2
- package/types/utils/unwrapExpression.js +0 -57
- package/types/utils/unwrapSequence.d.ts +0 -8
- package/types/utils/unwrapSequence.js +0 -16
- package/types/utils/valueToLiteral.d.ts +0 -3
- package/types/utils/valueToLiteral.js +0 -63
- package/types/utils/visitors/JSXElementsRemover.d.ts +0 -3
- package/types/utils/visitors/JSXElementsRemover.js +0 -51
|
@@ -1,264 +1,107 @@
|
|
|
1
|
-
import { readFileSync } from
|
|
2
|
-
import { dirname, extname, isAbsolute } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { stripQueryAndHash } from
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { dirname, extname, isAbsolute } from "path";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { parseSync } from "oxc-parser";
|
|
5
|
+
import { logger } from "@wyw-in-js/shared";
|
|
6
|
+
import { oxcShaker } from "../shaker.js";
|
|
7
|
+
import { getFileIdx } from "../utils/getFileIdx.js";
|
|
8
|
+
import { stripQueryAndHash } from "../utils/parseRequest.js";
|
|
9
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
9
10
|
export function getMatchedRule(rules, filename, code) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
action: 'ignore'
|
|
24
|
-
};
|
|
11
|
+
for (let i = rules.length - 1; i >= 0; i--) {
|
|
12
|
+
const rule = rules[i];
|
|
13
|
+
if (!rule.test) {
|
|
14
|
+
return rule;
|
|
15
|
+
}
|
|
16
|
+
if (typeof rule.test === "function" && rule.test(filename, code)) {
|
|
17
|
+
return rule;
|
|
18
|
+
}
|
|
19
|
+
if (rule.test instanceof RegExp && rule.test.test(filename)) {
|
|
20
|
+
return rule;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { action: "ignore" };
|
|
25
24
|
}
|
|
26
|
-
export function parseFile(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return /([\\/])babel-plugin-module-resolver\1/.test(key);
|
|
42
|
-
};
|
|
43
|
-
let moduleResolverWarned = false;
|
|
44
|
-
const normalizeBabelKey = key => key.replace(/\\/g, '/');
|
|
45
|
-
const isBabelPresetTypescript = key => {
|
|
46
|
-
const normalized = normalizeBabelKey(key);
|
|
47
|
-
if (normalized === 'typescript') return true;
|
|
48
|
-
return normalized.includes('preset-typescript');
|
|
49
|
-
};
|
|
50
|
-
const isBabelTransformTypescriptPlugin = key => {
|
|
51
|
-
const normalized = normalizeBabelKey(key);
|
|
52
|
-
if (normalized === 'transform-typescript') return true;
|
|
53
|
-
return normalized.includes('plugin-transform-typescript');
|
|
54
|
-
};
|
|
55
|
-
const withAllowDeclareFields = item => {
|
|
56
|
-
if (!Array.isArray(item)) {
|
|
57
|
-
return [item, {
|
|
58
|
-
allowDeclareFields: true
|
|
59
|
-
}];
|
|
60
|
-
}
|
|
61
|
-
const [target, rawOptions, ...rest] = item;
|
|
62
|
-
const options = typeof rawOptions === 'object' && rawOptions !== null && !Array.isArray(rawOptions) ? rawOptions : {};
|
|
63
|
-
if ('allowDeclareFields' in options) {
|
|
64
|
-
return item;
|
|
65
|
-
}
|
|
66
|
-
return [target, {
|
|
67
|
-
...options,
|
|
68
|
-
allowDeclareFields: true
|
|
69
|
-
}, ...rest];
|
|
70
|
-
};
|
|
71
|
-
const ensureAllowDeclareFieldsInBabelOptions = (babelOptions, scope = 'top') => {
|
|
72
|
-
let presetsChanged = false;
|
|
73
|
-
let pluginsChanged = false;
|
|
74
|
-
let overridesChanged = false;
|
|
75
|
-
let envChanged = false;
|
|
76
|
-
const presets = babelOptions.presets?.map(item => {
|
|
77
|
-
const key = getPluginKey(item);
|
|
78
|
-
if (!key || !isBabelPresetTypescript(key)) {
|
|
79
|
-
return item;
|
|
80
|
-
}
|
|
81
|
-
presetsChanged = true;
|
|
82
|
-
return withAllowDeclareFields(item);
|
|
83
|
-
});
|
|
84
|
-
const plugins = babelOptions.plugins?.map(item => {
|
|
85
|
-
const key = getPluginKey(item);
|
|
86
|
-
if (!key || !isBabelTransformTypescriptPlugin(key)) {
|
|
87
|
-
return item;
|
|
88
|
-
}
|
|
89
|
-
pluginsChanged = true;
|
|
90
|
-
return withAllowDeclareFields(item);
|
|
91
|
-
});
|
|
92
|
-
const {
|
|
93
|
-
overrides: baseOverrides
|
|
94
|
-
} = babelOptions;
|
|
95
|
-
let overrides = baseOverrides;
|
|
96
|
-
if (scope === 'top' && baseOverrides) {
|
|
97
|
-
const patchedOverrides = baseOverrides.map(override => ensureAllowDeclareFieldsInBabelOptions(override, 'override'));
|
|
98
|
-
if (patchedOverrides.some((patchedOverride, idx) => patchedOverride !== baseOverrides[idx])) {
|
|
99
|
-
overridesChanged = true;
|
|
100
|
-
overrides = patchedOverrides;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const {
|
|
104
|
-
env: baseEnv
|
|
105
|
-
} = babelOptions;
|
|
106
|
-
let env = baseEnv;
|
|
107
|
-
if (scope === 'top' && baseEnv) {
|
|
108
|
-
const entries = Object.entries(baseEnv);
|
|
109
|
-
const patchedEntries = entries.map(([envName, envOptions]) => [envName, envOptions ? ensureAllowDeclareFieldsInBabelOptions(envOptions, 'env') : envOptions]);
|
|
110
|
-
if (patchedEntries.some(([, patched], idx) => patched !== entries[idx][1])) {
|
|
111
|
-
envChanged = true;
|
|
112
|
-
env = Object.fromEntries(patchedEntries);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (!presetsChanged && !pluginsChanged && !overridesChanged && !envChanged) {
|
|
116
|
-
return babelOptions;
|
|
117
|
-
}
|
|
118
|
-
const next = {
|
|
119
|
-
...babelOptions
|
|
120
|
-
};
|
|
121
|
-
if (presetsChanged) next.presets = presets;
|
|
122
|
-
if (pluginsChanged) next.plugins = plugins;
|
|
123
|
-
if (overridesChanged) next.overrides = overrides;
|
|
124
|
-
if (envChanged) next.env = env;
|
|
125
|
-
return next;
|
|
126
|
-
};
|
|
127
|
-
function buildConfigs(services, name, pluginOptions, babelOptions) {
|
|
128
|
-
const {
|
|
129
|
-
babel,
|
|
130
|
-
options
|
|
131
|
-
} = services;
|
|
132
|
-
const commonOptions = {
|
|
133
|
-
ast: true,
|
|
134
|
-
filename: name,
|
|
135
|
-
inputSourceMap: options.inputSourceMap,
|
|
136
|
-
root: options.root,
|
|
137
|
-
sourceFileName: name,
|
|
138
|
-
sourceMaps: true
|
|
139
|
-
};
|
|
140
|
-
const isTypescriptFile = name.endsWith('.ts') || name.endsWith('.tsx') || name.endsWith('.mts') || name.endsWith('.cts');
|
|
141
|
-
let rawConfig = buildOptions(pluginOptions?.babelOptions, babelOptions, commonOptions);
|
|
142
|
-
if (isTypescriptFile) {
|
|
143
|
-
rawConfig = ensureAllowDeclareFieldsInBabelOptions(rawConfig);
|
|
144
|
-
}
|
|
145
|
-
const useBabelConfigs = isFeatureEnabled(pluginOptions.features, 'useBabelConfigs', name);
|
|
146
|
-
if (!useBabelConfigs) {
|
|
147
|
-
rawConfig = {
|
|
148
|
-
...rawConfig,
|
|
149
|
-
configFile: false
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
const parseConfig = loadBabelOptions(babel, name, {
|
|
153
|
-
babelrc: useBabelConfigs,
|
|
154
|
-
...rawConfig
|
|
155
|
-
});
|
|
156
|
-
const parseHasModuleResolver = parseConfig.plugins?.some(isModuleResolver);
|
|
157
|
-
const rawHasModuleResolver = rawConfig.plugins?.some(isModuleResolver);
|
|
158
|
-
if (parseHasModuleResolver && !rawHasModuleResolver) {
|
|
159
|
-
if (!moduleResolverWarned) {
|
|
160
|
-
// eslint-disable-next-line no-console
|
|
161
|
-
console.warn(`[wyw-in-js] ${name} has a module-resolver plugin in its babelrc, but it is not present ` + `in the babelOptions for the wyw-in-js plugin. This works for now but will be an error in the future. ` + `Please add the module-resolver plugin to the babelOptions for the wyw-in-js plugin.`);
|
|
162
|
-
moduleResolverWarned = true;
|
|
163
|
-
}
|
|
164
|
-
rawConfig = {
|
|
165
|
-
...rawConfig,
|
|
166
|
-
plugins: [...(parseConfig.plugins?.filter(plugin => isModuleResolver(plugin)) ?? []), ...(rawConfig.plugins ?? [])]
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
const evalConfig = loadBabelOptions(babel, name, {
|
|
170
|
-
babelrc: false,
|
|
171
|
-
...rawConfig
|
|
172
|
-
});
|
|
173
|
-
return {
|
|
174
|
-
evalConfig,
|
|
175
|
-
parseConfig
|
|
176
|
-
};
|
|
25
|
+
export function parseFile(_runtime, filename, originalCode) {
|
|
26
|
+
const log = logger.extend("transform:parse").extend(getFileIdx(filename));
|
|
27
|
+
const parseResult = parseSync(filename, originalCode, {
|
|
28
|
+
astType: filename.endsWith(".ts") || filename.endsWith(".tsx") ? "ts" : "js",
|
|
29
|
+
range: true,
|
|
30
|
+
sourceType: "module"
|
|
31
|
+
});
|
|
32
|
+
const fatalError = parseResult.errors.find((error) => error.severity === "Error");
|
|
33
|
+
if (fatalError) {
|
|
34
|
+
throw new Error(fatalError.message);
|
|
35
|
+
}
|
|
36
|
+
log("stage-1", `${filename} has been parsed`);
|
|
37
|
+
return parseResult.program;
|
|
177
38
|
}
|
|
178
39
|
export function loadAndParse(services, name, loadedCode, log) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
code,
|
|
225
|
-
evaluator: 'ignored',
|
|
226
|
-
reason: 'rule'
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
const evaluator = typeof action === 'function' ? action : require(require.resolve(action, {
|
|
230
|
-
paths: [dirname(filename)]
|
|
231
|
-
})).default;
|
|
232
|
-
return {
|
|
233
|
-
get ast() {
|
|
234
|
-
return getOrParse();
|
|
235
|
-
},
|
|
236
|
-
code,
|
|
237
|
-
evaluator,
|
|
238
|
-
evalConfig
|
|
239
|
-
};
|
|
40
|
+
const { options: { pluginOptions } } = services;
|
|
41
|
+
const filename = stripQueryAndHash(name);
|
|
42
|
+
const extension = extname(filename);
|
|
43
|
+
if (!pluginOptions.extensions.includes(extension)) {
|
|
44
|
+
log("[createEntrypoint] %s is ignored. If you want it to be processed, you should add '%s' to the \"extensions\" option.", filename, extension);
|
|
45
|
+
return {
|
|
46
|
+
code: isAbsolute(filename) ? loadedCode : "",
|
|
47
|
+
evaluator: "ignored",
|
|
48
|
+
reason: "extension"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
let code = loadedCode;
|
|
52
|
+
if (code === undefined) {
|
|
53
|
+
const cachedEntrypoint = services.cache.get("entrypoints", name);
|
|
54
|
+
if (cachedEntrypoint && "initialCode" in cachedEntrypoint && typeof cachedEntrypoint.initialCode === "string") {
|
|
55
|
+
code = cachedEntrypoint.initialCode;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
code ??= readFileSync(filename, "utf-8");
|
|
59
|
+
const { action } = getMatchedRule(pluginOptions.rules, filename, code);
|
|
60
|
+
if (action === "ignore") {
|
|
61
|
+
log("[createEntrypoint] %s is ignored by rule", name);
|
|
62
|
+
return {
|
|
63
|
+
code,
|
|
64
|
+
evaluator: "ignored",
|
|
65
|
+
reason: "rule"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const evaluator = typeof action === "function" ? action : nodeRequire(nodeRequire.resolve(action, { paths: [dirname(filename)] })).default;
|
|
69
|
+
if (evaluator !== oxcShaker) {
|
|
70
|
+
throw new Error(`[wyw-in-js] ${filename} matched a legacy evaluator. The Oxc runtime path supports only the default Oxc evaluator.`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
get ast() {
|
|
74
|
+
return null;
|
|
75
|
+
},
|
|
76
|
+
code,
|
|
77
|
+
evaluator,
|
|
78
|
+
evalConfig: {
|
|
79
|
+
ast: false,
|
|
80
|
+
configFile: false,
|
|
81
|
+
filename,
|
|
82
|
+
root: services.options.root ?? process.cwd()
|
|
83
|
+
}
|
|
84
|
+
};
|
|
240
85
|
}
|
|
241
86
|
export function getStack(entrypoint) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
return stack;
|
|
87
|
+
if (!entrypoint) return [];
|
|
88
|
+
const stack = [entrypoint.name];
|
|
89
|
+
let { parents } = entrypoint;
|
|
90
|
+
while (parents.length) {
|
|
91
|
+
stack.push(parents[0].name);
|
|
92
|
+
parents = parents[0].parents;
|
|
93
|
+
}
|
|
94
|
+
return stack;
|
|
252
95
|
}
|
|
253
96
|
export function mergeOnly(a, b) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
97
|
+
const result = new Set(a);
|
|
98
|
+
b.forEach((item) => result.add(item));
|
|
99
|
+
return [...result].filter((i) => i).sort();
|
|
257
100
|
}
|
|
258
101
|
export const isSuperSet = (a, b) => {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
102
|
+
if (a.includes("*")) return true;
|
|
103
|
+
if (b.length === 0) return true;
|
|
104
|
+
const aSet = new Set(a);
|
|
105
|
+
return b.every((item) => aSet.has(item));
|
|
263
106
|
};
|
|
264
|
-
//# sourceMappingURL=Entrypoint.helpers.js.map
|
|
107
|
+
//# sourceMappingURL=Entrypoint.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entrypoint.helpers.js","names":["readFileSync","dirname","extname","isAbsolute","logger","isFeatureEnabled","buildOptions","loadBabelOptions","getFileIdx","getPluginKey","stripQueryAndHash","getMatchedRule","rules","filename","code","i","length","rule","test","RegExp","action","parseFile","babel","originalCode","parseConfig","log","extend","parseResult","parseSync","Error","isModuleResolver","plugin","key","includes","moduleResolverWarned","normalizeBabelKey","replace","isBabelPresetTypescript","normalized","isBabelTransformTypescriptPlugin","withAllowDeclareFields","item","Array","isArray","allowDeclareFields","target","rawOptions","rest","options","ensureAllowDeclareFieldsInBabelOptions","babelOptions","scope","presetsChanged","pluginsChanged","overridesChanged","envChanged","presets","map","plugins","overrides","baseOverrides","patchedOverrides","override","some","patchedOverride","idx","env","baseEnv","entries","Object","patchedEntries","envName","envOptions","patched","fromEntries","next","buildConfigs","services","name","pluginOptions","commonOptions","ast","inputSourceMap","root","sourceFileName","sourceMaps","isTypescriptFile","endsWith","rawConfig","useBabelConfigs","features","configFile","babelrc","parseHasModuleResolver","rawHasModuleResolver","console","warn","filter","evalConfig","loadAndParse","loadedCode","eventEmitter","extension","extensions","evaluator","reason","undefined","cachedEntrypoint","cache","get","initialCode","getOrParse","perf","require","resolve","paths","default","getStack","entrypoint","stack","parents","push","mergeOnly","a","b","result","Set","forEach","add","sort","isSuperSet","aSet","every","has"],"sources":["../../src/transform/Entrypoint.helpers.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { dirname, extname, isAbsolute } from 'path';\n\nimport type { TransformOptions, PluginItem } from '@babel/core';\nimport type { File } from '@babel/types';\n\nimport type {\n Debugger,\n EvalRule,\n Evaluator,\n StrictOptions,\n} from '@wyw-in-js/shared';\nimport { logger, isFeatureEnabled } from '@wyw-in-js/shared';\n\nimport type { Core } from '../babel';\nimport { buildOptions } from '../options/buildOptions';\nimport { loadBabelOptions } from '../options/loadBabelOptions';\nimport type { ParentEntrypoint } from '../types';\nimport { getFileIdx } from '../utils/getFileIdx';\nimport { getPluginKey } from '../utils/getPluginKey';\n\nimport type { IEntrypointCode, IIgnoredEntrypoint } from './Entrypoint.types';\nimport type { Services } from './types';\nimport { stripQueryAndHash } from '../utils/parseRequest';\n\nexport function getMatchedRule(\n rules: EvalRule[],\n filename: string,\n code: string\n): EvalRule {\n for (let i = rules.length - 1; i >= 0; i--) {\n const rule = rules[i];\n if (!rule.test) {\n return rule;\n }\n\n if (typeof rule.test === 'function' && rule.test(filename, code)) {\n return rule;\n }\n\n if (rule.test instanceof RegExp && rule.test.test(filename)) {\n return rule;\n }\n }\n\n return { action: 'ignore' };\n}\n\nexport function parseFile(\n babel: Core,\n filename: string,\n originalCode: string,\n parseConfig: TransformOptions\n): File {\n const log = logger.extend('transform:parse').extend(getFileIdx(filename));\n\n const parseResult = babel.parseSync(originalCode, parseConfig);\n if (!parseResult) {\n throw new Error(`Failed to parse ${filename}`);\n }\n\n log('stage-1', `${filename} has been parsed`);\n\n return parseResult;\n}\n\nconst isModuleResolver = (plugin: PluginItem) => {\n const key = getPluginKey(plugin);\n if (!key) return false;\n\n if (['module-resolver', 'babel-plugin-module-resolver'].includes(key)) {\n return true;\n }\n\n return /([\\\\/])babel-plugin-module-resolver\\1/.test(key);\n};\n\nlet moduleResolverWarned = false;\n\nconst normalizeBabelKey = (key: string) => key.replace(/\\\\/g, '/');\n\nconst isBabelPresetTypescript = (key: string) => {\n const normalized = normalizeBabelKey(key);\n\n if (normalized === 'typescript') return true;\n return normalized.includes('preset-typescript');\n};\n\nconst isBabelTransformTypescriptPlugin = (key: string) => {\n const normalized = normalizeBabelKey(key);\n\n if (normalized === 'transform-typescript') return true;\n return normalized.includes('plugin-transform-typescript');\n};\n\nconst withAllowDeclareFields = (item: PluginItem): PluginItem => {\n if (!Array.isArray(item)) {\n return [item, { allowDeclareFields: true }];\n }\n\n const [target, rawOptions, ...rest] = item;\n const options =\n typeof rawOptions === 'object' &&\n rawOptions !== null &&\n !Array.isArray(rawOptions)\n ? rawOptions\n : {};\n\n if ('allowDeclareFields' in options) {\n return item;\n }\n\n return [target, { ...options, allowDeclareFields: true }, ...rest];\n};\n\ntype AllowDeclareFieldsPatchScope = 'top' | 'env' | 'override';\n\nconst ensureAllowDeclareFieldsInBabelOptions = (\n babelOptions: TransformOptions,\n scope: AllowDeclareFieldsPatchScope = 'top'\n): TransformOptions => {\n let presetsChanged = false;\n let pluginsChanged = false;\n let overridesChanged = false;\n let envChanged = false;\n\n const presets = babelOptions.presets?.map((item) => {\n const key = getPluginKey(item);\n if (!key || !isBabelPresetTypescript(key)) {\n return item;\n }\n\n presetsChanged = true;\n return withAllowDeclareFields(item);\n });\n\n const plugins = babelOptions.plugins?.map((item) => {\n const key = getPluginKey(item);\n if (!key || !isBabelTransformTypescriptPlugin(key)) {\n return item;\n }\n\n pluginsChanged = true;\n return withAllowDeclareFields(item);\n });\n\n const { overrides: baseOverrides } = babelOptions;\n let overrides = baseOverrides;\n if (scope === 'top' && baseOverrides) {\n const patchedOverrides = baseOverrides.map((override) =>\n ensureAllowDeclareFieldsInBabelOptions(\n override as TransformOptions,\n 'override'\n )\n );\n\n if (\n patchedOverrides.some(\n (patchedOverride, idx) => patchedOverride !== baseOverrides[idx]\n )\n ) {\n overridesChanged = true;\n overrides = patchedOverrides;\n }\n }\n\n const { env: baseEnv } = babelOptions;\n let env = baseEnv;\n if (scope === 'top' && baseEnv) {\n const entries = Object.entries(baseEnv);\n const patchedEntries = entries.map(([envName, envOptions]) => [\n envName,\n envOptions\n ? ensureAllowDeclareFieldsInBabelOptions(envOptions, 'env')\n : envOptions,\n ]) as Array<[string, TransformOptions | null | undefined]>;\n\n if (\n patchedEntries.some(([, patched], idx) => patched !== entries[idx][1])\n ) {\n envChanged = true;\n env = Object.fromEntries(patchedEntries);\n }\n }\n\n if (!presetsChanged && !pluginsChanged && !overridesChanged && !envChanged) {\n return babelOptions;\n }\n\n const next: TransformOptions = { ...babelOptions };\n if (presetsChanged) next.presets = presets;\n if (pluginsChanged) next.plugins = plugins;\n if (overridesChanged) next.overrides = overrides;\n if (envChanged) next.env = env;\n\n return next;\n};\n\nfunction buildConfigs(\n services: Services,\n name: string,\n pluginOptions: StrictOptions,\n babelOptions: TransformOptions | undefined\n): {\n evalConfig: TransformOptions;\n parseConfig: TransformOptions;\n} {\n const { babel, options } = services;\n\n const commonOptions = {\n ast: true,\n filename: name,\n inputSourceMap: options.inputSourceMap,\n root: options.root,\n sourceFileName: name,\n sourceMaps: true,\n };\n\n const isTypescriptFile =\n name.endsWith('.ts') ||\n name.endsWith('.tsx') ||\n name.endsWith('.mts') ||\n name.endsWith('.cts');\n\n let rawConfig = buildOptions(\n pluginOptions?.babelOptions,\n babelOptions,\n commonOptions\n );\n\n if (isTypescriptFile) {\n rawConfig = ensureAllowDeclareFieldsInBabelOptions(rawConfig);\n }\n\n const useBabelConfigs = isFeatureEnabled(\n pluginOptions.features,\n 'useBabelConfigs',\n name\n );\n\n if (!useBabelConfigs) {\n rawConfig = {\n ...rawConfig,\n configFile: false,\n };\n }\n\n const parseConfig = loadBabelOptions(babel, name, {\n babelrc: useBabelConfigs,\n ...rawConfig,\n });\n\n const parseHasModuleResolver = parseConfig.plugins?.some(isModuleResolver);\n const rawHasModuleResolver = rawConfig.plugins?.some(isModuleResolver);\n\n if (parseHasModuleResolver && !rawHasModuleResolver) {\n if (!moduleResolverWarned) {\n // eslint-disable-next-line no-console\n console.warn(\n `[wyw-in-js] ${name} has a module-resolver plugin in its babelrc, but it is not present ` +\n `in the babelOptions for the wyw-in-js plugin. This works for now but will be an error in the future. ` +\n `Please add the module-resolver plugin to the babelOptions for the wyw-in-js plugin.`\n );\n\n moduleResolverWarned = true;\n }\n\n rawConfig = {\n ...rawConfig,\n plugins: [\n ...(parseConfig.plugins?.filter((plugin) => isModuleResolver(plugin)) ??\n []),\n ...(rawConfig.plugins ?? []),\n ],\n };\n }\n\n const evalConfig = loadBabelOptions(babel, name, {\n babelrc: false,\n ...rawConfig,\n });\n\n return {\n evalConfig,\n parseConfig,\n };\n}\n\nexport function loadAndParse(\n services: Services,\n name: string,\n loadedCode: string | undefined,\n log: Debugger\n): IEntrypointCode | IIgnoredEntrypoint {\n const {\n babel,\n eventEmitter,\n options: { pluginOptions },\n } = services;\n\n const filename = stripQueryAndHash(name);\n const extension = extname(filename);\n\n if (!pluginOptions.extensions.includes(extension)) {\n log(\n '[createEntrypoint] %s is ignored. If you want it to be processed, you should add \\'%s\\' to the \"extensions\" option.',\n filename,\n extension\n );\n\n return {\n code: isAbsolute(filename) ? loadedCode : '',\n evaluator: 'ignored',\n reason: 'extension',\n };\n }\n\n let code = loadedCode;\n\n if (code === undefined) {\n const cachedEntrypoint = services.cache.get('entrypoints', name);\n if (\n cachedEntrypoint &&\n 'initialCode' in cachedEntrypoint &&\n typeof cachedEntrypoint.initialCode === 'string'\n ) {\n code = cachedEntrypoint.initialCode;\n }\n }\n\n code ??= readFileSync(filename, 'utf-8');\n\n const { action, babelOptions } = getMatchedRule(\n pluginOptions.rules,\n filename,\n code\n );\n\n let ast: File | undefined;\n\n const { evalConfig, parseConfig } = buildConfigs(\n services,\n filename,\n pluginOptions,\n babelOptions\n );\n\n const getOrParse = () => {\n if (ast) return ast;\n ast = eventEmitter.perf('parseFile', () =>\n parseFile(babel, name, code, parseConfig)\n );\n\n return ast;\n };\n\n if (action === 'ignore') {\n log('[createEntrypoint] %s is ignored by rule', name);\n return {\n get ast() {\n return getOrParse();\n },\n code,\n evaluator: 'ignored',\n reason: 'rule',\n };\n }\n\n const evaluator: Evaluator =\n typeof action === 'function'\n ? action\n : require(\n require.resolve(action, {\n paths: [dirname(filename)],\n })\n ).default;\n\n return {\n get ast() {\n return getOrParse();\n },\n code,\n evaluator,\n evalConfig,\n };\n}\n\nexport function getStack(entrypoint: ParentEntrypoint) {\n if (!entrypoint) return [];\n\n const stack = [entrypoint.name];\n\n let { parents } = entrypoint;\n while (parents.length) {\n stack.push(parents[0].name);\n parents = parents[0].parents;\n }\n\n return stack;\n}\n\nexport function mergeOnly(a: string[], b: string[]) {\n const result = new Set(a);\n b.forEach((item) => result.add(item));\n return [...result].filter((i) => i).sort();\n}\n\nexport const isSuperSet = <T>(a: (T | '*')[], b: (T | '*')[]) => {\n if (a.includes('*')) return true;\n if (b.length === 0) return true;\n const aSet = new Set(a);\n return b.every((item) => aSet.has(item));\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,EAAEC,OAAO,EAAEC,UAAU,QAAQ,MAAM;AAWnD,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,mBAAmB;AAG5D,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,gBAAgB,QAAQ,6BAA6B;AAE9D,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,YAAY,QAAQ,uBAAuB;AAIpD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,KAAiB,EACjBC,QAAgB,EAChBC,IAAY,EACF;EACV,KAAK,IAAIC,CAAC,GAAGH,KAAK,CAACI,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IAC1C,MAAME,IAAI,GAAGL,KAAK,CAACG,CAAC,CAAC;IACrB,IAAI,CAACE,IAAI,CAACC,IAAI,EAAE;MACd,OAAOD,IAAI;IACb;IAEA,IAAI,OAAOA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,C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ync } from 'fs';\nimport { dirname, extname, isAbsolute } from 'path';\nimport { createRequire } from 'module';\n\nimport { parseSync } from 'oxc-parser';\n\nimport type { Debugger, EvalRule, Evaluator } from '@wyw-in-js/shared';\nimport { logger } from '@wyw-in-js/shared';\n\nimport { oxcShaker } from '../shaker';\nimport type { ParentEntrypoint } from '../types';\nimport { getFileIdx } from '../utils/getFileIdx';\n\nimport type {\n IEntrypointCode,\n IIgnoredEntrypoint,\n ParsedAst,\n} from './Entrypoint.types';\nimport type { Services } from './types';\nimport { stripQueryAndHash } from '../utils/parseRequest';\n\nconst nodeRequire = createRequire(import.meta.url);\n\nexport function getMatchedRule(\n rules: EvalRule[],\n filename: string,\n code: string\n): EvalRule {\n for (let i = rules.length - 1; i >= 0; i--) {\n const rule = rules[i];\n if (!rule.test) {\n return rule;\n }\n\n if (typeof rule.test === 'function' && rule.test(filename, code)) {\n return rule;\n }\n\n if (rule.test instanceof RegExp && rule.test.test(filename)) {\n return rule;\n }\n }\n\n return { action: 'ignore' };\n}\n\nexport function parseFile(\n _runtime: unknown,\n filename: string,\n originalCode: string\n): ParsedAst {\n const log = logger.extend('transform:parse').extend(getFileIdx(filename));\n\n const parseResult = parseSync(filename, originalCode, {\n astType:\n filename.endsWith('.ts') || filename.endsWith('.tsx') ? 'ts' : 'js',\n range: true,\n sourceType: 'module',\n });\n const fatalError = parseResult.errors.find(\n (error) => error.severity === 'Error'\n );\n if (fatalError) {\n throw new Error(fatalError.message);\n }\n\n log('stage-1', `${filename} has been parsed`);\n\n return parseResult.program;\n}\n\nexport function loadAndParse(\n services: Services,\n name: string,\n loadedCode: string | undefined,\n log: Debugger\n): IEntrypointCode | IIgnoredEntrypoint {\n const {\n options: { pluginOptions },\n } = services;\n\n const filename = stripQueryAndHash(name);\n const extension = extname(filename);\n\n if (!pluginOptions.extensions.includes(extension)) {\n log(\n '[createEntrypoint] %s is ignored. If you want it to be processed, you should add \\'%s\\' to the \"extensions\" option.',\n filename,\n extension\n );\n\n return {\n code: isAbsolute(filename) ? loadedCode : '',\n evaluator: 'ignored',\n reason: 'extension',\n };\n }\n\n let code = loadedCode;\n\n if (code === undefined) {\n const cachedEntrypoint = services.cache.get('entrypoints', name);\n if (\n cachedEntrypoint &&\n 'initialCode' in cachedEntrypoint &&\n typeof cachedEntrypoint.initialCode === 'string'\n ) {\n code = cachedEntrypoint.initialCode;\n }\n }\n\n code ??= readFileSync(filename, 'utf-8');\n\n const { action } = getMatchedRule(pluginOptions.rules, filename, code);\n\n if (action === 'ignore') {\n log('[createEntrypoint] %s is ignored by rule', name);\n return {\n code,\n evaluator: 'ignored',\n reason: 'rule',\n };\n }\n\n const evaluator: Evaluator =\n typeof action === 'function'\n ? action\n : nodeRequire(\n nodeRequire.resolve(action, {\n paths: [dirname(filename)],\n })\n ).default;\n\n if (evaluator !== oxcShaker) {\n throw new Error(\n `[wyw-in-js] ${filename} matched a legacy evaluator. The Oxc runtime path supports only the default Oxc evaluator.`\n );\n }\n\n return {\n get ast() {\n return null;\n },\n code,\n evaluator,\n evalConfig: {\n ast: false,\n configFile: false,\n filename,\n root: services.options.root ?? process.cwd(),\n },\n };\n}\n\nexport function getStack(entrypoint: ParentEntrypoint) {\n if (!entrypoint) return [];\n\n const stack = [entrypoint.name];\n\n let { parents } = entrypoint;\n while (parents.length) {\n stack.push(parents[0].name);\n parents = parents[0].parents;\n }\n\n return stack;\n}\n\nexport function mergeOnly(a: string[], b: string[]) {\n const result = new Set(a);\n b.forEach((item) => result.add(item));\n return [...result].filter((i) => i).sort();\n}\n\nexport const isSuperSet = <T>(a: (T | '*')[], b: (T | '*')[]) => {\n if (a.includes('*')) return true;\n if (b.length === 0) return true;\n const aSet = new Set(a);\n return b.every((item) => aSet.has(item));\n};\n"],"file":"Entrypoint.helpers.js"}
|