@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,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadWywOptions = loadWywOptions;
|
|
7
|
-
var _cosmiconfig = require("cosmiconfig");
|
|
8
|
-
var _shaker = require("../../shaker");
|
|
9
|
-
const searchPlaces = [`.wyw-in-jsrc`, `.wyw-in-jsrc.json`, `.wyw-in-jsrc.yaml`, `.wyw-in-jsrc.yml`, `.wyw-in-jsrc.js`, `.wyw-in-jsrc.cjs`, `.config/wyw-in-jsrc`, `.config/wyw-in-jsrc.json`, `.config/wyw-in-jsrc.yaml`, `.config/wyw-in-jsrc.yml`, `.config/wyw-in-jsrc.js`, `.config/wyw-in-jsrc.cjs`, `wyw-in-js.config.js`, `wyw-in-js.config.cjs`];
|
|
10
|
-
const explorerSync = (0, _cosmiconfig.cosmiconfigSync)('wyw-in-js', {
|
|
11
|
-
searchPlaces
|
|
12
|
-
});
|
|
13
|
-
const cache = new WeakMap();
|
|
14
|
-
const defaultOverrides = {};
|
|
15
|
-
const nodeModulesRegExp = /[\\/]node_modules[\\/]/;
|
|
16
|
-
const defaultImportLoaders = {
|
|
17
|
-
raw: 'raw',
|
|
18
|
-
url: 'url'
|
|
19
|
-
};
|
|
20
|
-
function loadWywOptions(overrides = defaultOverrides) {
|
|
21
|
-
var _result$config;
|
|
22
|
-
if (cache.has(overrides)) {
|
|
23
|
-
return cache.get(overrides);
|
|
24
|
-
}
|
|
25
|
-
const {
|
|
26
|
-
configFile,
|
|
27
|
-
ignore,
|
|
28
|
-
rules,
|
|
29
|
-
babelOptions = {},
|
|
30
|
-
importLoaders: overridesImportLoaders,
|
|
31
|
-
...rest
|
|
32
|
-
} = overrides;
|
|
33
|
-
const result =
|
|
34
|
-
// eslint-disable-next-line no-nested-ternary
|
|
35
|
-
configFile === false ? undefined : configFile !== undefined ? explorerSync.load(configFile) : explorerSync.search();
|
|
36
|
-
const defaultFeatures = {
|
|
37
|
-
dangerousCodeRemover: true,
|
|
38
|
-
globalCache: true,
|
|
39
|
-
happyDOM: true,
|
|
40
|
-
softErrors: false,
|
|
41
|
-
useBabelConfigs: true,
|
|
42
|
-
useWeakRefInEval: true
|
|
43
|
-
};
|
|
44
|
-
const config = (_result$config = result === null || result === void 0 ? void 0 : result.config) !== null && _result$config !== void 0 ? _result$config : {};
|
|
45
|
-
const configImportLoaders = config.importLoaders;
|
|
46
|
-
const configFeatures = config.features;
|
|
47
|
-
const options = {
|
|
48
|
-
displayName: false,
|
|
49
|
-
evaluate: true,
|
|
50
|
-
extensions: ['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx'],
|
|
51
|
-
outputMetadata: false,
|
|
52
|
-
rules: rules !== null && rules !== void 0 ? rules : [{
|
|
53
|
-
action: _shaker.shaker
|
|
54
|
-
}, {
|
|
55
|
-
// The old `ignore` option is used as a default value for `ignore` rule.
|
|
56
|
-
test: ignore !== null && ignore !== void 0 ? ignore : nodeModulesRegExp,
|
|
57
|
-
action: 'ignore'
|
|
58
|
-
}, {
|
|
59
|
-
// Do not ignore ES-modules
|
|
60
|
-
test: (filename, code) => {
|
|
61
|
-
if (!nodeModulesRegExp.test(filename)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// If a file contains `export` or `import` keywords, we assume it's an ES-module
|
|
66
|
-
return /(?:^|\*\/|;|})\s*(?:export|import)[\s{]/m.test(code);
|
|
67
|
-
},
|
|
68
|
-
action: _shaker.shaker
|
|
69
|
-
}],
|
|
70
|
-
babelOptions,
|
|
71
|
-
highPriorityPlugins: ['module-resolver'],
|
|
72
|
-
...config,
|
|
73
|
-
...rest,
|
|
74
|
-
importLoaders: {
|
|
75
|
-
...defaultImportLoaders,
|
|
76
|
-
...(configImportLoaders !== null && configImportLoaders !== void 0 ? configImportLoaders : {}),
|
|
77
|
-
...(overridesImportLoaders !== null && overridesImportLoaders !== void 0 ? overridesImportLoaders : {})
|
|
78
|
-
},
|
|
79
|
-
features: {
|
|
80
|
-
...defaultFeatures,
|
|
81
|
-
...(configFeatures !== null && configFeatures !== void 0 ? configFeatures : {}),
|
|
82
|
-
...rest.features
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
cache.set(overrides, options);
|
|
86
|
-
return options;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=loadWywOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadWywOptions.js","names":["_cosmiconfig","require","_shaker","searchPlaces","explorerSync","cosmiconfigSync","cache","WeakMap","defaultOverrides","nodeModulesRegExp","defaultImportLoaders","raw","url","loadWywOptions","overrides","_result$config","has","get","configFile","ignore","rules","babelOptions","importLoaders","overridesImportLoaders","rest","result","undefined","load","search","defaultFeatures","dangerousCodeRemover","globalCache","happyDOM","softErrors","useBabelConfigs","useWeakRefInEval","config","configImportLoaders","configFeatures","features","options","displayName","evaluate","extensions","outputMetadata","action","shaker","test","filename","code","highPriorityPlugins","set"],"sources":["../../../src/transform/helpers/loadWywOptions.ts"],"sourcesContent":["import { cosmiconfigSync } from 'cosmiconfig';\n\nimport type {\n FeatureFlags,\n ImportLoaders,\n StrictOptions,\n} from '@wyw-in-js/shared';\n\nimport { shaker } from '../../shaker';\nimport type { PluginOptions } from '../../types';\n\nconst searchPlaces = [\n `.wyw-in-jsrc`,\n `.wyw-in-jsrc.json`,\n `.wyw-in-jsrc.yaml`,\n `.wyw-in-jsrc.yml`,\n `.wyw-in-jsrc.js`,\n `.wyw-in-jsrc.cjs`,\n `.config/wyw-in-jsrc`,\n `.config/wyw-in-jsrc.json`,\n `.config/wyw-in-jsrc.yaml`,\n `.config/wyw-in-jsrc.yml`,\n `.config/wyw-in-jsrc.js`,\n `.config/wyw-in-jsrc.cjs`,\n `wyw-in-js.config.js`,\n `wyw-in-js.config.cjs`,\n];\n\nconst explorerSync = cosmiconfigSync('wyw-in-js', { searchPlaces });\n\nexport type PartialOptions = Partial<Omit<PluginOptions, 'features'>> & {\n features?: Partial<FeatureFlags>;\n};\n\nconst cache = new WeakMap<Partial<PartialOptions>, StrictOptions>();\nconst defaultOverrides = {};\nconst nodeModulesRegExp = /[\\\\/]node_modules[\\\\/]/;\nconst defaultImportLoaders: ImportLoaders = {\n raw: 'raw',\n url: 'url',\n};\n\nexport function loadWywOptions(\n overrides: PartialOptions = defaultOverrides\n): StrictOptions {\n if (cache.has(overrides)) {\n return cache.get(overrides)!;\n }\n\n const {\n configFile,\n ignore,\n rules,\n babelOptions = {},\n importLoaders: overridesImportLoaders,\n ...rest\n } = overrides;\n\n const result =\n // eslint-disable-next-line no-nested-ternary\n configFile === false\n ? undefined\n : configFile !== undefined\n ? explorerSync.load(configFile)\n : explorerSync.search();\n\n const defaultFeatures: FeatureFlags = {\n dangerousCodeRemover: true,\n globalCache: true,\n happyDOM: true,\n softErrors: false,\n useBabelConfigs: true,\n useWeakRefInEval: true,\n };\n\n const config = (result?.config ?? {}) as Partial<StrictOptions>;\n const configImportLoaders = config.importLoaders;\n const configFeatures = config.features;\n\n const options: StrictOptions = {\n displayName: false,\n evaluate: true,\n extensions: ['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx'],\n outputMetadata: false,\n rules: rules ?? [\n {\n action: shaker,\n },\n {\n // The old `ignore` option is used as a default value for `ignore` rule.\n test: ignore ?? nodeModulesRegExp,\n action: 'ignore',\n },\n {\n // Do not ignore ES-modules\n test: (filename, code) => {\n if (!nodeModulesRegExp.test(filename)) {\n return false;\n }\n\n // If a file contains `export` or `import` keywords, we assume it's an ES-module\n return /(?:^|\\*\\/|;|})\\s*(?:export|import)[\\s{]/m.test(code);\n },\n action: shaker,\n },\n ],\n babelOptions,\n highPriorityPlugins: ['module-resolver'],\n ...config,\n ...rest,\n importLoaders: {\n ...defaultImportLoaders,\n ...(configImportLoaders ?? {}),\n ...(overridesImportLoaders ?? {}),\n },\n features: {\n ...defaultFeatures,\n ...(configFeatures ?? {}),\n ...rest.features,\n },\n };\n\n cache.set(overrides, options);\n\n return options;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA;AAGA,MAAME,YAAY,GAAG,CACnB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,CACvB;AAED,MAAMC,YAAY,GAAG,IAAAC,4BAAe,EAAC,WAAW,EAAE;EAAEF;AAAa,CAAC,CAAC;AAMnE,MAAMG,KAAK,GAAG,IAAIC,OAAO,CAAyC,CAAC;AACnE,MAAMC,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAMC,iBAAiB,GAAG,wBAAwB;AAClD,MAAMC,oBAAmC,GAAG;EAC1CC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE;AACP,CAAC;AAEM,S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CAAC,EACD;MACE;MACAC,IAAI,EAAE5B,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIV,iBAAiB;MACjCoC,MAAM,EAAE;IACV,CAAC,EACD;MACE;MACAE,IAAI,EAAEA,CAACC,QAAQ,EAAEC,IAAI,KAAK;QACxB,IAAI,CAACxC,iBAAiB,CAACsC,IAAI,CAACC,QAAQ,CAAC,EAAE;UACrC,OAAO,KAAK;QACd;;QAEA;QACA,OAAO,0CAA0C,CAACD,IAAI,CAACE,IAAI,CAAC;MAC9D,CAAC;MACDJ,MAAM,EAAEC;IACV,CAAC,CACF;IACDzB,YAAY;IACZ6B,mBAAmB,EAAE,CAAC,iBAAiB,CAAC;IACxC,GAAGd,MAAM;IACT,GAAGZ,IAAI;IACPF,aAAa,EAAE;MACb,GAAGZ,oBAAoB;MACvB,IAAI2B,mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI,CAAC,CAAC,CAAC;MAC9B,IAAId,sBAAsB,aAAtBA,sBAAsB,cAAtBA,sBAAsB,GAAI,CAAC,CAAC;IAClC,CAAC;IACDgB,QAAQ,EAAE;MACR,GAAGV,eAAe;MAClB,IAAIS,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAI,CAAC,CAAC,CAAC;MACzB,GAAGd,IAAI,CAACe;IACV;EACF,CAAC;EAEDjC,KAAK,CAAC6C,GAAG,CAACrC,SAAS,EAAE0B,OAAO,CAAC;EAE7B,OAAOA,OAAO;AAChB","ignoreList":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.withDefaultServices = void 0;
|
|
7
|
-
var babelCore = _interopRequireWildcard(require("@babel/core"));
|
|
8
|
-
var _cache = require("../../cache");
|
|
9
|
-
var _EventEmitter = require("../../utils/EventEmitter");
|
|
10
|
-
var _Entrypoint = require("../Entrypoint.helpers");
|
|
11
|
-
var _rootLog = require("../rootLog");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
const withDefaultServices = ({
|
|
14
|
-
babel = babelCore,
|
|
15
|
-
cache = new _cache.TransformCacheCollection(),
|
|
16
|
-
emitWarning,
|
|
17
|
-
eventEmitter = _EventEmitter.EventEmitter.dummy,
|
|
18
|
-
loadAndParseFn = _Entrypoint.loadAndParse,
|
|
19
|
-
log = _rootLog.rootLog,
|
|
20
|
-
options
|
|
21
|
-
}) => ({
|
|
22
|
-
babel,
|
|
23
|
-
cache,
|
|
24
|
-
emitWarning,
|
|
25
|
-
eventEmitter,
|
|
26
|
-
loadAndParseFn,
|
|
27
|
-
log,
|
|
28
|
-
options
|
|
29
|
-
});
|
|
30
|
-
exports.withDefaultServices = withDefaultServices;
|
|
31
|
-
//# sourceMappingURL=withDefaultServices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withDefaultServices.js","names":["babelCore","_interopRequireWildcard","require","_cache","_EventEmitter","_Entrypoint","_rootLog","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","withDefaultServices","babel","cache","TransformCacheCollection","emitWarning","eventEmitter","EventEmitter","dummy","loadAndParseFn","loadAndParse","log","rootLog","options","exports"],"sources":["../../../src/transform/helpers/withDefaultServices.ts"],"sourcesContent":["import * as babelCore from '@babel/core';\n\nimport { TransformCacheCollection } from '../../cache';\nimport { EventEmitter } from '../../utils/EventEmitter';\nimport { loadAndParse } from '../Entrypoint.helpers';\nimport { rootLog } from '../rootLog';\nimport type { Services } from '../types';\n\ntype RequiredServices = 'options';\nexport type PartialServices = Partial<Omit<Services, RequiredServices>> &\n Pick<Services, RequiredServices>;\n\nexport const withDefaultServices = ({\n babel = babelCore,\n cache = new TransformCacheCollection(),\n emitWarning,\n eventEmitter = EventEmitter.dummy,\n loadAndParseFn = loadAndParse,\n log = rootLog,\n options,\n}: PartialServices): Services => ({\n babel,\n cache,\n emitWarning,\n eventEmitter,\n loadAndParseFn,\n log,\n options,\n});\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAqC,SAAAD,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAO9B,MAAMkB,mBAAmB,GAAGA,CAAC;EAClCC,KAAK,GAAG3B,SAAS;EACjB4B,KAAK,GAAG,IAAIC,+BAAwB,CAAC,CAAC;EACtCC,WAAW;EACXC,YAAY,GAAGC,0BAAY,CAACC,KAAK;EACjCC,cAAc,GAAGC,wBAAY;EAC7BC,GAAG,GAAGC,gBAAO;EACbC;AACe,CAAC,MAAgB;EAChCX,KAAK;EACLC,KAAK;EACLE,WAAW;EACXC,YAAY;EACZG,cAAc;EACdE,GAAG;EACHE;AACF,CAAC,CAAC;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isStaticallyEvaluatableModule = isStaticallyEvaluatableModule;
|
|
7
|
-
var _types = require("@babel/types");
|
|
8
|
-
function isTypeOnlyImport(statement) {
|
|
9
|
-
if (statement.importKind === 'type') {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
return statement.specifiers.every(specifier => (0, _types.isImportSpecifier)(specifier) && specifier.importKind === 'type');
|
|
13
|
-
}
|
|
14
|
-
function isTypeOnlyReExport(statement) {
|
|
15
|
-
if (!statement.source) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return statement.exportKind === 'type';
|
|
19
|
-
}
|
|
20
|
-
function unwrapExpression(expr) {
|
|
21
|
-
let current = expr;
|
|
22
|
-
for (;;) {
|
|
23
|
-
if ((0, _types.isTSAsExpression)(current)) {
|
|
24
|
-
current = current.expression;
|
|
25
|
-
// eslint-disable-next-line no-continue
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if ((0, _types.isTSSatisfiesExpression)(current)) {
|
|
29
|
-
current = current.expression;
|
|
30
|
-
// eslint-disable-next-line no-continue
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if ((0, _types.isTSNonNullExpression)(current)) {
|
|
34
|
-
current = current.expression;
|
|
35
|
-
// eslint-disable-next-line no-continue
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if ((0, _types.isTSInstantiationExpression)(current)) {
|
|
39
|
-
current = current.expression;
|
|
40
|
-
// eslint-disable-next-line no-continue
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if ((0, _types.isParenthesizedExpression)(current)) {
|
|
44
|
-
current = current.expression;
|
|
45
|
-
// eslint-disable-next-line no-continue
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
return current;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function isSafeExpression(expr) {
|
|
52
|
-
const unwrapped = unwrapExpression(expr);
|
|
53
|
-
if ((0, _types.isStringLiteral)(unwrapped) || (0, _types.isNumericLiteral)(unwrapped) || (0, _types.isBooleanLiteral)(unwrapped) || (0, _types.isNullLiteral)(unwrapped) || (0, _types.isBigIntLiteral)(unwrapped)) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
if ((0, _types.isArrowFunctionExpression)(unwrapped) || (0, _types.isFunctionExpression)(unwrapped)) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
if ((0, _types.isIdentifier)(unwrapped)) {
|
|
60
|
-
return unwrapped.name === 'undefined' || unwrapped.name === 'NaN' || unwrapped.name === 'Infinity';
|
|
61
|
-
}
|
|
62
|
-
if ((0, _types.isTemplateLiteral)(unwrapped)) {
|
|
63
|
-
return unwrapped.expressions.every(item => (0, _types.isExpression)(item) && isSafeExpression(item));
|
|
64
|
-
}
|
|
65
|
-
if ((0, _types.isUnaryExpression)(unwrapped)) {
|
|
66
|
-
return isSafeExpression(unwrapped.argument);
|
|
67
|
-
}
|
|
68
|
-
if ((0, _types.isBinaryExpression)(unwrapped) || (0, _types.isLogicalExpression)(unwrapped)) {
|
|
69
|
-
return isSafeExpression(unwrapped.left) && isSafeExpression(unwrapped.right);
|
|
70
|
-
}
|
|
71
|
-
if ((0, _types.isConditionalExpression)(unwrapped)) {
|
|
72
|
-
return isSafeExpression(unwrapped.test) && isSafeExpression(unwrapped.consequent) && isSafeExpression(unwrapped.alternate);
|
|
73
|
-
}
|
|
74
|
-
if ((0, _types.isArrayExpression)(unwrapped)) {
|
|
75
|
-
return unwrapped.elements.every(item => {
|
|
76
|
-
if (item === null) return true;
|
|
77
|
-
if ((0, _types.isSpreadElement)(item)) return false;
|
|
78
|
-
return isSafeExpression(item);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if ((0, _types.isObjectExpression)(unwrapped)) {
|
|
82
|
-
return unwrapped.properties.every(prop => {
|
|
83
|
-
if ((0, _types.isSpreadElement)(prop)) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if ((0, _types.isObjectMethod)(prop)) {
|
|
87
|
-
return !prop.computed;
|
|
88
|
-
}
|
|
89
|
-
if ((0, _types.isObjectProperty)(prop)) {
|
|
90
|
-
if (prop.computed) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return (0, _types.isExpression)(prop.value) && isSafeExpression(prop.value);
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if ((0, _types.isCallExpression)(unwrapped) || (0, _types.isNewExpression)(unwrapped) || (0, _types.isTaggedTemplateExpression)(unwrapped) || (0, _types.isAwaitExpression)(unwrapped) || (0, _types.isYieldExpression)(unwrapped) || (0, _types.isUpdateExpression)(unwrapped) || (0, _types.isAssignmentExpression)(unwrapped) || (0, _types.isSequenceExpression)(unwrapped)) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
function isSafeDeclarator(declarator) {
|
|
104
|
-
if (!declarator.init) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
return isSafeExpression(declarator.init);
|
|
108
|
-
}
|
|
109
|
-
function isSafeVariableDeclaration(decl) {
|
|
110
|
-
return decl.declarations.every(isSafeDeclarator);
|
|
111
|
-
}
|
|
112
|
-
function isSafeStatement(statement) {
|
|
113
|
-
if ((0, _types.isImportDeclaration)(statement)) {
|
|
114
|
-
return isTypeOnlyImport(statement);
|
|
115
|
-
}
|
|
116
|
-
if ((0, _types.isExportAllDeclaration)(statement)) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
if ((0, _types.isExportNamedDeclaration)(statement)) {
|
|
120
|
-
if (!statement.declaration) {
|
|
121
|
-
return !statement.source || isTypeOnlyReExport(statement);
|
|
122
|
-
}
|
|
123
|
-
if ((0, _types.isFunctionDeclaration)(statement.declaration)) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
if ((0, _types.isClassDeclaration)(statement.declaration)) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (statement.declaration.type === 'VariableDeclaration') {
|
|
130
|
-
return isSafeVariableDeclaration(statement.declaration);
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if ((0, _types.isExportDefaultDeclaration)(statement)) {
|
|
135
|
-
const decl = statement.declaration;
|
|
136
|
-
if ((0, _types.isFunctionDeclaration)(decl) || (0, _types.isFunctionExpression)(decl) || (0, _types.isArrowFunctionExpression)(decl) || (0, _types.isClassExpression)(decl) || (0, _types.isClassDeclaration)(decl)) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
return isSafeExpression(decl);
|
|
140
|
-
}
|
|
141
|
-
if (statement.type === 'VariableDeclaration') {
|
|
142
|
-
return isSafeVariableDeclaration(statement);
|
|
143
|
-
}
|
|
144
|
-
if ((0, _types.isFunctionDeclaration)(statement)) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
if ((0, _types.isEmptyStatement)(statement)) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
if ((0, _types.isExpressionStatement)(statement)) {
|
|
151
|
-
// Directives (like "use strict") are safe.
|
|
152
|
-
return (0, _types.isStringLiteral)(statement.expression);
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
function isStaticallyEvaluatableModule(ast) {
|
|
157
|
-
return ast.program.body.every(isSafeStatement);
|
|
158
|
-
}
|
|
159
|
-
//# sourceMappingURL=isStaticallyEvaluatableModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isStaticallyEvaluatableModule.js","names":["_types","require","isTypeOnlyImport","statement","importKind","specifiers","every","specifier","isImportSpecifier","isTypeOnlyReExport","source","exportKind","unwrapExpression","expr","current","isTSAsExpression","expression","isTSSatisfiesExpression","isTSNonNullExpression","isTSInstantiationExpression","isParenthesizedExpression","isSafeExpression","unwrapped","isStringLiteral","isNumericLiteral","isBooleanLiteral","isNullLiteral","isBigIntLiteral","isArrowFunctionExpression","isFunctionExpression","isIdentifier","name","isTemplateLiteral","expressions","item","isExpression","isUnaryExpression","argument","isBinaryExpression","isLogicalExpression","left","right","isConditionalExpression","test","consequent","alternate","isArrayExpression","elements","isSpreadElement","isObjectExpression","properties","prop","isObjectMethod","computed","isObjectProperty","value","isCallExpression","isNewExpression","isTaggedTemplateExpression","isAwaitExpression","isYieldExpression","isUpdateExpression","isAssignmentExpression","isSequenceExpression","isSafeDeclarator","declarator","init","isSafeVariableDeclaration","decl","declarations","isSafeStatement","isImportDeclaration","isExportAllDeclaration","isExportNamedDeclaration","declaration","isFunctionDeclaration","isClassDeclaration","type","isExportDefaultDeclaration","isClassExpression","isEmptyStatement","isExpressionStatement","isStaticallyEvaluatableModule","ast","program","body"],"sources":["../../src/transform/isStaticallyEvaluatableModule.ts"],"sourcesContent":["import type {\n Expression,\n ImportDeclaration,\n ExportNamedDeclaration,\n File,\n Statement,\n VariableDeclaration,\n VariableDeclarator,\n} from '@babel/types';\nimport {\n isArrayExpression,\n isArrowFunctionExpression,\n isAssignmentExpression,\n isAwaitExpression,\n isBinaryExpression,\n isBigIntLiteral,\n isBooleanLiteral,\n isCallExpression,\n isClassDeclaration,\n isClassExpression,\n isConditionalExpression,\n isEmptyStatement,\n isExportAllDeclaration,\n isExportDefaultDeclaration,\n isExportNamedDeclaration,\n isExpression,\n isExpressionStatement,\n isFunctionDeclaration,\n isFunctionExpression,\n isIdentifier,\n isImportDeclaration,\n isImportSpecifier,\n isLogicalExpression,\n isNewExpression,\n isNullLiteral,\n isNumericLiteral,\n isObjectExpression,\n isObjectMethod,\n isObjectProperty,\n isParenthesizedExpression,\n isSequenceExpression,\n isSpreadElement,\n isStringLiteral,\n isTaggedTemplateExpression,\n isTemplateLiteral,\n isTSAsExpression,\n isTSInstantiationExpression,\n isTSNonNullExpression,\n isTSSatisfiesExpression,\n isUnaryExpression,\n isUpdateExpression,\n isYieldExpression,\n} from '@babel/types';\n\nfunction isTypeOnlyImport(statement: ImportDeclaration): boolean {\n if (statement.importKind === 'type') {\n return true;\n }\n\n return statement.specifiers.every(\n (specifier) =>\n isImportSpecifier(specifier) && specifier.importKind === 'type'\n );\n}\n\nfunction isTypeOnlyReExport(statement: ExportNamedDeclaration): boolean {\n if (!statement.source) {\n return false;\n }\n\n return statement.exportKind === 'type';\n}\n\nfunction unwrapExpression(expr: Expression): Expression {\n let current: Expression = expr;\n\n for (;;) {\n if (isTSAsExpression(current)) {\n current = current.expression;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (isTSSatisfiesExpression(current)) {\n current = current.expression;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (isTSNonNullExpression(current)) {\n current = current.expression;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (isTSInstantiationExpression(current)) {\n current = current.expression;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (isParenthesizedExpression(current)) {\n current = current.expression;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n return current;\n }\n}\n\nfunction isSafeExpression(expr: Expression): boolean {\n const unwrapped = unwrapExpression(expr);\n\n if (\n isStringLiteral(unwrapped) ||\n isNumericLiteral(unwrapped) ||\n isBooleanLiteral(unwrapped) ||\n isNullLiteral(unwrapped) ||\n isBigIntLiteral(unwrapped)\n ) {\n return true;\n }\n\n if (isArrowFunctionExpression(unwrapped) || isFunctionExpression(unwrapped)) {\n return true;\n }\n\n if (isIdentifier(unwrapped)) {\n return (\n unwrapped.name === 'undefined' ||\n unwrapped.name === 'NaN' ||\n unwrapped.name === 'Infinity'\n );\n }\n\n if (isTemplateLiteral(unwrapped)) {\n return unwrapped.expressions.every(\n (item) => isExpression(item) && isSafeExpression(item)\n );\n }\n\n if (isUnaryExpression(unwrapped)) {\n return isSafeExpression(unwrapped.argument as Expression);\n }\n\n if (isBinaryExpression(unwrapped) || isLogicalExpression(unwrapped)) {\n return (\n isSafeExpression(unwrapped.left as Expression) &&\n isSafeExpression(unwrapped.right as Expression)\n );\n }\n\n if (isConditionalExpression(unwrapped)) {\n return (\n isSafeExpression(unwrapped.test) &&\n isSafeExpression(unwrapped.consequent) &&\n isSafeExpression(unwrapped.alternate)\n );\n }\n\n if (isArrayExpression(unwrapped)) {\n return unwrapped.elements.every((item) => {\n if (item === null) return true;\n if (isSpreadElement(item)) return false;\n return isSafeExpression(item);\n });\n }\n\n if (isObjectExpression(unwrapped)) {\n return unwrapped.properties.every((prop) => {\n if (isSpreadElement(prop)) {\n return false;\n }\n\n if (isObjectMethod(prop)) {\n return !prop.computed;\n }\n\n if (isObjectProperty(prop)) {\n if (prop.computed) {\n return false;\n }\n\n return isExpression(prop.value) && isSafeExpression(prop.value);\n }\n\n return false;\n });\n }\n\n if (\n isCallExpression(unwrapped) ||\n isNewExpression(unwrapped) ||\n isTaggedTemplateExpression(unwrapped) ||\n isAwaitExpression(unwrapped) ||\n isYieldExpression(unwrapped) ||\n isUpdateExpression(unwrapped) ||\n isAssignmentExpression(unwrapped) ||\n isSequenceExpression(unwrapped)\n ) {\n return false;\n }\n\n return false;\n}\n\nfunction isSafeDeclarator(declarator: VariableDeclarator): boolean {\n if (!declarator.init) {\n return true;\n }\n\n return isSafeExpression(declarator.init);\n}\n\nfunction isSafeVariableDeclaration(decl: VariableDeclaration): boolean {\n return decl.declarations.every(isSafeDeclarator);\n}\n\nfunction isSafeStatement(statement: Statement): boolean {\n if (isImportDeclaration(statement)) {\n return isTypeOnlyImport(statement);\n }\n\n if (isExportAllDeclaration(statement)) {\n return false;\n }\n\n if (isExportNamedDeclaration(statement)) {\n if (!statement.declaration) {\n return !statement.source || isTypeOnlyReExport(statement);\n }\n\n if (isFunctionDeclaration(statement.declaration)) {\n return true;\n }\n\n if (isClassDeclaration(statement.declaration)) {\n return false;\n }\n\n if (statement.declaration.type === 'VariableDeclaration') {\n return isSafeVariableDeclaration(statement.declaration);\n }\n\n return false;\n }\n\n if (isExportDefaultDeclaration(statement)) {\n const decl = statement.declaration;\n if (\n isFunctionDeclaration(decl) ||\n isFunctionExpression(decl) ||\n isArrowFunctionExpression(decl) ||\n isClassExpression(decl) ||\n isClassDeclaration(decl)\n ) {\n return false;\n }\n\n return isSafeExpression(decl as Expression);\n }\n\n if (statement.type === 'VariableDeclaration') {\n return isSafeVariableDeclaration(statement);\n }\n\n if (isFunctionDeclaration(statement)) {\n return true;\n }\n\n if (isEmptyStatement(statement)) {\n return true;\n }\n\n if (isExpressionStatement(statement)) {\n // Directives (like \"use strict\") are safe.\n return isStringLiteral(statement.expression);\n }\n\n return false;\n}\n\nexport function isStaticallyEvaluatableModule(ast: File): boolean {\n return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IAAI,CAAC,IAC1B,IAAAxC,gCAAyB,EAACwC,IAAI,CAAC,IAC/B,IAAAW,wBAAiB,EAACX,IAAI,CAAC,IACvB,IAAAQ,yBAAkB,EAACR,IAAI,CAAC,EACxB;MACA,OAAO,KAAK;IACd;IAEA,OAAO/C,gBAAgB,CAAC+C,IAAkB,CAAC;EAC7C;EAEA,IAAIjE,SAAS,CAAC0E,IAAI,KAAK,qBAAqB,EAAE;IAC5C,OAAOV,yBAAyB,CAAChE,SAAS,CAAC;EAC7C;EAEA,IAAI,IAAAwE,4BAAqB,EAACxE,SAAS,CAAC,EAAE;IACpC,OAAO,IAAI;EACb;EAEA,IAAI,IAAA6E,uBAAgB,EAAC7E,SAAS,CAAC,EAAE;IAC/B,OAAO,IAAI;EACb;EAEA,IAAI,IAAA8E,4BAAqB,EAAC9E,SAAS,CAAC,EAAE;IACpC;IACA,OAAO,IAAAoB,sBAAe,EAACpB,SAAS,CAACa,UAAU,CAAC;EAC9C;EAEA,OAAO,KAAK;AACd;AAEO,SAASkE,6BAA6BA,CAACC,GAAS,EAAW;EAChE,OAAOA,GAAG,CAACC,OAAO,CAACC,IAAI,CAAC/E,KAAK,CAACgE,eAAe,CAAC;AAChD","ignoreList":[]}
|
package/lib/transform/rootLog.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.rootLog = void 0;
|
|
7
|
-
var _shared = require("@wyw-in-js/shared");
|
|
8
|
-
const rootLog = exports.rootLog = _shared.logger.extend('transform');
|
|
9
|
-
//# sourceMappingURL=rootLog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rootLog.js","names":["_shared","require","rootLog","exports","logger","extend"],"sources":["../../src/transform/rootLog.ts"],"sourcesContent":["import type { Debugger } from '@wyw-in-js/shared';\nimport { logger } from '@wyw-in-js/shared';\n\nexport const rootLog: Debugger = logger.extend('transform');\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,OAAiB,GAAAC,OAAA,CAAAD,OAAA,GAAGE,cAAM,CAACC,MAAM,CAAC,WAAW,CAAC","ignoreList":[]}
|
package/lib/transform/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Pending","exports","Symbol"],"sources":["../../src/transform/types.ts"],"sourcesContent":["import type { BabelFileResult } from '@babel/core';\n\nimport type { ValueCache } from '@wyw-in-js/processor-utils';\nimport type { Debugger, Artifact, StrictOptions } from '@wyw-in-js/shared';\n\nimport type { Core } from '../babel';\nimport type { TransformCacheCollection } from '../cache';\nimport type { Options, ITransformFileResult } from '../types';\nimport type { EventEmitter } from '../utils/EventEmitter';\nimport type { WYWTransformMetadata } from '../utils/TransformMetadata';\n\nimport type { Entrypoint } from './Entrypoint';\nimport type { LoadAndParseFn, IEntrypointDependency } from './Entrypoint.types';\nimport type { BaseAction } from './actions/BaseAction';\nimport type {\n IExtracted,\n IWorkflowActionLinariaResult,\n IWorkflowActionNonLinariaResult,\n} from './actions/types';\n\nexport type Services = {\n babel: Core;\n cache: TransformCacheCollection;\n emitWarning?: (message: string) => void;\n eventEmitter: EventEmitter;\n loadAndParseFn: LoadAndParseFn;\n log: Debugger;\n options: Options & {\n pluginOptions: StrictOptions;\n };\n};\n\nexport interface IBaseNode {\n type: ActionTypes;\n}\n\nexport type ActionByType<TType extends ActionQueueItem['type']> = Extract<\n ActionQueueItem,\n {\n type: TType;\n }\n>;\n\nexport const Pending = Symbol('pending');\n\nexport type YieldResult = Exclude<ActionQueueItem['result'], typeof Pending>;\n\nexport type AnyIteratorResult<TMode extends 'async' | 'sync', TResult> = {\n async: Promise<IteratorResult<YieldArg, TResult>>;\n sync: IteratorResult<YieldArg, TResult>;\n}[TMode];\n\nexport interface IBaseAction<TAction extends ActionQueueItem, TResult, TData>\n extends IBaseNode {\n actionContext: unknown;\n abortSignal: AbortSignal | null;\n createAbortSignal: () => AbortSignal & Disposable;\n data: TData;\n entrypoint: Entrypoint;\n getNext: GetNext;\n idx: string;\n result: TResult | typeof Pending;\n run: <TMode extends 'async' | 'sync'>(\n handler: Handler<TMode, TAction>\n ) => {\n next: (arg: YieldResult) => AnyIteratorResult<TMode, TResult>;\n throw(e: unknown): AnyIteratorResult<TMode, TResult>;\n };\n services: Services;\n}\n\ntype NextParams<\n TType extends ActionTypes,\n TNextAction extends ActionByType<TType> = ActionByType<TType>,\n> = [\n type: TType,\n entrypoint: Entrypoint,\n data: TNextAction['data'],\n abortSignal?: AbortSignal | null,\n];\n\nexport type YieldArg = {\n [K in ActionQueueItem['type']]: NextParams<K>;\n}[ActionQueueItem['type']];\n\nexport type SyncScenarioFor<TResult> = {\n [Symbol.iterator](): SyncScenarioFor<TResult>;\n next(arg: YieldResult): IteratorResult<YieldArg, TResult>;\n return(value: TResult): IteratorResult<YieldArg, TResult>;\n throw(e: unknown): IteratorResult<YieldArg, TResult>;\n};\n\nexport type AsyncScenarioFor<TResult> = {\n [Symbol.asyncIterator](): AsyncScenarioFor<TResult>;\n next(arg: YieldResult): Promise<IteratorResult<YieldArg, TResult>>;\n return(\n value: TResult | PromiseLike<TResult>\n ): Promise<IteratorResult<YieldArg, TResult>>;\n throw(e: unknown): Promise<IteratorResult<YieldArg, TResult>>;\n};\n\nexport type SyncScenarioForAction<TAction extends ActionQueueItem> =\n SyncScenarioFor<TypeOfResult<TAction>>;\n\nexport type AsyncScenarioForAction<TAction extends ActionQueueItem> =\n AsyncScenarioFor<TypeOfResult<TAction>>;\n\nexport type Handler<\n TMode extends 'async' | 'sync',\n TAction extends ActionQueueItem,\n> = ((this: BaseAction<TAction>) => {\n async: AsyncScenarioForAction<TAction>;\n sync: SyncScenarioForAction<TAction>;\n}[TMode]) & {\n recover?: (e: unknown, action: BaseAction<TAction>) => YieldArg;\n};\n\nexport type Handlers<TMode extends 'async' | 'sync'> = {\n [TAction in ActionQueueItem as TAction['type']]: Handler<TMode, TAction>;\n};\n\nexport type TypeOfResult<T extends ActionQueueItem> = Exclude<\n T['result'],\n typeof Pending\n>;\n\nexport type GetNext = <\n TType extends ActionTypes,\n TNextAction extends ActionByType<TType> = ActionByType<TType>,\n>(\n ...args: NextParams<TType, TNextAction>\n) => Generator<\n [TType, Entrypoint, TNextAction['data'], AbortSignal | null],\n TypeOfResult<TNextAction>,\n YieldResult\n>;\n\nexport interface ICollectActionResult {\n ast: BabelFileResult['ast']; // FIXME: looks like this is not used\n code: BabelFileResult['code'];\n map?: BabelFileResult['map'];\n metadata?: WYWTransformMetadata | null;\n}\n\nexport interface ICollectAction\n extends IBaseAction<\n ICollectAction,\n ICollectActionResult,\n { valueCache: ValueCache }\n > {\n type: 'collect';\n}\n\nexport interface IEvalAction\n extends IBaseAction<IEvalAction, [ValueCache, string[]] | null, undefined> {\n type: 'evalFile';\n}\n\nexport interface IExplodeReexportsAction\n extends IBaseAction<IExplodeReexportsAction, void, undefined> {\n type: 'explodeReexports';\n}\n\nexport interface IExtractAction\n extends IBaseAction<\n IExtractAction,\n IExtracted,\n { processors: { artifacts: Artifact[] }[] }\n > {\n type: 'extract';\n}\n\nexport interface IGetExportsAction\n extends IBaseAction<IGetExportsAction, string[], undefined> {\n type: 'getExports';\n}\n\nexport interface IProcessEntrypointAction\n extends IBaseAction<IProcessEntrypointAction, void, undefined> {\n type: 'processEntrypoint';\n}\n\nexport interface IProcessImportsAction\n extends IBaseAction<\n IProcessImportsAction,\n void,\n {\n resolved: IEntrypointDependency[];\n }\n > {\n type: 'processImports';\n}\n\nexport interface IResolveImportsAction\n extends IBaseAction<\n IResolveImportsAction,\n IEntrypointDependency[],\n {\n imports: Map<string, string[]> | null;\n phase?: 'initial' | 'rewritten';\n preResolved?: IEntrypointDependency[];\n }\n > {\n type: 'resolveImports';\n}\n\nexport interface ITransformAction\n extends IBaseAction<ITransformAction, ITransformFileResult, undefined> {\n type: 'transform';\n}\n\nexport interface IWorkflowAction\n extends IBaseAction<\n IWorkflowAction,\n IWorkflowActionLinariaResult | IWorkflowActionNonLinariaResult,\n undefined\n > {\n type: 'workflow';\n}\n\nexport type ActionQueueItem =\n | IEvalAction\n | IExplodeReexportsAction\n | IExtractAction\n | IGetExportsAction\n | ICollectAction\n | IProcessEntrypointAction\n | IProcessImportsAction\n | IResolveImportsAction\n | ITransformAction\n | IWorkflowAction;\n\nexport type ActionTypes = ActionQueueItem['type'];\n"],"mappings":";;;;;;AA2CO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGE,MAAM,CAAC,SAAS,CAAC","ignoreList":[]}
|
package/lib/transform.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.transform = transform;
|
|
7
|
-
exports.transformSync = transformSync;
|
|
8
|
-
var _shared = require("@wyw-in-js/shared");
|
|
9
|
-
var _loadWywOptions = require("./transform/helpers/loadWywOptions");
|
|
10
|
-
var _cache = require("./cache");
|
|
11
|
-
var _Entrypoint = require("./transform/Entrypoint");
|
|
12
|
-
var _actionRunner = require("./transform/actions/actionRunner");
|
|
13
|
-
var _generators = require("./transform/generators");
|
|
14
|
-
var _resolveImports = require("./transform/generators/resolveImports");
|
|
15
|
-
var _withDefaultServices = require("./transform/helpers/withDefaultServices");
|
|
16
|
-
/**
|
|
17
|
-
* This file exposes sync and async transform functions that:
|
|
18
|
-
* - parse the passed code to AST
|
|
19
|
-
* - builds a dependency graph for the file
|
|
20
|
-
* - shakes each dependency and removes unused code
|
|
21
|
-
* - runs generated code in a sandbox
|
|
22
|
-
* - collects artifacts
|
|
23
|
-
* - returns transformed code (without WYW template literals), generated CSS, source maps and babel metadata from transform step.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const memoizedSyncResolve = new WeakMap();
|
|
27
|
-
const memoizedAsyncResolve = new WeakMap();
|
|
28
|
-
const EMPTY_CUSTOM_HANDLERS = {};
|
|
29
|
-
const memoizedActionContexts = new WeakMap();
|
|
30
|
-
const getActionContext = (resolveImportsHandler, customHandlers) => {
|
|
31
|
-
const customHandlersKey = Object.keys(customHandlers).length === 0 ? EMPTY_CUSTOM_HANDLERS : customHandlers;
|
|
32
|
-
let actionContextsByHandlers = memoizedActionContexts.get(resolveImportsHandler);
|
|
33
|
-
if (!actionContextsByHandlers) {
|
|
34
|
-
actionContextsByHandlers = new WeakMap();
|
|
35
|
-
memoizedActionContexts.set(resolveImportsHandler, actionContextsByHandlers);
|
|
36
|
-
}
|
|
37
|
-
let actionContext = actionContextsByHandlers.get(customHandlersKey);
|
|
38
|
-
if (!actionContext) {
|
|
39
|
-
actionContext = {};
|
|
40
|
-
actionContextsByHandlers.set(customHandlersKey, actionContext);
|
|
41
|
-
}
|
|
42
|
-
return actionContext;
|
|
43
|
-
};
|
|
44
|
-
function transformSync(partialServices, originalCode, syncResolve, customHandlers = {}) {
|
|
45
|
-
const {
|
|
46
|
-
options
|
|
47
|
-
} = partialServices;
|
|
48
|
-
const pluginOptions = (0, _loadWywOptions.loadWywOptions)(options.pluginOptions);
|
|
49
|
-
const services = (0, _withDefaultServices.withDefaultServices)({
|
|
50
|
-
...partialServices,
|
|
51
|
-
options: {
|
|
52
|
-
...options,
|
|
53
|
-
pluginOptions
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
if (!(0, _shared.isFeatureEnabled)(pluginOptions.features, 'globalCache', options.filename)) {
|
|
57
|
-
// If global cache is disabled, we need to create a new cache for each file
|
|
58
|
-
services.cache = new _cache.TransformCacheCollection();
|
|
59
|
-
}
|
|
60
|
-
if (!memoizedSyncResolve.has(syncResolve)) {
|
|
61
|
-
memoizedSyncResolve.set(syncResolve, function resolveImports() {
|
|
62
|
-
return _resolveImports.syncResolveImports.call(this, syncResolve);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const resolveImportsHandler = memoizedSyncResolve.get(syncResolve);
|
|
66
|
-
const actionHandlers = {
|
|
67
|
-
..._generators.baseHandlers,
|
|
68
|
-
...customHandlers,
|
|
69
|
-
resolveImports: resolveImportsHandler
|
|
70
|
-
};
|
|
71
|
-
const actionContext = getActionContext(resolveImportsHandler, customHandlers);
|
|
72
|
-
const entrypoint = _Entrypoint.Entrypoint.createRoot(services, options.filename, ['__wywPreval'], originalCode);
|
|
73
|
-
if (entrypoint.ignored) {
|
|
74
|
-
return {
|
|
75
|
-
code: originalCode,
|
|
76
|
-
sourceMap: options.inputSourceMap
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const workflowAction = entrypoint.createAction('workflow', undefined, null, actionContext);
|
|
80
|
-
try {
|
|
81
|
-
const result = (0, _actionRunner.syncActionRunner)(workflowAction, actionHandlers);
|
|
82
|
-
entrypoint.log('%s is ready', entrypoint.name);
|
|
83
|
-
return result;
|
|
84
|
-
} catch (err) {
|
|
85
|
-
entrypoint.log('Unhandled error %O', err);
|
|
86
|
-
if ((0, _shared.isFeatureEnabled)(pluginOptions.features, 'softErrors', options.filename)) {
|
|
87
|
-
// eslint-disable-next-line no-console
|
|
88
|
-
console.error(`Error during transform of ${entrypoint.name}:`, err);
|
|
89
|
-
return {
|
|
90
|
-
code: originalCode,
|
|
91
|
-
sourceMap: options.inputSourceMap
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function transform(partialServices, originalCode, asyncResolve, customHandlers = {}) {
|
|
98
|
-
const {
|
|
99
|
-
options
|
|
100
|
-
} = partialServices;
|
|
101
|
-
const pluginOptions = (0, _loadWywOptions.loadWywOptions)(options.pluginOptions);
|
|
102
|
-
const services = (0, _withDefaultServices.withDefaultServices)({
|
|
103
|
-
...partialServices,
|
|
104
|
-
options: {
|
|
105
|
-
...options,
|
|
106
|
-
pluginOptions
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
if (!(0, _shared.isFeatureEnabled)(pluginOptions.features, 'globalCache', options.filename)) {
|
|
110
|
-
// If global cache is disabled, we need to create a new cache for each file
|
|
111
|
-
services.cache = new _cache.TransformCacheCollection();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
* This method can be run simultaneously for multiple files.
|
|
116
|
-
* A shared cache is accessible for all runs, but each run has its own queue
|
|
117
|
-
* to maintain the correct processing order. The cache stores the outcome
|
|
118
|
-
* of tree-shaking, and if the result is already stored in the cache
|
|
119
|
-
* but the "only" option has changed, the file will be re-processed using
|
|
120
|
-
* the combined "only" option.
|
|
121
|
-
*/
|
|
122
|
-
if (!memoizedAsyncResolve.has(asyncResolve)) {
|
|
123
|
-
const resolveImports = function resolveImports() {
|
|
124
|
-
return _resolveImports.asyncResolveImports.call(this, asyncResolve);
|
|
125
|
-
};
|
|
126
|
-
memoizedAsyncResolve.set(asyncResolve, resolveImports);
|
|
127
|
-
}
|
|
128
|
-
const resolveImportsHandler = memoizedAsyncResolve.get(asyncResolve);
|
|
129
|
-
const actionHandlers = {
|
|
130
|
-
..._generators.baseHandlers,
|
|
131
|
-
...customHandlers,
|
|
132
|
-
resolveImports: resolveImportsHandler
|
|
133
|
-
};
|
|
134
|
-
const actionContext = getActionContext(resolveImportsHandler, customHandlers);
|
|
135
|
-
const entrypoint = _Entrypoint.Entrypoint.createRoot(services, options.filename, ['__wywPreval'], originalCode);
|
|
136
|
-
if (entrypoint.ignored) {
|
|
137
|
-
return {
|
|
138
|
-
code: originalCode,
|
|
139
|
-
sourceMap: options.inputSourceMap
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const workflowAction = entrypoint.createAction('workflow', undefined, null, actionContext);
|
|
143
|
-
try {
|
|
144
|
-
const result = await (0, _actionRunner.asyncActionRunner)(workflowAction, actionHandlers);
|
|
145
|
-
entrypoint.log('%s is ready', entrypoint.name);
|
|
146
|
-
return result;
|
|
147
|
-
} catch (err) {
|
|
148
|
-
entrypoint.log('Unhandled error %O', err);
|
|
149
|
-
if ((0, _shared.isFeatureEnabled)(pluginOptions.features, 'softErrors', options.filename)) {
|
|
150
|
-
// eslint-disable-next-line no-console
|
|
151
|
-
console.error(`Error during transform of ${entrypoint.name}:`, err);
|
|
152
|
-
return {
|
|
153
|
-
code: originalCode,
|
|
154
|
-
sourceMap: options.inputSourceMap
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
throw err;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
//# sourceMappingURL=transform.js.map
|
package/lib/transform.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","names":["_shared","require","_loadWywOptions","_cache","_Entrypoint","_actionRunner","_generators","_resolveImports","_withDefaultServices","memoizedSyncResolve","WeakMap","memoizedAsyncResolve","EMPTY_CUSTOM_HANDLERS","memoizedActionContexts","getActionContext","resolveImportsHandler","customHandlers","customHandlersKey","Object","keys","length","actionContextsByHandlers","get","set","actionContext","transformSync","partialServices","originalCode","syncResolve","options","pluginOptions","loadWywOptions","services","withDefaultServices","isFeatureEnabled","features","filename","cache","TransformCacheCollection","has","resolveImports","syncResolveImports","call","actionHandlers","baseHandlers","entrypoint","Entrypoint","createRoot","ignored","code","sourceMap","inputSourceMap","workflowAction","createAction","undefined","result","syncActionRunner","log","name","err","console","error","transform","asyncResolve","asyncResolveImports","asyncActionRunner"],"sources":["../src/transform.ts"],"sourcesContent":["/**\n * This file exposes sync and async transform functions that:\n * - parse the passed code to AST\n * - builds a dependency graph for the file\n * - shakes each dependency and removes unused code\n * - runs generated code in a sandbox\n * - collects artifacts\n * - returns transformed code (without WYW template literals), generated CSS, source maps and babel metadata from transform step.\n */\n\nimport { isFeatureEnabled } from '@wyw-in-js/shared';\n\nimport type { PartialOptions } from './transform/helpers/loadWywOptions';\nimport { loadWywOptions } from './transform/helpers/loadWywOptions';\nimport { TransformCacheCollection } from './cache';\nimport { Entrypoint } from './transform/Entrypoint';\nimport {\n asyncActionRunner,\n syncActionRunner,\n} from './transform/actions/actionRunner';\nimport { baseHandlers } from './transform/generators';\nimport {\n asyncResolveImports,\n syncResolveImports,\n} from './transform/generators/resolveImports';\nimport { withDefaultServices } from './transform/helpers/withDefaultServices';\nimport type {\n Handler,\n Handlers,\n IResolveImportsAction,\n Services,\n} from './transform/types';\nimport type { Result } from './types';\n\ntype PartialServices = Partial<Omit<Services, 'options'>> & {\n options: Omit<Services['options'], 'pluginOptions'> & {\n pluginOptions?: PartialOptions;\n };\n};\n\ntype AllHandlers<TMode extends 'async' | 'sync'> = Handlers<TMode>;\n\nconst memoizedSyncResolve = new WeakMap<\n (what: string, importer: string, stack: string[]) => string | null,\n Handler<'sync', IResolveImportsAction>\n>();\n\nconst memoizedAsyncResolve = new WeakMap<\n (what: string, importer: string, stack: string[]) => Promise<string | null>,\n Handler<'async' | 'sync', IResolveImportsAction>\n>();\n\nconst EMPTY_CUSTOM_HANDLERS = {};\nconst memoizedActionContexts = new WeakMap<object, WeakMap<object, object>>();\n\nconst getActionContext = (\n resolveImportsHandler: object,\n customHandlers: object\n): object => {\n const customHandlersKey =\n Object.keys(customHandlers).length === 0\n ? EMPTY_CUSTOM_HANDLERS\n : customHandlers;\n let actionContextsByHandlers = memoizedActionContexts.get(\n resolveImportsHandler\n );\n if (!actionContextsByHandlers) {\n actionContextsByHandlers = new WeakMap();\n memoizedActionContexts.set(resolveImportsHandler, actionContextsByHandlers);\n }\n\n let actionContext = actionContextsByHandlers.get(customHandlersKey);\n if (!actionContext) {\n actionContext = {};\n actionContextsByHandlers.set(customHandlersKey, actionContext);\n }\n\n return actionContext;\n};\n\nexport function transformSync(\n partialServices: PartialServices,\n originalCode: string,\n syncResolve: (what: string, importer: string, stack: string[]) => string,\n customHandlers: Partial<AllHandlers<'sync'>> = {}\n): Result {\n const { options } = partialServices;\n const pluginOptions = loadWywOptions(options.pluginOptions);\n const services = withDefaultServices({\n ...partialServices,\n options: {\n ...options,\n pluginOptions,\n },\n });\n\n if (\n !isFeatureEnabled(pluginOptions.features, 'globalCache', options.filename)\n ) {\n // If global cache is disabled, we need to create a new cache for each file\n services.cache = new TransformCacheCollection();\n }\n\n if (!memoizedSyncResolve.has(syncResolve)) {\n memoizedSyncResolve.set(\n syncResolve,\n function resolveImports(this: IResolveImportsAction) {\n return syncResolveImports.call(this, syncResolve);\n }\n );\n }\n\n const resolveImportsHandler = memoizedSyncResolve.get(syncResolve)!;\n const actionHandlers = {\n ...baseHandlers,\n ...customHandlers,\n resolveImports: resolveImportsHandler,\n };\n const actionContext = getActionContext(resolveImportsHandler, customHandlers);\n\n const entrypoint = Entrypoint.createRoot(\n services,\n options.filename,\n ['__wywPreval'],\n originalCode\n );\n\n if (entrypoint.ignored) {\n return {\n code: originalCode,\n sourceMap: options.inputSourceMap,\n };\n }\n\n const workflowAction = entrypoint.createAction(\n 'workflow',\n undefined,\n null,\n actionContext\n );\n\n try {\n const result = syncActionRunner(workflowAction, actionHandlers);\n\n entrypoint.log('%s is ready', entrypoint.name);\n\n return result;\n } catch (err) {\n entrypoint.log('Unhandled error %O', err);\n\n if (\n isFeatureEnabled(pluginOptions.features, 'softErrors', options.filename)\n ) {\n // eslint-disable-next-line no-console\n console.error(`Error during transform of ${entrypoint.name}:`, err);\n\n return {\n code: originalCode,\n sourceMap: options.inputSourceMap,\n };\n }\n\n throw err;\n }\n}\n\nexport async function transform(\n partialServices: PartialServices,\n originalCode: string,\n asyncResolve: (\n what: string,\n importer: string,\n stack: string[]\n ) => Promise<string | null>,\n customHandlers: Partial<AllHandlers<'sync'>> = {}\n): Promise<Result> {\n const { options } = partialServices;\n const pluginOptions = loadWywOptions(options.pluginOptions);\n const services = withDefaultServices({\n ...partialServices,\n options: {\n ...options,\n pluginOptions,\n },\n });\n\n if (\n !isFeatureEnabled(pluginOptions.features, 'globalCache', options.filename)\n ) {\n // If global cache is disabled, we need to create a new cache for each file\n services.cache = new TransformCacheCollection();\n }\n\n /*\n * This method can be run simultaneously for multiple files.\n * A shared cache is accessible for all runs, but each run has its own queue\n * to maintain the correct processing order. The cache stores the outcome\n * of tree-shaking, and if the result is already stored in the cache\n * but the \"only\" option has changed, the file will be re-processed using\n * the combined \"only\" option.\n */\n if (!memoizedAsyncResolve.has(asyncResolve)) {\n const resolveImports = function resolveImports(\n this: IResolveImportsAction\n ) {\n return asyncResolveImports.call(this, asyncResolve);\n };\n\n memoizedAsyncResolve.set(asyncResolve, resolveImports);\n }\n\n const resolveImportsHandler = memoizedAsyncResolve.get(asyncResolve)!;\n const actionHandlers = {\n ...baseHandlers,\n ...customHandlers,\n resolveImports: resolveImportsHandler,\n };\n const actionContext = getActionContext(resolveImportsHandler, customHandlers);\n\n const entrypoint = Entrypoint.createRoot(\n services,\n options.filename,\n ['__wywPreval'],\n originalCode\n );\n\n if (entrypoint.ignored) {\n return {\n code: originalCode,\n sourceMap: options.inputSourceMap,\n };\n }\n\n const workflowAction = entrypoint.createAction(\n 'workflow',\n undefined,\n null,\n actionContext\n );\n\n try {\n const result = await asyncActionRunner(workflowAction, actionHandlers);\n\n entrypoint.log('%s is ready', entrypoint.name);\n\n return result;\n } catch (err) {\n entrypoint.log('Unhandled error %O', err);\n\n if (\n isFeatureEnabled(pluginOptions.features, 'softErrors', options.filename)\n ) {\n // eslint-disable-next-line no-console\n console.error(`Error during transform of ${entrypoint.name}:`, err);\n\n return {\n code: originalCode,\n sourceMap: options.inputSourceMap,\n };\n }\n\n throw err;\n }\n}\n"],"mappings":";;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAIA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAIA,IAAAO,oBAAA,GAAAP,OAAA;AAzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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MpB,cAAc,GAAG;IACrB,GAAGC,wBAAY;IACf,GAAG5B,cAAc;IACjBwB,cAAc,EAAEzB;EAClB,CAAC;EACD,MAAMS,aAAa,GAAGV,gBAAgB,CAACC,qBAAqB,EAAEC,cAAc,CAAC;EAE7E,MAAM6B,UAAU,GAAGC,sBAAU,CAACC,UAAU,CACtCf,QAAQ,EACRH,OAAO,CAACO,QAAQ,EAChB,CAAC,aAAa,CAAC,EACfT,YACF,CAAC;EAED,IAAIkB,UAAU,CAACG,OAAO,EAAE;IACtB,OAAO;MACLC,IAAI,EAAEtB,YAAY;MAClBuB,SAAS,EAAErB,OAAO,CAACsB;IACrB,CAAC;EACH;EAEA,MAAMC,cAAc,GAAGP,UAAU,CAACQ,YAAY,CAC5C,UAAU,EACVC,SAAS,EACT,IAAI,EACJ9B,aACF,CAAC;EAED,IAAI;IACF,MAAM+B,MAAM,GAAG,MAAM,IAAAU,+BAAiB,EAACb,cAAc,EAAET,cAAc,CAAC;IAEtEE,UAAU,CAACY,GAAG,CAAC,aAAa,EAAEZ,UAAU,CAACa,IAAI,CAAC;IAE9C,OAAOH,MAAM;EACf,CAAC,CAAC,OAAOI,GAAG,EAAE;IACZd,UAAU,CAACY,GAAG,CAAC,oBAAoB,EAAEE,GAAG,CAAC;IAEzC,IACE,IAAAzB,wBAAgB,EAACJ,aAAa,CAACK,QAAQ,EAAE,YAAY,EAAEN,OAAO,CAACO,QAAQ,CAAC,EACxE;MACA;MACAwB,OAAO,CAACC,KAAK,CAAC,6BAA6BhB,UAAU,CAACa,IAAI,GAAG,EAAEC,GAAG,CAAC;MAEnE,OAAO;QACLV,IAAI,EAAEtB,YAAY;QAClBuB,SAAS,EAAErB,OAAO,CAACsB;MACrB,CAAC;IACH;IAEA,MAAMQ,GAAG;EACX;AACF","ignoreList":[]}
|
package/lib/types.js
DELETED
package/lib/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { BabelFile, PluginPass } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport type { File, Program } from '@babel/types';\nimport type { RawSourceMap } from 'source-map';\n\nimport type { BaseProcessor } from '@wyw-in-js/processor-utils';\nimport type {\n Debugger,\n Replacement,\n Rules,\n StrictOptions,\n} from '@wyw-in-js/shared';\n\nimport type {\n WYWTransformMetadata,\n WYWTransformResultMetadata,\n} from './utils/TransformMetadata';\nimport type { WYWTransformDiagnostic } from './utils/TransformDiagnostics';\n\nexport type PluginOptions = StrictOptions & {\n configFile?: string | false;\n stage?: Stage;\n};\n\nexport type ParentEntrypoint = {\n evaluated: boolean;\n log: Debugger;\n name: string;\n parents: ParentEntrypoint[];\n seqId: number;\n};\n\nexport type Dependencies = string[];\n\nexport interface IPluginState extends PluginPass {\n dependencies: Dependencies;\n file: BabelFile & {\n metadata: {\n wywInJS?: WYWTransformMetadata;\n };\n };\n processors: BaseProcessor[];\n}\n\nexport interface ITransformFileResult {\n code: string;\n metadata: WYWTransformMetadata | null;\n}\n\nexport type Stage = 'preeval' | 'collect';\n\nexport type Result = {\n code: string;\n cssSourceMapText?: string;\n cssText?: string;\n dependencies?: string[];\n diagnostics?: WYWTransformDiagnostic[];\n metadata?: WYWTransformResultMetadata;\n replacements?: Replacement[];\n rules?: Rules;\n sourceMap?: RawSourceMap | null;\n};\n\nexport type Options = {\n filename: string;\n inputSourceMap?: RawSourceMap;\n keepComments?: boolean | RegExp;\n outputFilename?: string;\n pluginOptions?: Partial<PluginOptions>;\n prefixer?: boolean;\n preprocessor?: Preprocessor;\n root?: string;\n};\n\nexport type PreprocessorFn = (selector: string, cssText: string) => string;\nexport type Preprocessor = 'none' | 'stylis' | PreprocessorFn | void;\n\nexport type MissedBabelCoreTypes = {\n File: new (\n options: { filename: string },\n file: { ast: File; code: string }\n ) => { path: NodePath<Program> };\n};\n\nexport type JSONValue =\n | null\n | string\n | number\n | boolean\n | JSONObject\n | JSONArray;\n\nexport interface JSONObject {\n [x: string]: JSONValue;\n}\n\nexport type JSONArray = Array<JSONValue>;\n\nexport type Serializable = JSONValue;\n\n/**\n * CSS-related types\n */\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isOnActionStartArgs = exports.isOnActionFinishArgs = exports.EventEmitter = void 0;
|
|
7
|
-
const isOnActionStartArgs = args => {
|
|
8
|
-
return args[0] === 'start';
|
|
9
|
-
};
|
|
10
|
-
exports.isOnActionStartArgs = isOnActionStartArgs;
|
|
11
|
-
const isOnActionFinishArgs = args => {
|
|
12
|
-
return args[0] === 'finish' || args[0] === 'fail';
|
|
13
|
-
};
|
|
14
|
-
exports.isOnActionFinishArgs = isOnActionFinishArgs;
|
|
15
|
-
class EventEmitter {
|
|
16
|
-
static dummy = new EventEmitter(() => {}, () => 0, () => {});
|
|
17
|
-
constructor(onEvent, onAction, onEntrypointEvent) {
|
|
18
|
-
this.onEvent = onEvent;
|
|
19
|
-
this.onAction = onAction;
|
|
20
|
-
this.onEntrypointEvent = onEntrypointEvent;
|
|
21
|
-
}
|
|
22
|
-
action(actonType, idx, entrypointRef, fn) {
|
|
23
|
-
const id = this.onAction('start', performance.now(), actonType, idx, entrypointRef);
|
|
24
|
-
try {
|
|
25
|
-
const result = fn();
|
|
26
|
-
if (result instanceof Promise) {
|
|
27
|
-
result.then(() => this.onAction('finish', performance.now(), id, true), e => this.onAction('fail', performance.now(), id, true, e));
|
|
28
|
-
} else {
|
|
29
|
-
this.onAction('finish', performance.now(), id, false);
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
} catch (e) {
|
|
33
|
-
this.onAction('fail', performance.now(), id, false, e);
|
|
34
|
-
throw e;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
entrypointEvent(sequenceId, event) {
|
|
38
|
-
this.onEntrypointEvent(sequenceId, performance.now(), event);
|
|
39
|
-
}
|
|
40
|
-
perf(method, fn) {
|
|
41
|
-
const labels = {
|
|
42
|
-
method
|
|
43
|
-
};
|
|
44
|
-
this.onEvent(labels, 'start');
|
|
45
|
-
const result = fn();
|
|
46
|
-
if (result instanceof Promise) {
|
|
47
|
-
result.then(() => this.onEvent(labels, 'finish'), () => this.onEvent(labels, 'finish'));
|
|
48
|
-
} else {
|
|
49
|
-
this.onEvent(labels, 'finish');
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
single(labels) {
|
|
54
|
-
this.onEvent({
|
|
55
|
-
...labels,
|
|
56
|
-
datetime: new Date()
|
|
57
|
-
}, 'single');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.EventEmitter = EventEmitter;
|
|
61
|
-
//# sourceMappingURL=EventEmitter.js.map
|