@wyw-in-js/transform 1.1.0 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/cache.js +426 -289
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js +137 -134
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/eval/broker.js +2134 -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/resolverStrategy.js +51 -0
- package/esm/eval/resolverStrategy.js.map +1 -0
- package/esm/eval/runner.js +1759 -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 +896 -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 +78 -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 +165 -196
- package/esm/transform/generators/resolveImports.js.map +1 -1
- package/esm/transform/generators/resolveStaticOxcValues.js +2911 -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 +239 -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 +154 -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 +123 -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 +46 -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.js +1217 -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.js +220 -0
- package/esm/utils/collectOxcRuntime.js.map +1 -0
- package/esm/utils/collectOxcTemplateDependencies.js +1398 -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/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.js +97 -0
- package/esm/utils/oxcPreevalStage.js.map +1 -0
- package/esm/utils/oxcPreevalTransforms.js +1054 -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/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 +18 -26
- package/types/cache.d.ts +17 -8
- package/types/cache.js +237 -95
- package/types/debug/fileReporter.js +22 -22
- package/types/eval/broker.d.ts +88 -0
- package/types/eval/broker.js +2262 -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 +97 -0
- package/types/eval/protocol.js +1 -0
- package/types/eval/resolverStrategy.d.ts +13 -0
- package/types/eval/resolverStrategy.js +46 -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 +35 -7
- package/types/module.js +535 -163
- 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 +28 -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.js +18 -22
- package/types/transform/generators/resolveStaticOxcValues.d.ts +2 -0
- package/types/transform/generators/resolveStaticOxcValues.js +3235 -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 +203 -199
- package/types/transform/generators/workflow.js +62 -45
- package/types/transform/helpers/loadWywOptions.js +94 -20
- 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 +88 -101
- package/types/types.d.ts +0 -23
- package/types/types.js +1 -2
- package/types/utils/EventEmitter.js +3 -9
- 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.d.ts +16 -0
- package/types/utils/applyOxcProcessors.js +1391 -0
- package/types/utils/collectOxcExportsAndImports.d.ts +35 -0
- package/types/utils/collectOxcExportsAndImports.js +957 -0
- package/types/utils/collectOxcRuntime.d.ts +14 -0
- package/types/utils/collectOxcRuntime.js +250 -0
- package/types/utils/collectOxcTemplateDependencies.d.ts +38 -0
- package/types/utils/collectOxcTemplateDependencies.js +1580 -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/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.d.ts +20 -0
- package/types/utils/oxcPreevalStage.js +102 -0
- package/types/utils/oxcPreevalTransforms.d.ts +13 -0
- package/types/utils/oxcPreevalTransforms.js +1179 -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/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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shaker.js","names":["pathLib","logger","syncResolve","collectExportsAndImports","sideEffectImport","getFileIdx","isRemoved","applyAction","dereference","findActionForNode","reference","removeWithRelated","invalidateTraversalCache","stripQueryAndHash","getImportOverride","toImportKey","warnedDynamicImportFiles","Set","getNonParamBinding","exportPath","name","binding","scope","getBinding","kind","parent","getBindingForExport","isIdentifier","node","variableDeclarator","findParent","p","isVariableDeclarator","id","get","isAssignmentExpression","left","isFunctionDeclaration","isClassDeclaration","undefined","isTSEnumDeclaration","withoutRemoved","items","filter","local","rearrangeExports","types","t","root","exportRefs","exports","rearranged","rootScope","forEach","refs","length","declarator","uid","generateUid","declaration","unshiftContainer","variableDeclaration","identifier","registerDeclaration","constantViolations","ref","replaced","replaceWith","isBindingIdentifier","push","registerConstantViolation","assigmentToExport","expressionStatement","assignmentExpression","memberExpression","body","lastViolation","pathInRoot","find","n","isDescendant","pushed","insertAfter","getPropertyAssignmentStatement","bindingName","assignment","isMemberExpression","object","statement","parentPath","isExpressionStatement","isWithinAliveExport","aliveExports","some","alive","isAncestor","getExportPathsForVariableDeclaration","exportPaths","Object","keys","getOuterBindingIdentifiers","includes","getDeclaratorExportLiveness","bindingNames","liveness","isAlive","has","hasRuntimeReferencesToEnum","path","enumId","program","getProgramParent","hasReference","traverse","Identifier","ancestor","isTSType","isFlowType","isReferencedIdentifier","localBinding","stop","stripExportKeepDeclaration","exportDeclaration","isExportNamedDeclaration","cloneNode","isVariableDeclaration","declarators","staleExportPaths","segments","clonedDeclarator","currentSegment","replaceWithMultiple","map","groupedDeclarators","groupedDeclaration","exportNamedDeclaration","shakerPlugin","babel","keepSideEffects","ifUnknownExport","importOverrides","onlyExports","shakerLogger","extend","pre","file","filename","opts","log","join","onlyExportsSet","shouldKeepOverride","override","hasImportOverride","cache","Map","source","cached","strippedSource","direct","result","set","isFileImport","startsWith","isAbsolute","resolved","key","collected","imports","sideEffectImports","values","reexports","hasWywPreval","__wywPreval","hasDefault","default","delete","size","deadExports","remove","importedAsSideEffect","isEsModule","add","importNames","imported","entries","exported","isImportSpecifier","isImportDefaultSpecifier","isImportNamespaceSpecifier","exp","exportToPath","notFoundExports","clear","isAllExportsFound","Error","forDeleting","i","forDeletingSet","queueForDeleting","deleted","dereferenced","changed","action","outerReferences","referencePaths","candidate","removableAssignmentStatements","removableOuterReferences","blockingReferences","strippedEnum","stalePath","strippedWithBlocking","strippedWithoutBlocking","crawl","unreferenced","getAllBindings","referenced","isArrayPattern","isObjectPattern","violation","visitor","post","dynamicImportWarningsEnabled","Boolean","process","env","WYW_WARN_DYNAMIC_IMPORTS","dynamicImports","imp","type","sources","Array","from","sort","sourcesToWarn","shouldWarn","importKey","overrideKeys","item","index","array","firstIndexForKey","findIndex","warning","console","warn","processedImports","addImport","metadata","wywEvaluator"],"sources":["../../src/plugins/shaker.ts"],"sourcesContent":["import pathLib from 'path';\n\nimport type { BabelFile, PluginObj, NodePath } from '@babel/core';\nimport type { Binding } from '@babel/traverse';\nimport type {\n ExportNamedDeclaration,\n Identifier,\n MemberExpression,\n Program,\n VariableDeclaration,\n VariableDeclarator,\n} from '@babel/types';\n\nimport { logger, syncResolve } from '@wyw-in-js/shared';\nimport type { ImportOverride, ImportOverrides } from '@wyw-in-js/shared';\n\nimport type { Core } from '../babel';\nimport type { IMetadata } from '../utils/ShakerMetadata';\nimport type { Exports, IState } from '../utils/collectExportsAndImports';\nimport {\n collectExportsAndImports,\n sideEffectImport,\n} from '../utils/collectExportsAndImports';\nimport { getFileIdx } from '../utils/getFileIdx';\nimport { isRemoved } from '../utils/isRemoved';\nimport {\n applyAction,\n dereference,\n findActionForNode,\n reference,\n removeWithRelated,\n} from '../utils/scopeHelpers';\nimport { invalidateTraversalCache } from '../utils/traversalCache';\nimport { stripQueryAndHash } from '../utils/parseRequest';\nimport { getImportOverride, toImportKey } from '../utils/importOverrides';\n\nconst warnedDynamicImportFiles = new Set<string>();\n\nexport interface IShakerOptions {\n ifUnknownExport?: 'error' | 'ignore' | 'reexport-all' | 'skip-shaking';\n importOverrides?: ImportOverrides;\n keepSideEffects?: boolean;\n onlyExports: string[];\n root?: string;\n}\n\ninterface NodeWithName {\n name: string;\n}\n\nfunction getNonParamBinding(\n exportPath: NodePath,\n name: string\n): Binding | undefined {\n const binding = exportPath.scope.getBinding(name);\n if (binding && (binding.kind as string) !== 'param') {\n return binding;\n }\n\n // When `exportPath` is inside a function scope, a parameter can shadow\n // the actual export binding (e.g. `export function fallback(fallback) {}`).\n // In such cases we need the binding from the declaration scope.\n return exportPath.scope.parent?.getBinding(name) ?? binding;\n}\n\nfunction getBindingForExport(exportPath: NodePath): Binding | undefined {\n if (exportPath.isIdentifier()) {\n return getNonParamBinding(exportPath, exportPath.node.name);\n }\n\n const variableDeclarator = exportPath.findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n if (variableDeclarator) {\n const id = variableDeclarator.get('id');\n if (id.isIdentifier()) {\n return variableDeclarator.scope.getBinding(id.node.name);\n }\n }\n\n if (exportPath.isAssignmentExpression()) {\n const left = exportPath.get('left');\n if (left.isIdentifier()) {\n return getNonParamBinding(exportPath, left.node.name);\n }\n }\n\n if (exportPath.isFunctionDeclaration() || exportPath.isClassDeclaration()) {\n const { id } = exportPath.node;\n if (!id) {\n // `export default function() {}` / `export default class {}` (anonymous)\n return undefined;\n }\n return getNonParamBinding(exportPath, id.name);\n }\n\n if (exportPath.isTSEnumDeclaration()) {\n return getNonParamBinding(exportPath, exportPath.node.id.name);\n }\n\n return undefined;\n}\n\nconst withoutRemoved = <T extends { local: NodePath }>(items: T[]): T[] =>\n items.filter(({ local }) => !isRemoved(local));\n\nfunction rearrangeExports(\n { types: t }: Core,\n root: NodePath<Program>,\n exportRefs: Map<string, NodePath<MemberExpression>[]>,\n exports: Exports\n): Exports {\n const rearranged = {\n ...exports,\n };\n\n const rootScope = root.scope;\n exportRefs.forEach((refs, name) => {\n if (refs.length <= 1) {\n if (refs.length === 1) {\n // Maybe exports is assigned to another variable?\n const declarator = refs[0].findParent((p) =>\n p.isVariableDeclarator()\n ) as NodePath<VariableDeclarator> | undefined;\n\n if (!declarator) {\n return;\n }\n } else {\n return;\n }\n }\n\n const uid = rootScope.generateUid(name);\n // Define variable in the beginning\n const [declaration] = root.unshiftContainer('body', [\n t.variableDeclaration('var', [t.variableDeclarator(t.identifier(uid))]),\n ]);\n\n rootScope.registerDeclaration(declaration);\n\n const constantViolations: NodePath<Identifier>[] = [];\n // Replace every reference with defined variable\n refs.forEach((ref) => {\n const [replaced] = ref.replaceWith(t.identifier(uid));\n if (replaced.isBindingIdentifier()) {\n constantViolations.push(replaced);\n } else {\n reference(replaced);\n }\n });\n\n constantViolations.forEach((id) => {\n rootScope.registerConstantViolation(id);\n });\n\n const assigmentToExport = t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.memberExpression(t.identifier('exports'), t.identifier(name)),\n t.identifier(uid)\n )\n );\n\n // export.foo = _foo will be inserted either after the last _foo assigment or in the end of the file\n const body = root.get('body');\n const lastViolation =\n constantViolations[constantViolations.length - 1] ??\n body[body.length - 1];\n const pathInRoot = root\n .get('body')\n .find((n) => lastViolation.isDescendant(n))!;\n\n const [pushed] = pathInRoot.insertAfter(assigmentToExport);\n\n const local = pushed.get('expression.right') as NodePath<Identifier>;\n reference(local);\n\n rearranged[name] = local;\n });\n\n return rearranged;\n}\n\nconst getPropertyAssignmentStatement = (\n ref: NodePath,\n bindingName: string\n): NodePath | null => {\n const assignment = ref.findParent((parent) =>\n parent.isAssignmentExpression()\n );\n if (!assignment?.isAssignmentExpression()) return null;\n\n const left = assignment.get('left');\n if (!left.isMemberExpression()) return null;\n\n const object = left.get('object');\n if (!object.isIdentifier({ name: bindingName })) return null;\n\n const statement = assignment.parentPath;\n return statement?.isExpressionStatement() ? statement : null;\n};\n\nconst isWithinAliveExport = (\n ref: NodePath,\n aliveExports: Set<NodePath>\n): boolean =>\n [...aliveExports].some((alive) => alive === ref || alive.isAncestor(ref));\n\nfunction getExportPathsForVariableDeclaration(\n declaration: NodePath<VariableDeclaration>,\n exports: Exports\n): NodePath[] {\n const exportPaths: NodePath[] = [];\n\n declaration.get('declarations').forEach((declarator) => {\n Object.keys(declarator.getOuterBindingIdentifiers()).forEach((name) => {\n const exportPath = exports[name];\n if (exportPath && !exportPaths.includes(exportPath)) {\n exportPaths.push(exportPath);\n }\n });\n });\n\n return exportPaths;\n}\n\nfunction getDeclaratorExportLiveness(\n declarator: NodePath<VariableDeclarator>,\n exports: Exports,\n aliveExports: Set<NodePath>\n): boolean | null {\n const bindingNames = Object.keys(declarator.getOuterBindingIdentifiers());\n if (bindingNames.length === 0) {\n return null;\n }\n\n let liveness: boolean | null = null;\n for (const name of bindingNames) {\n const exportPath = exports[name];\n if (!exportPath) {\n return null;\n }\n\n const isAlive = aliveExports.has(exportPath);\n if (liveness === null) {\n liveness = isAlive;\n } else if (liveness !== isAlive) {\n return null;\n }\n }\n\n return liveness;\n}\n\nfunction hasRuntimeReferencesToEnum(path: NodePath): boolean {\n if (!path.isTSEnumDeclaration()) {\n return false;\n }\n\n const enumId = path.get('id');\n const bindingName = enumId.node.name;\n const program = path.scope.getProgramParent().path as NodePath<Program>;\n\n let hasReference = false;\n program.traverse({\n Identifier(identifier) {\n if (hasReference || identifier.node.name !== bindingName) {\n return;\n }\n\n if (identifier.findParent((ancestor) => ancestor === path)) {\n return;\n }\n\n if (\n identifier.find(\n (ancestor) => ancestor.isTSType() || ancestor.isFlowType()\n )\n ) {\n return;\n }\n\n if (!identifier.isReferencedIdentifier()) {\n return;\n }\n\n const localBinding = identifier.scope.getBinding(bindingName);\n if (localBinding && localBinding.path !== enumId) {\n return;\n }\n\n hasReference = true;\n identifier.stop();\n },\n });\n\n return hasReference;\n}\n\nfunction stripExportKeepDeclaration(\n path: NodePath,\n exports: Exports,\n aliveExports: Set<NodePath>,\n t: Core['types']\n): NodePath[] | null {\n const exportDeclaration = path.findParent((p) =>\n p.isExportNamedDeclaration()\n ) as NodePath<ExportNamedDeclaration> | null;\n if (!exportDeclaration) return null;\n\n const declaration = exportDeclaration.get('declaration');\n if (!declaration.node) return null;\n\n if (\n declaration.isFunctionDeclaration() ||\n declaration.isClassDeclaration() ||\n declaration.isTSEnumDeclaration()\n ) {\n exportDeclaration.replaceWith(t.cloneNode(declaration.node, true));\n return [path];\n }\n\n if (declaration.isVariableDeclaration()) {\n const declarators = declaration.get('declarations');\n const staleExportPaths = getExportPathsForVariableDeclaration(\n declaration,\n exports\n );\n\n if (declarators.length === 1) {\n exportDeclaration.replaceWith(t.cloneNode(declaration.node, true));\n return staleExportPaths.length > 0 ? staleExportPaths : [path];\n }\n\n const segments: Array<{\n alive: boolean;\n declarators: VariableDeclarator[];\n }> = [];\n\n for (const declarator of declarators) {\n const isAlive = getDeclaratorExportLiveness(\n declarator,\n exports,\n aliveExports\n );\n if (isAlive === null) {\n return null;\n }\n\n const clonedDeclarator = t.cloneNode(declarator.node, true);\n const currentSegment = segments[segments.length - 1];\n if (currentSegment && currentSegment.alive === isAlive) {\n currentSegment.declarators.push(clonedDeclarator);\n } else {\n segments.push({\n alive: isAlive,\n declarators: [clonedDeclarator],\n });\n }\n }\n\n exportDeclaration.replaceWithMultiple(\n segments.map(({ alive, declarators: groupedDeclarators }) => {\n const groupedDeclaration = t.variableDeclaration(\n declaration.node.kind,\n groupedDeclarators\n );\n\n return alive\n ? t.exportNamedDeclaration(groupedDeclaration, [])\n : groupedDeclaration;\n })\n );\n\n return staleExportPaths.length > 0 ? staleExportPaths : [path];\n }\n\n return null;\n}\n\nexport default function shakerPlugin(\n babel: Core,\n {\n keepSideEffects = false,\n ifUnknownExport = 'skip-shaking',\n importOverrides,\n onlyExports,\n root,\n }: IShakerOptions\n): PluginObj<IState & { filename: string }> {\n const shakerLogger = logger.extend('shaker');\n\n return {\n name: '@wyw-in-js/transform/shaker',\n pre(file: BabelFile) {\n this.filename = file.opts.filename!;\n const log = shakerLogger.extend(getFileIdx(this.filename));\n\n log('start', `${this.filename}, onlyExports: ${onlyExports.join(',')}`);\n const onlyExportsSet = new Set(onlyExports);\n\n const shouldKeepOverride = (\n override: ImportOverride | undefined\n ): boolean => !!override && ('mock' in override || 'noShake' in override);\n\n const hasImportOverride = (() => {\n if (!importOverrides || Object.keys(importOverrides).length === 0) {\n return () => false;\n }\n\n const cache = new Map<string, boolean>();\n\n return (source: string): boolean => {\n const cached = cache.get(source);\n if (cached !== undefined) {\n return cached;\n }\n\n const strippedSource = stripQueryAndHash(source);\n\n const direct =\n getImportOverride(importOverrides, source) ??\n (strippedSource !== source\n ? getImportOverride(importOverrides, strippedSource)\n : null);\n if (direct) {\n const result = shouldKeepOverride(direct);\n cache.set(source, result);\n return result;\n }\n\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n if (!isFileImport) {\n cache.set(source, false);\n return false;\n }\n\n try {\n const resolved = syncResolve(strippedSource, this.filename, []);\n const { key } = toImportKey({\n source: strippedSource,\n resolved,\n root,\n });\n const override = getImportOverride(importOverrides, key);\n const result = shouldKeepOverride(override);\n cache.set(source, result);\n return result;\n } catch {\n cache.set(source, false);\n return false;\n }\n };\n })();\n\n const collected = collectExportsAndImports(file.path);\n const { imports } = collected;\n const sideEffectImports = imports.filter(sideEffectImport);\n log(\n 'import-and-exports',\n [\n `imports: ${imports.length} (side-effects: ${sideEffectImports.length})`,\n `exports: ${Object.values(collected.exports).length}`,\n `reexports: ${collected.reexports.length}`,\n ].join(', ')\n );\n\n // We cannot just throw out exports if they are referred in the code\n // Let's dome some replacements\n const exports = rearrangeExports(\n babel,\n file.path,\n collected.exportRefs,\n collected.exports\n );\n\n Object.values(exports).forEach((local) => {\n if (local.isAssignmentExpression()) {\n const left = local.get('left');\n if (left.isIdentifier()) {\n // For some reason babel does not mark id in AssignmentExpression as a reference\n // So we need to do it manually\n reference(left, left, true);\n }\n }\n });\n\n const hasWywPreval = exports.__wywPreval !== undefined;\n const hasDefault = exports.default !== undefined;\n\n // If __wywPreval is not exported, we can remove it from onlyExports\n if (onlyExportsSet.has('__wywPreval') && !hasWywPreval) {\n onlyExportsSet.delete('__wywPreval');\n }\n\n if (onlyExportsSet.size === 0) {\n // Fast-lane: if there are no exports to keep, we can just shake out the whole file\n this.imports = [];\n this.exports = {};\n this.reexports = [];\n this.deadExports = Object.keys(exports);\n\n file.path.get('body').forEach((p) => {\n p.remove();\n });\n\n return;\n }\n\n const importedAsSideEffect = onlyExportsSet.has('side-effect');\n onlyExportsSet.delete('side-effect');\n\n // Hackaround for packages which include a 'default' export without specifying __esModule; such packages cannot be\n // shaken as they will break interopRequireDefault babel helper\n // See example in shaker-plugin.test.ts\n // Real-world example was found in preact/compat npm package\n if (\n onlyExportsSet.has('default') &&\n hasDefault &&\n !collected.isEsModule\n ) {\n this.imports = imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n return;\n }\n\n if (!onlyExportsSet.has('*')) {\n // __esModule should be kept alive\n onlyExportsSet.add('__esModule');\n\n const aliveExports = new Set<NodePath>();\n const importNames = imports.map(({ imported }) => imported);\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (onlyExportsSet.has(exported)) {\n aliveExports.add(local);\n return;\n }\n\n const binding =\n local.isIdentifier() && local.scope.getBinding(local.node.name);\n\n if (\n binding &&\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n importNames.includes((local.node as NodeWithName).name || '')\n ) {\n aliveExports.add(local);\n return;\n }\n\n if ([...aliveExports].some((alive) => alive === local)) {\n // It's possible to export multiple values from a single variable initializer, e.g\n // export const { foo, bar } = baz();\n // We need to treat all of them as used if any of them are used, since otherwise\n // we'll attempt to delete the baz() call\n aliveExports.add(local);\n }\n });\n\n collected.reexports.forEach((exp) => {\n if (onlyExportsSet.has(exp.exported)) {\n aliveExports.add(exp.local);\n }\n });\n\n const exportToPath = new Map<string, NodePath>();\n Object.entries(exports).forEach(([exported, local]) => {\n exportToPath.set(exported, local);\n });\n\n collected.reexports.forEach((exp) => {\n exportToPath.set(exp.exported, exp.local);\n });\n\n const notFoundExports = [...onlyExportsSet].filter(\n (exp) =>\n exp !== '__esModule' && !aliveExports.has(exportToPath.get(exp)!)\n );\n exportToPath.clear();\n\n const isAllExportsFound = notFoundExports.length === 0;\n if (!isAllExportsFound && ifUnknownExport !== 'ignore') {\n if (ifUnknownExport === 'error') {\n throw new Error(\n `Unknown export(s) requested: ${onlyExports.join(',')}`\n );\n }\n\n if (ifUnknownExport === 'reexport-all') {\n // If there are unknown exports, we have keep alive all re-exports.\n if (exports['*'] !== undefined) {\n aliveExports.add(exports['*']);\n }\n\n collected.reexports.forEach((exp) => {\n if (exp.exported === '*') {\n aliveExports.add(exp.local);\n }\n });\n }\n\n if (ifUnknownExport === 'skip-shaking') {\n this.imports = imports;\n this.exports = exports;\n this.reexports = collected.reexports;\n this.deadExports = [];\n\n return;\n }\n }\n\n const forDeleting = [\n ...Object.values(exports),\n ...collected.reexports.map((i) => i.local),\n ].filter((exp) => !aliveExports.has(exp));\n\n const forDeletingSet = new Set<NodePath>(forDeleting);\n const queueForDeleting = (path: NodePath): boolean => {\n if (isRemoved(path) || forDeletingSet.has(path)) {\n return false;\n }\n\n forDeletingSet.add(path);\n forDeleting.push(path);\n return true;\n };\n\n if (!keepSideEffects && !importedAsSideEffect) {\n // Drop side-effect imports for eval-only builds unless they were explicitly requested.\n // This prevents evaluating unrelated runtime code (e.g. Radix) during __wywPreval eval.\n sideEffectImports.forEach((i) => {\n if (hasImportOverride(i.source)) {\n return;\n }\n\n queueForDeleting(i.local);\n });\n }\n\n const deleted = new Set<NodePath>();\n\n let dereferenced: NodePath<Identifier>[] = [];\n let changed = true;\n while (changed) {\n changed = false;\n // eslint-disable-next-line no-restricted-syntax\n for (const path of forDeleting) {\n if (deleted.has(path)) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const binding = getBindingForExport(path);\n const action = findActionForNode(path);\n const parent = action?.[1];\n const outerReferences = (binding?.referencePaths || []).filter(\n (ref) => {\n if (ref === parent || parent?.isAncestor(ref)) {\n return false;\n }\n\n return !forDeleting.some(\n (candidate) =>\n candidate !== path &&\n !isRemoved(candidate) &&\n (candidate === ref || candidate.isAncestor(ref))\n );\n }\n );\n const bindingName = binding?.identifier.name;\n const removableAssignmentStatements = new Set<NodePath>();\n const removableOuterReferences = outerReferences.filter((ref) => {\n if (!bindingName) return false;\n const statement = getPropertyAssignmentStatement(\n ref,\n bindingName\n );\n if (!statement || isWithinAliveExport(statement, aliveExports)) {\n return false;\n }\n\n removableAssignmentStatements.add(statement);\n return true;\n });\n\n const blockingReferences = outerReferences.filter(\n (ref) => !removableOuterReferences.includes(ref)\n );\n\n if (blockingReferences.length > 0 && path.isIdentifier()) {\n // Temporary deref it in order to simplify further checks.\n dereference(path);\n dereferenced.push(path);\n }\n\n const strippedEnum =\n !deleted.has(path) && hasRuntimeReferencesToEnum(path)\n ? stripExportKeepDeclaration(\n path,\n exports,\n aliveExports,\n babel.types\n )\n : null;\n\n if (strippedEnum) {\n strippedEnum.forEach((stalePath) => {\n deleted.add(stalePath);\n });\n changed = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const strippedWithBlocking =\n !deleted.has(path) && binding && blockingReferences.length > 0\n ? stripExportKeepDeclaration(\n path,\n exports,\n aliveExports,\n babel.types\n )\n : null;\n\n if (strippedWithBlocking) {\n strippedWithBlocking.forEach((stalePath) => {\n deleted.add(stalePath);\n });\n changed = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (\n !deleted.has(path) &&\n (!binding || blockingReferences.length === 0)\n ) {\n // For variable declaration exports, `path` is the init expression\n // (not the Identifier). Other forDeleting candidates whose init\n // expressions are ancestors of references to this binding can\n // incorrectly filter them out of outerReferences. Those candidates\n // may later survive via stripExportKeepDeclaration, leaving a\n // dangling reference. Strip the export keyword but keep the\n // declaration so the unreferenced sweep removes it only when dead.\n // This only applies to expression paths (variable init), not\n // Identifiers (function/class declarations) which can't be\n // ancestors of external references.\n const strippedWithoutBlocking =\n binding && !path.isIdentifier()\n ? stripExportKeepDeclaration(\n path,\n exports,\n aliveExports,\n babel.types\n )\n : null;\n\n if (strippedWithoutBlocking) {\n strippedWithoutBlocking.forEach((stalePath) => {\n deleted.add(stalePath);\n });\n if (removableAssignmentStatements.size > 0) {\n for (const statement of removableAssignmentStatements) {\n if (queueForDeleting(statement)) {\n changed = true;\n }\n }\n }\n\n changed = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (removableAssignmentStatements.size > 0) {\n for (const statement of removableAssignmentStatements) {\n if (queueForDeleting(statement)) {\n changed = true;\n }\n }\n }\n\n if (action) {\n applyAction(action);\n } else {\n removeWithRelated([path]);\n }\n\n deleted.add(path);\n changed = true;\n }\n }\n\n dereferenced.forEach((path) => {\n // If path is still alive, we need to reference it back\n if (!isRemoved(path)) {\n reference(path);\n }\n });\n\n dereferenced = [];\n\n // stripExportKeepDeclaration replaces ExportNamedDeclaration with\n // its declaration, creating new AST nodes. The old scope bindings\n // become stale (pointing at disconnected paths). Recrawl so\n // getAllBindings() returns fresh bindings with correct .referenced.\n file.scope.crawl();\n\n // Find and mark for deleting all unreferenced variables\n const unreferenced = Object.values(\n file.scope.getAllBindings()\n ).filter((i) => !i.referenced);\n\n for (const binding of unreferenced) {\n if (binding.path.isVariableDeclarator()) {\n const id = binding.path.get('id');\n // Skip destructured patterns — removing the declarator would kill\n // sibling bindings that may still be referenced (e.g. export {B}\n // from `const [A, B] = createContext(...)` when only A is dead).\n if (\n !id.isArrayPattern() &&\n !id.isObjectPattern() &&\n !isRemoved(id) &&\n !forDeletingSet.has(id)\n ) {\n // Drop dead variable declarations, e.g. `const foo = make();` when `foo` is no longer referenced.\n for (const violation of binding.constantViolations) {\n if (queueForDeleting(violation)) {\n changed = true;\n }\n }\n\n if (queueForDeleting(id)) {\n changed = true;\n }\n }\n }\n\n // Drop import specifiers whose bindings lost all references during shaking\n // (e.g. when we keep only __wywPreval and the rest of the module is removed).\n if (\n (binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()) &&\n !isRemoved(binding.path) &&\n !forDeletingSet.has(binding.path)\n ) {\n if (queueForDeleting(binding.path)) {\n changed = true;\n }\n }\n }\n }\n }\n\n this.imports = withoutRemoved(imports);\n this.exports = {};\n this.deadExports = [];\n\n Object.entries(exports).forEach(([exported, local]) => {\n if (isRemoved(local)) {\n this.deadExports.push(exported);\n } else {\n this.exports[exported] = local;\n }\n });\n\n this.reexports = withoutRemoved(collected.reexports);\n },\n visitor: {},\n post(file: BabelFile) {\n const log = shakerLogger.extend(getFileIdx(file.opts.filename!));\n\n const dynamicImportWarningsEnabled =\n Boolean(process.env.WYW_WARN_DYNAMIC_IMPORTS) &&\n process.env.WYW_WARN_DYNAMIC_IMPORTS !== '0' &&\n process.env.WYW_WARN_DYNAMIC_IMPORTS !== 'false';\n\n const filename = file.opts.filename!;\n\n if (\n dynamicImportWarningsEnabled &&\n !warnedDynamicImportFiles.has(filename)\n ) {\n const dynamicImports = this.imports.filter(\n (imp) => !sideEffectImport(imp) && imp.type === 'dynamic'\n );\n if (dynamicImports.length > 0) {\n const sources = Array.from(\n new Set(dynamicImports.map((imp) => imp.source))\n ).sort();\n const sourcesToWarn = (() => {\n if (!importOverrides || Object.keys(importOverrides).length === 0) {\n return sources;\n }\n\n const shouldWarn = (source: string): boolean => {\n const strippedSource = stripQueryAndHash(source);\n const direct =\n getImportOverride(importOverrides, source) ??\n (strippedSource !== source\n ? getImportOverride(importOverrides, strippedSource)\n : undefined);\n if (direct !== undefined) {\n return false;\n }\n\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n if (!isFileImport) {\n return true;\n }\n\n try {\n const resolved = syncResolve(strippedSource, filename, []);\n const importKey = toImportKey({\n source: strippedSource,\n resolved,\n root,\n }).key;\n return (\n getImportOverride(importOverrides, importKey) === undefined\n );\n } catch {\n return true;\n }\n };\n\n return sources.filter(shouldWarn);\n })();\n\n if (sourcesToWarn.length > 0) {\n warnedDynamicImportFiles.add(filename);\n const overrideKeys = sourcesToWarn\n .map((source) => {\n const strippedSource = stripQueryAndHash(source);\n const isFileImport =\n strippedSource.startsWith('.') ||\n pathLib.isAbsolute(strippedSource);\n\n if (!isFileImport) {\n return { source, key: source };\n }\n\n try {\n const resolved = syncResolve(strippedSource, filename, []);\n return {\n source,\n key: toImportKey({\n source: strippedSource,\n resolved,\n root,\n }).key,\n };\n } catch {\n return { source, key: strippedSource };\n }\n })\n .filter((item, index, array) => {\n const firstIndexForKey = array.findIndex(\n (i) => i.key === item.key\n );\n return firstIndexForKey === index;\n });\n const warning = [\n `[wyw-in-js] Dynamic imports reached prepare stage`,\n ``,\n `file: ${filename}`,\n `count: ${sourcesToWarn.length}`,\n `sources:`,\n ...sourcesToWarn.map((source) => ` - ${source}`),\n ``,\n `note: these imports will be resolved/processed even if they are lazy (e.g. React.lazy(() => import(...)))`,\n ``,\n `tip: if the imported module is runtime-only or heavy, mock it during evaluation via importOverrides:`,\n ` importOverrides: {`,\n ...overrideKeys.map(\n ({ key, source }) =>\n ` '${key}': { mock: './path/to/mock' }, // from ${source}`\n ),\n ` }`,\n ``,\n `note: importOverrides affects only build-time evaluation (it does not change your bundler runtime behavior)`,\n ].join('\\n');\n // eslint-disable-next-line no-console\n console.warn(warning);\n }\n }\n }\n\n const processedImports = new Set<string>();\n const imports = new Map<string, string[]>();\n const addImport = ({\n imported,\n source,\n }: {\n imported: string;\n source: string;\n }) => {\n if (processedImports.has(`${source}:${imported}`)) {\n return;\n }\n\n if (!imports.has(source)) {\n imports.set(source, []);\n }\n\n if (imported) {\n imports.get(source)!.push(imported);\n }\n\n processedImports.add(`${source}:${imported}`);\n };\n\n this.imports.forEach(addImport);\n this.reexports.forEach(addImport);\n\n log('end', `remaining imports: %O`, imports);\n\n // eslint-disable-next-line no-param-reassign\n (file.metadata as IMetadata).wywEvaluator = {\n imports,\n };\n\n invalidateTraversalCache(file.path);\n },\n };\n}\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,MAAM;AAa1B,SAASC,MAAM,EAAEC,WAAW,QAAQ,mBAAmB;AAMvD,SACEC,wBAAwB,EACxBC,gBAAgB,QACX,mCAAmC;AAC1C,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACEC,WAAW,EACXC,WAAW,EACXC,iBAAiB,EACjBC,SAAS,EACTC,iBAAiB,QACZ,uBAAuB;AAC9B,SAASC,wBAAwB,QAAQ,yBAAyB;AAClE,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,0BAA0B;AAEzE,MAAMC,wBAAwB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAclD,SAASC,kBAAkBA,CACzBC,UAAoB,EACpBC,IAAY,EACS;EACrB,MAAMC,OAAO,GAAGF,UAAU,CAACG,KAAK,CAACC,UAAU,CAACH,IAAI,CAAC;EACjD,IAAIC,OAAO,IAAKA,OAAO,CAACG,IAAI,KAAgB,OAAO,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EAAE,EAAE,CAAC;QACzB;QAEA,IAAI4B,QAAQ,EAAE;UACZhB,OAAO,CAACtI,GAAG,CAAC0H,MAAM,CAAC,CAAEvF,IAAI,CAACmH,QAAQ,CAAC;QACrC;QAEA+D,gBAAgB,CAACjE,GAAG,CAAC,GAAG1B,MAAM,IAAI4B,QAAQ,EAAE,CAAC;MAC/C,CAAC;MAED,IAAI,CAAChB,OAAO,CAACnH,OAAO,CAACmM,SAAS,CAAC;MAC/B,IAAI,CAAC7E,SAAS,CAACtH,OAAO,CAACmM,SAAS,CAAC;MAEjCpG,GAAG,CAAC,KAAK,EAAE,uBAAuB,EAAEoB,OAAO,CAAC;;MAE5C;MACCvB,IAAI,CAACwG,QAAQ,CAAeC,YAAY,GAAG;QAC1ClF;MACF,CAAC;MAED5J,wBAAwB,CAACqI,IAAI,CAACrC,IAAI,CAAC;IACrC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-continue, @typescript-eslint/no-use-before-define */
|
|
2
|
-
import traverse from '@babel/traverse';
|
|
3
|
-
import { getBindingIdentifiers } from '@babel/types';
|
|
4
|
-
const isTypeOnlyImport = statement => {
|
|
5
|
-
if (statement.importKind === 'type') {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
if (statement.specifiers.length === 0) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return statement.specifiers.every(specifier => specifier.type === 'ImportSpecifier' && specifier.importKind === 'type');
|
|
12
|
-
};
|
|
13
|
-
const isTypeOnlyExport = statement => statement.exportKind === 'type';
|
|
14
|
-
const getModuleExportName = node => node.type === 'Identifier' ? node.name : node.value;
|
|
15
|
-
const isTypeOnlyStatement = statement => {
|
|
16
|
-
switch (statement.type) {
|
|
17
|
-
case 'EmptyStatement':
|
|
18
|
-
case 'TSDeclareFunction':
|
|
19
|
-
case 'TSInterfaceDeclaration':
|
|
20
|
-
case 'TSTypeAliasDeclaration':
|
|
21
|
-
return true;
|
|
22
|
-
default:
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
function collectExportNamedDeclaration(statement, reexports, explicitExports) {
|
|
27
|
-
if (!statement.source) {
|
|
28
|
-
return isTypeOnlyExport(statement);
|
|
29
|
-
}
|
|
30
|
-
if (isTypeOnlyExport(statement)) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
const source = statement.source.value;
|
|
34
|
-
for (const specifier of statement.specifiers) {
|
|
35
|
-
if (specifier.type === 'ExportSpecifier') {
|
|
36
|
-
if (specifier.exportKind === 'type') {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
explicitExports.add(getModuleExportName(specifier.exported));
|
|
40
|
-
reexports.push(getNamedReexport(specifier, source));
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (specifier.type === 'ExportDefaultSpecifier') {
|
|
44
|
-
explicitExports.add(getModuleExportName(specifier.exported));
|
|
45
|
-
reexports.push(getDefaultReexport(specifier, source));
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (specifier.type === 'ExportNamespaceSpecifier') {
|
|
49
|
-
explicitExports.add(getModuleExportName(specifier.exported));
|
|
50
|
-
reexports.push(getNamespaceReexport(specifier, source));
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return statement.specifiers.length > 0;
|
|
56
|
-
}
|
|
57
|
-
function getNamedReexport(specifier, source) {
|
|
58
|
-
return {
|
|
59
|
-
exported: getModuleExportName(specifier.exported),
|
|
60
|
-
imported: getModuleExportName(specifier.local),
|
|
61
|
-
kind: 'named',
|
|
62
|
-
source
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function getDefaultReexport(specifier, source) {
|
|
66
|
-
return {
|
|
67
|
-
exported: getModuleExportName(specifier.exported),
|
|
68
|
-
imported: 'default',
|
|
69
|
-
kind: 'named',
|
|
70
|
-
source
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function getNamespaceReexport(specifier, source) {
|
|
74
|
-
return {
|
|
75
|
-
exported: getModuleExportName(specifier.exported),
|
|
76
|
-
kind: 'namespace',
|
|
77
|
-
source
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const collectImportBinding = (statement, imports) => {
|
|
81
|
-
if (statement.importKind === 'type') {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
if (statement.specifiers.length === 0) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
let sawValueImport = false;
|
|
88
|
-
for (const specifier of statement.specifiers) {
|
|
89
|
-
if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
sawValueImport = true;
|
|
93
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
94
|
-
imports.set(specifier.local.name, {
|
|
95
|
-
imported: getImportSpecifierName(specifier),
|
|
96
|
-
kind: 'named',
|
|
97
|
-
source: statement.source.value
|
|
98
|
-
});
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
102
|
-
imports.set(specifier.local.name, {
|
|
103
|
-
imported: 'default',
|
|
104
|
-
kind: 'named',
|
|
105
|
-
source: statement.source.value
|
|
106
|
-
});
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
imports.set(specifier.local.name, {
|
|
110
|
-
kind: 'namespace',
|
|
111
|
-
source: statement.source.value
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return sawValueImport || isTypeOnlyImport(statement);
|
|
115
|
-
};
|
|
116
|
-
const getImportSpecifierName = specifier => getModuleExportName(specifier.imported);
|
|
117
|
-
const getLocalDeclarationNames = declaration => {
|
|
118
|
-
if (declaration.type === 'VariableDeclaration' || declaration.type === 'FunctionDeclaration' || declaration.type === 'ClassDeclaration') {
|
|
119
|
-
return Object.keys(getBindingIdentifiers(declaration));
|
|
120
|
-
}
|
|
121
|
-
if (declaration.type === 'TSEnumDeclaration' || declaration.type === 'TSModuleDeclaration') {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return [];
|
|
125
|
-
};
|
|
126
|
-
const collectLocalExportNamedDeclaration = (statement, importedBindings, passthroughCandidates, explicitExports) => {
|
|
127
|
-
let complete = true;
|
|
128
|
-
if (isTypeOnlyExport(statement)) {
|
|
129
|
-
return {
|
|
130
|
-
complete: true,
|
|
131
|
-
ok: true
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
if (statement.declaration) {
|
|
135
|
-
const names = getLocalDeclarationNames(statement.declaration);
|
|
136
|
-
if (names === null) {
|
|
137
|
-
return {
|
|
138
|
-
complete: false,
|
|
139
|
-
ok: false
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
for (const name of names) {
|
|
143
|
-
explicitExports.add(name);
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
complete: names.length === 0,
|
|
147
|
-
ok: true
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
for (const specifier of statement.specifiers) {
|
|
151
|
-
if (specifier.type !== 'ExportSpecifier') {
|
|
152
|
-
return {
|
|
153
|
-
complete: false,
|
|
154
|
-
ok: false
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (specifier.exportKind === 'type') {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const exported = getModuleExportName(specifier.exported);
|
|
161
|
-
explicitExports.add(exported);
|
|
162
|
-
if (specifier.local.type !== 'Identifier') {
|
|
163
|
-
complete = false;
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
if (!importedBindings.has(specifier.local.name)) {
|
|
167
|
-
complete = false;
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (!passthroughCandidates.has(specifier.local.name)) {
|
|
171
|
-
passthroughCandidates.set(specifier.local.name, []);
|
|
172
|
-
}
|
|
173
|
-
passthroughCandidates.get(specifier.local.name).push(exported);
|
|
174
|
-
}
|
|
175
|
-
return {
|
|
176
|
-
complete: complete && statement.specifiers.length > 0,
|
|
177
|
-
ok: true
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
const collectPassthroughReexports = (ast, importedBindings, passthroughCandidates, reexports) => {
|
|
181
|
-
let complete = true;
|
|
182
|
-
const bindingReferenceCounts = new Map();
|
|
183
|
-
traverse(ast, {
|
|
184
|
-
Program(path) {
|
|
185
|
-
for (const localName of passthroughCandidates.keys()) {
|
|
186
|
-
bindingReferenceCounts.set(localName, path.scope.getBinding(localName)?.referencePaths.length ?? -1);
|
|
187
|
-
}
|
|
188
|
-
path.stop();
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
for (const [localName, exportedNames] of passthroughCandidates) {
|
|
192
|
-
if (bindingReferenceCounts.get(localName) !== exportedNames.length) {
|
|
193
|
-
complete = false;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
const imported = importedBindings.get(localName);
|
|
197
|
-
for (const exported of exportedNames) {
|
|
198
|
-
if (imported.kind === 'namespace') {
|
|
199
|
-
reexports.push({
|
|
200
|
-
exported,
|
|
201
|
-
kind: 'namespace',
|
|
202
|
-
source: imported.source
|
|
203
|
-
});
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
reexports.push({
|
|
207
|
-
exported,
|
|
208
|
-
imported: imported.imported,
|
|
209
|
-
kind: 'named',
|
|
210
|
-
source: imported.source
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
complete,
|
|
216
|
-
ok: true
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
function analyzeBarrelProgram(ast) {
|
|
220
|
-
const reexports = [];
|
|
221
|
-
const explicitExports = new Set();
|
|
222
|
-
const exportAll = [];
|
|
223
|
-
const importedBindings = new Map();
|
|
224
|
-
const passthroughCandidates = new Map();
|
|
225
|
-
let complete = true;
|
|
226
|
-
for (const statement of ast.program.body) {
|
|
227
|
-
if (statement.type === 'ImportDeclaration') {
|
|
228
|
-
if (!collectImportBinding(statement, importedBindings)) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (statement.type === 'ExportNamedDeclaration') {
|
|
234
|
-
if (statement.source) {
|
|
235
|
-
if (!collectExportNamedDeclaration(statement, reexports, explicitExports)) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
const localResult = collectLocalExportNamedDeclaration(statement, importedBindings, passthroughCandidates, explicitExports);
|
|
241
|
-
if (!localResult.ok) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
complete = complete && localResult.complete;
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (statement.type === 'ExportAllDeclaration') {
|
|
248
|
-
if (statement.exportKind === 'type') {
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if (!statement.source) {
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
exportAll.push(getExportAllSource(statement));
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
if (statement.type === 'ExportDefaultDeclaration') {
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
if (!isTypeOnlyStatement(statement)) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const passthroughResult = collectPassthroughReexports(ast, importedBindings, passthroughCandidates, reexports);
|
|
265
|
-
if (!passthroughResult.ok) {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
complete = complete && passthroughResult.complete;
|
|
269
|
-
if (reexports.length === 0 && exportAll.length === 0) {
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
return {
|
|
273
|
-
complete,
|
|
274
|
-
explicitExports: [...explicitExports],
|
|
275
|
-
exportAll,
|
|
276
|
-
kind: 'barrel',
|
|
277
|
-
reexports
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
const getExportAllSource = statement => statement.source.value;
|
|
281
|
-
export function analyzeBarrelFile(ast) {
|
|
282
|
-
const result = analyzeBarrelProgram(ast);
|
|
283
|
-
if (!result) {
|
|
284
|
-
return {
|
|
285
|
-
kind: 'ineligible',
|
|
286
|
-
reason: 'impure'
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
//# sourceMappingURL=barrelManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"barrelManifest.js","names":["traverse","getBindingIdentifiers","isTypeOnlyImport","statement","importKind","specifiers","length","every","specifier","type","isTypeOnlyExport","exportKind","getModuleExportName","node","name","value","isTypeOnlyStatement","collectExportNamedDeclaration","reexports","explicitExports","source","add","exported","push","getNamedReexport","getDefaultReexport","getNamespaceReexport","imported","local","kind","collectImportBinding","imports","sawValueImport","set","getImportSpecifierName","getLocalDeclarationNames","declaration","Object","keys","collectLocalExportNamedDeclaration","importedBindings","passthroughCandidates","complete","ok","names","has","get","collectPassthroughReexports","ast","bindingReferenceCounts","Map","Program","path","localName","scope","getBinding","referencePaths","stop","exportedNames","analyzeBarrelProgram","Set","exportAll","program","body","localResult","getExportAllSource","passthroughResult","analyzeBarrelFile","result","reason"],"sources":["../../src/transform/barrelManifest.ts"],"sourcesContent":["/* eslint-disable no-continue, @typescript-eslint/no-use-before-define */\nimport traverse from '@babel/traverse';\nimport { getBindingIdentifiers } from '@babel/types';\nimport type {\n ClassDeclaration,\n Declaration,\n ExportAllDeclaration,\n ExportDefaultSpecifier,\n ExportNamedDeclaration,\n ExportNamespaceSpecifier,\n ExportSpecifier,\n File,\n FunctionDeclaration,\n Identifier,\n ImportDeclaration,\n ImportSpecifier,\n Program,\n StringLiteral,\n VariableDeclaration,\n} from '@babel/types';\n\nexport type BarrelSkipReason =\n | 'custom-evaluator'\n | 'empty'\n | 'ignored'\n | 'impure'\n | 'namespace-barrel'\n | 'unknown-star';\n\nexport type BarrelBlockedReason =\n | 'ambiguous'\n | 'cycle'\n | 'namespace-barrel'\n | 'unknown-star'\n | 'unresolved';\n\nexport type BarrelResolvedBinding =\n | {\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n kind: 'namespace';\n source: string;\n };\n\nexport type BarrelManifestExport =\n | BarrelResolvedBinding\n | {\n kind: 'blocked';\n reason: BarrelBlockedReason;\n };\n\nexport type BarrelManifest = {\n complete: boolean;\n exports: Record<string, BarrelManifestExport>;\n kind: 'barrel';\n};\n\nexport type BarrelManifestCacheEntry =\n | BarrelManifest\n | {\n kind: 'ineligible';\n reason: BarrelSkipReason;\n };\n\nexport type RawBarrelReexport =\n | {\n exported: string;\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n exported: string;\n kind: 'namespace';\n source: string;\n };\n\nexport type RawBarrelManifest = {\n complete: boolean;\n explicitExports: string[];\n exportAll: string[];\n kind: 'barrel';\n reexports: RawBarrelReexport[];\n};\n\ntype LocalImportBinding =\n | {\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n kind: 'namespace';\n source: string;\n };\n\nconst isTypeOnlyImport = (statement: ImportDeclaration): boolean => {\n if (statement.importKind === 'type') {\n return true;\n }\n\n if (statement.specifiers.length === 0) {\n return false;\n }\n\n return statement.specifiers.every(\n (specifier) =>\n specifier.type === 'ImportSpecifier' && specifier.importKind === 'type'\n );\n};\n\nconst isTypeOnlyExport = (statement: ExportNamedDeclaration): boolean =>\n statement.exportKind === 'type';\n\nconst getModuleExportName = (node: Identifier | StringLiteral): string =>\n node.type === 'Identifier' ? node.name : node.value;\n\nconst isTypeOnlyStatement = (statement: Program['body'][number]): boolean => {\n switch (statement.type) {\n case 'EmptyStatement':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n return true;\n default:\n return false;\n }\n};\n\nfunction collectExportNamedDeclaration(\n statement: ExportNamedDeclaration,\n reexports: RawBarrelReexport[],\n explicitExports: Set<string>\n): boolean {\n if (!statement.source) {\n return isTypeOnlyExport(statement);\n }\n\n if (isTypeOnlyExport(statement)) {\n return true;\n }\n\n const source = statement.source.value;\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ExportSpecifier') {\n if (specifier.exportKind === 'type') {\n continue;\n }\n\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getNamedReexport(specifier, source));\n continue;\n }\n\n if (specifier.type === 'ExportDefaultSpecifier') {\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getDefaultReexport(specifier, source));\n continue;\n }\n\n if (specifier.type === 'ExportNamespaceSpecifier') {\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getNamespaceReexport(specifier, source));\n continue;\n }\n\n return false;\n }\n\n return statement.specifiers.length > 0;\n}\n\nfunction getNamedReexport(\n specifier: ExportSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n imported: getModuleExportName(specifier.local),\n kind: 'named',\n source,\n };\n}\n\nfunction getDefaultReexport(\n specifier: ExportDefaultSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n imported: 'default',\n kind: 'named',\n source,\n };\n}\n\nfunction getNamespaceReexport(\n specifier: ExportNamespaceSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n kind: 'namespace',\n source,\n };\n}\n\nconst collectImportBinding = (\n statement: ImportDeclaration,\n imports: Map<string, LocalImportBinding>\n): boolean => {\n if (statement.importKind === 'type') {\n return true;\n }\n\n if (statement.specifiers.length === 0) {\n return false;\n }\n\n let sawValueImport = false;\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.importKind === 'type'\n ) {\n continue;\n }\n\n sawValueImport = true;\n\n if (specifier.type === 'ImportSpecifier') {\n imports.set(specifier.local.name, {\n imported: getImportSpecifierName(specifier),\n kind: 'named',\n source: statement.source.value,\n });\n continue;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n imports.set(specifier.local.name, {\n imported: 'default',\n kind: 'named',\n source: statement.source.value,\n });\n continue;\n }\n\n imports.set(specifier.local.name, {\n kind: 'namespace',\n source: statement.source.value,\n });\n }\n\n return sawValueImport || isTypeOnlyImport(statement);\n};\n\nconst getImportSpecifierName = (specifier: ImportSpecifier): string =>\n getModuleExportName(specifier.imported);\n\nconst getLocalDeclarationNames = (\n declaration: Declaration\n): string[] | null => {\n if (\n declaration.type === 'VariableDeclaration' ||\n declaration.type === 'FunctionDeclaration' ||\n declaration.type === 'ClassDeclaration'\n ) {\n return Object.keys(\n getBindingIdentifiers(\n declaration as\n | VariableDeclaration\n | FunctionDeclaration\n | ClassDeclaration\n )\n );\n }\n\n if (\n declaration.type === 'TSEnumDeclaration' ||\n declaration.type === 'TSModuleDeclaration'\n ) {\n return null;\n }\n\n return [];\n};\n\nconst collectLocalExportNamedDeclaration = (\n statement: ExportNamedDeclaration,\n importedBindings: Map<string, LocalImportBinding>,\n passthroughCandidates: Map<string, string[]>,\n explicitExports: Set<string>\n): { complete: boolean; ok: boolean } => {\n let complete = true;\n\n if (isTypeOnlyExport(statement)) {\n return {\n complete: true,\n ok: true,\n };\n }\n\n if (statement.declaration) {\n const names = getLocalDeclarationNames(statement.declaration);\n if (names === null) {\n return {\n complete: false,\n ok: false,\n };\n }\n\n for (const name of names) {\n explicitExports.add(name);\n }\n\n return {\n complete: names.length === 0,\n ok: true,\n };\n }\n\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ExportSpecifier') {\n return {\n complete: false,\n ok: false,\n };\n }\n\n if (specifier.exportKind === 'type') {\n continue;\n }\n\n const exported = getModuleExportName(specifier.exported);\n explicitExports.add(exported);\n\n if (specifier.local.type !== 'Identifier') {\n complete = false;\n continue;\n }\n\n if (!importedBindings.has(specifier.local.name)) {\n complete = false;\n continue;\n }\n\n if (!passthroughCandidates.has(specifier.local.name)) {\n passthroughCandidates.set(specifier.local.name, []);\n }\n passthroughCandidates.get(specifier.local.name)!.push(exported);\n }\n\n return {\n complete: complete && statement.specifiers.length > 0,\n ok: true,\n };\n};\n\nconst collectPassthroughReexports = (\n ast: File,\n importedBindings: Map<string, LocalImportBinding>,\n passthroughCandidates: Map<string, string[]>,\n reexports: RawBarrelReexport[]\n): { complete: boolean; ok: boolean } => {\n let complete = true;\n const bindingReferenceCounts = new Map<string, number>();\n\n traverse(ast, {\n Program(path) {\n for (const localName of passthroughCandidates.keys()) {\n bindingReferenceCounts.set(\n localName,\n path.scope.getBinding(localName)?.referencePaths.length ?? -1\n );\n }\n path.stop();\n },\n });\n\n for (const [localName, exportedNames] of passthroughCandidates) {\n if (bindingReferenceCounts.get(localName) !== exportedNames.length) {\n complete = false;\n continue;\n }\n\n const imported = importedBindings.get(localName)!;\n for (const exported of exportedNames) {\n if (imported.kind === 'namespace') {\n reexports.push({\n exported,\n kind: 'namespace',\n source: imported.source,\n });\n continue;\n }\n\n reexports.push({\n exported,\n imported: imported.imported,\n kind: 'named',\n source: imported.source,\n });\n }\n }\n\n return {\n complete,\n ok: true,\n };\n};\n\nfunction analyzeBarrelProgram(ast: File): RawBarrelManifest | null {\n const reexports: RawBarrelReexport[] = [];\n const explicitExports = new Set<string>();\n const exportAll: string[] = [];\n const importedBindings = new Map<string, LocalImportBinding>();\n const passthroughCandidates = new Map<string, string[]>();\n let complete = true;\n\n for (const statement of ast.program.body) {\n if (statement.type === 'ImportDeclaration') {\n if (!collectImportBinding(statement, importedBindings)) {\n return null;\n }\n continue;\n }\n\n if (statement.type === 'ExportNamedDeclaration') {\n if (statement.source) {\n if (\n !collectExportNamedDeclaration(statement, reexports, explicitExports)\n ) {\n return null;\n }\n continue;\n }\n\n const localResult = collectLocalExportNamedDeclaration(\n statement,\n importedBindings,\n passthroughCandidates,\n explicitExports\n );\n if (!localResult.ok) {\n return null;\n }\n complete = complete && localResult.complete;\n continue;\n }\n\n if (statement.type === 'ExportAllDeclaration') {\n if (statement.exportKind === 'type') {\n continue;\n }\n\n if (!statement.source) {\n return null;\n }\n\n exportAll.push(getExportAllSource(statement));\n continue;\n }\n\n if (statement.type === 'ExportDefaultDeclaration') {\n return null;\n }\n\n if (!isTypeOnlyStatement(statement)) {\n return null;\n }\n }\n\n const passthroughResult = collectPassthroughReexports(\n ast,\n importedBindings,\n passthroughCandidates,\n reexports\n );\n if (!passthroughResult.ok) {\n return null;\n }\n complete = complete && passthroughResult.complete;\n\n if (reexports.length === 0 && exportAll.length === 0) {\n return null;\n }\n\n return {\n complete,\n explicitExports: [...explicitExports],\n exportAll,\n kind: 'barrel',\n reexports,\n };\n}\n\nconst getExportAllSource = (statement: ExportAllDeclaration): string =>\n statement.source.value;\n\nexport function analyzeBarrelFile(\n ast: File\n): BarrelManifestCacheEntry | RawBarrelManifest {\n const result = analyzeBarrelProgram(ast);\n\n if (!result) {\n return {\n kind: 'ineligible',\n reason: 'impure',\n };\n }\n\n return result;\n}\n"],"mappings":"AAAA;AACA,OAAOA,QAAQ,MAAM,iBAAiB;AACtC,SAASC,qBAAqB,QAAQ,cAAc;AAiGpD,MAAMC,gBAAgB,GAAIC,SAA4B,IAAc;EAClE,IAAIA,SAAS,CAACC,UAAU,KAAK,MAAM,EAAE;IACnC,OAAO,IAAI;EACb;EAEA,IAAID,SAAS,CAACE,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;IACrC,OAAO,KAAK;EACd;EAEA,OAAOH,SAAS,CAACE,UAAU,CAACE,KAAK,CAC9BC,SAAS,IACRA,SAAS,CAACC,IAAI,KAAK,iBAAiB,IAAID,SAAS,CAACJ,UAAU,KAAK,MACrE,CAAC;AACH,CAAC;AAED,MAAMM,gBAAgB,GAAIP,SAAiC,IACzDA,SAAS,CAACQ,UAAU,KAAK,MAAM;AAEjC,MAAMC,mBAAmB,GAAIC,IAAgC,IAC3DA,IAAI,CAACJ,IAAI,KAAK,YAAY,GAAGI,IAAI,CAACC,IA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KAAK;AAExB,OAAO,SAASoD,iBAAiBA,CAC/BnB,GAAS,EACqC;EAC9C,MAAMoB,MAAM,GAAGT,oBAAoB,CAACX,GAAG,CAAC;EAExC,IAAI,CAACoB,MAAM,EAAE;IACX,OAAO;MACLvC,IAAI,EAAE,YAAY;MAClBwC,MAAM,EAAE;IACV,CAAC;EACH;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import generate from '@babel/generator';
|
|
2
|
-
import { findExportsInImports } from './getExports';
|
|
3
|
-
const getWildcardReexport = (babel, ast) => {
|
|
4
|
-
const reexportsFrom = [];
|
|
5
|
-
ast.program.body.forEach(node => {
|
|
6
|
-
if (babel.types.isExportAllDeclaration(node) && node.source && babel.types.isStringLiteral(node.source)) {
|
|
7
|
-
reexportsFrom.push({
|
|
8
|
-
source: node.source.value,
|
|
9
|
-
node
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return reexportsFrom;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Replaces wildcard reexports with named reexports.
|
|
18
|
-
* Recursively emits getExports for each reexported module,
|
|
19
|
-
* and replaces wildcard with resolved named.
|
|
20
|
-
*/
|
|
21
|
-
export function* explodeReexports() {
|
|
22
|
-
const {
|
|
23
|
-
babel
|
|
24
|
-
} = this.services;
|
|
25
|
-
const {
|
|
26
|
-
log,
|
|
27
|
-
loadedAndParsed
|
|
28
|
-
} = this.entrypoint;
|
|
29
|
-
if (loadedAndParsed.evaluator === 'ignored') {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);
|
|
33
|
-
if (!reexportsFrom.length) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
log('has wildcard reexport from %o', reexportsFrom);
|
|
37
|
-
const resolvedImports = yield* this.getNext('resolveImports', this.entrypoint, {
|
|
38
|
-
imports: new Map(reexportsFrom.map(i => [i.source, []]))
|
|
39
|
-
});
|
|
40
|
-
const importedEntrypoints = findExportsInImports(this.entrypoint, resolvedImports);
|
|
41
|
-
const replacements = new Map();
|
|
42
|
-
for (const importedEntrypoint of importedEntrypoints) {
|
|
43
|
-
if (importedEntrypoint.entrypoint.loadedAndParsed.evaluator !== 'ignored') {
|
|
44
|
-
const reexport = reexportsFrom.find(i => i.source === importedEntrypoint.import);
|
|
45
|
-
if (reexport) {
|
|
46
|
-
const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
|
|
47
|
-
const namedExports = exports.filter(name => name !== 'default');
|
|
48
|
-
if (namedExports.length !== 0) {
|
|
49
|
-
replacements.set(reexport.node, babel.types.exportNamedDeclaration(null, namedExports.map(i => babel.types.exportSpecifier(babel.types.identifier(i), babel.types.identifier(i))), babel.types.stringLiteral(importedEntrypoint.import)));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Replace wildcard reexport with named reexports
|
|
56
|
-
babel.traverse(loadedAndParsed.ast, {
|
|
57
|
-
ExportAllDeclaration(path) {
|
|
58
|
-
if (!replacements.has(path.node)) return;
|
|
59
|
-
path.replaceWith(replacements.get(path.node));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
loadedAndParsed.code = generate(loadedAndParsed.ast).code;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=explodeReexports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"explodeReexports.js","names":["generate","findExportsInImports","getWildcardReexport","babel","ast","reexportsFrom","program","body","forEach","node","types","isExportAllDeclaration","source","isStringLiteral","push","value","explodeReexports","services","log","loadedAndParsed","entrypoint","evaluator","length","resolvedImports","getNext","imports","Map","map","i","importedEntrypoints","replacements","importedEntrypoint","reexport","find","import","exports","undefined","namedExports","filter","name","set","exportNamedDeclaration","exportSpecifier","identifier","stringLiteral","traverse","ExportAllDeclaration","path","has","replaceWith","get","code"],"sources":["../../../src/transform/generators/explodeReexports.ts"],"sourcesContent":["import generate from '@babel/generator';\nimport type { ExportAllDeclaration, File, Node } from '@babel/types';\n\nimport type { Core } from '../../babel';\nimport type { IExplodeReexportsAction, SyncScenarioForAction } from '../types';\n\nimport { findExportsInImports } from './getExports';\n\nconst getWildcardReexport = (babel: Core, ast: File) => {\n const reexportsFrom: { node: ExportAllDeclaration; source: string }[] = [];\n ast.program.body.forEach((node) => {\n if (\n babel.types.isExportAllDeclaration(node) &&\n node.source &&\n babel.types.isStringLiteral(node.source)\n ) {\n reexportsFrom.push({\n source: node.source.value,\n node,\n });\n }\n });\n\n return reexportsFrom;\n};\n\n/**\n * Replaces wildcard reexports with named reexports.\n * Recursively emits getExports for each reexported module,\n * and replaces wildcard with resolved named.\n */\nexport function* explodeReexports(\n this: IExplodeReexportsAction\n): SyncScenarioForAction<IExplodeReexportsAction> {\n const { babel } = this.services;\n const { log, loadedAndParsed } = this.entrypoint;\n if (loadedAndParsed.evaluator === 'ignored') {\n return;\n }\n\n const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);\n if (!reexportsFrom.length) {\n return;\n }\n\n log('has wildcard reexport from %o', reexportsFrom);\n\n const resolvedImports = yield* this.getNext(\n 'resolveImports',\n this.entrypoint,\n {\n imports: new Map(reexportsFrom.map((i) => [i.source, []])),\n }\n );\n\n const importedEntrypoints = findExportsInImports(\n this.entrypoint,\n resolvedImports\n );\n\n const replacements = new Map<ExportAllDeclaration, Node>();\n for (const importedEntrypoint of importedEntrypoints) {\n if (importedEntrypoint.entrypoint.loadedAndParsed.evaluator !== 'ignored') {\n const reexport = reexportsFrom.find(\n (i) => i.source === importedEntrypoint.import\n );\n if (reexport) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n const namedExports = exports.filter((name) => name !== 'default');\n if (namedExports.length !== 0) {\n replacements.set(\n reexport.node,\n babel.types.exportNamedDeclaration(\n null,\n namedExports.map((i) =>\n babel.types.exportSpecifier(\n babel.types.identifier(i),\n babel.types.identifier(i)\n )\n ),\n babel.types.stringLiteral(importedEntrypoint.import)\n )\n );\n }\n }\n }\n }\n\n // Replace wildcard reexport with named reexports\n babel.traverse(loadedAndParsed.ast, {\n ExportAllDeclaration(path) {\n if (!replacements.has(path.node)) return;\n path.replaceWith(replacements.get(path.node)!);\n },\n });\n\n loadedAndParsed.code = generate(loadedAndParsed.ast).code;\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAMvC,SAASC,oBAAoB,QAAQ,cAAc;AAEnD,MAAMC,mBAAmB,GAAGA,CAACC,KAAW,EAAEC,GAAS,KAAK;EACtD,MAAMC,aAA+D,GAAG,EAAE;EAC1ED,GAAG,CAACE,OAAO,CAACC,IAAI,CAACC,OAAO,CAAEC,IAAI,IAAK;IACjC,IACEN,KAAK,CAACO,KAAK,CAACC,sBAAsB,CAACF,IAAI,CAAC,IACxCA,IAAI,CAACG,MAAM,IACXT,KAAK,CAACO,KAAK,CAACG,eAAe,CAACJ,IAAI,CAACG,MAAM,CAAC,EACxC;MACAP,aAAa,CAACS,IAAI,CAAC;QACjBF,MAAM,EAAEH,IAAI,CAACG,MAAM,CAACG,KAAK;QACzBN;MACF,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;EAEF,OAAOJ,aAAa;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,UAAUW,gBAAgBA,CAAA,EAEiB;EAChD,MAAM;IAAEb;EAAM,CAAC,GAAG,IAAI,CAACc,QAAQ;EAC/B,MAAM;IAAEC,GAAG;IAAEC;EAAgB,CAAC,GAAG,IAAI,CAACC,UAAU;EAChD,IAAID,eAAe,CAACE,SAAS,KAAK,SAAS,EAAE;IAC3C;EACF;EAEA,MAAMhB,aAAa,GAAGH,mBAAmB,CAACC,KAAK,EAAEgB,eAAe,CAACf,GAAG,CAAC;EACrE,IAAI,CAACC,aAAa,CAACi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