@wyw-in-js/transform 1.0.8 → 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 -28
- 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 -79
- package/esm/transform/generators/workflow.js.map +1 -1
- package/esm/transform/helpers/loadWywOptions.js +154 -73
- 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 +10 -0
- package/esm/utils/TransformDiagnostics.js.map +1 -0
- package/esm/utils/TransformMetadata.js +28 -10
- 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 +7 -8
- package/types/index.js +24 -77
- 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 +6 -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 -37
- package/types/transform/helpers/loadWywOptions.js +95 -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 +4 -24
- package/types/types.js +1 -2
- package/types/utils/EventEmitter.js +3 -9
- package/types/utils/ShakerMetadata.js +1 -5
- package/types/utils/TransformDiagnostics.d.ts +9 -0
- package/types/utils/TransformDiagnostics.js +11 -0
- package/types/utils/TransformMetadata.d.ts +22 -4
- package/types/utils/TransformMetadata.js +23 -8
- 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 -257
- 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 -90
- package/lib/transform/generators/workflow.js.map +0 -1
- package/lib/transform/helpers/loadWywOptions.js +0 -87
- 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/TransformMetadata.js +0 -19
- 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 -20
- 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,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const getExports_1 = require("./getExports");
|
|
6
|
-
const processEntrypoint_1 = require("./processEntrypoint");
|
|
7
|
-
const processImports_1 = require("./processImports");
|
|
8
|
-
const transform_1 = require("./transform");
|
|
1
|
+
import { getExports } from './getExports';
|
|
2
|
+
import { processEntrypointAsync } from './processEntrypoint';
|
|
3
|
+
import { processImports } from './processImports';
|
|
4
|
+
import { transform } from './transform';
|
|
9
5
|
// eslint-disable-next-line require-yield
|
|
10
6
|
function* emptyHandler() {
|
|
11
7
|
throw new Error(`Handler for ${this.type} is not implemented`);
|
|
12
8
|
}
|
|
13
|
-
|
|
9
|
+
export const baseProcessingHandlers = {
|
|
14
10
|
collect: (emptyHandler),
|
|
15
11
|
evalFile: (emptyHandler),
|
|
12
|
+
explodeReexports: (emptyHandler),
|
|
16
13
|
extract: (emptyHandler),
|
|
17
14
|
workflow: (emptyHandler),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
transform: transform_1.transform,
|
|
15
|
+
getExports,
|
|
16
|
+
processEntrypoint: processEntrypointAsync,
|
|
17
|
+
processImports,
|
|
18
|
+
transform,
|
|
23
19
|
};
|
|
@@ -1,56 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.collect = collect;
|
|
4
|
-
const buildOptions_1 = require("../../options/buildOptions");
|
|
5
|
-
const collector_1 = require("../../plugins/collector");
|
|
6
|
-
const TransformMetadata_1 = require("../../utils/TransformMetadata");
|
|
1
|
+
import { oxcShaker } from '../../shaker';
|
|
2
|
+
import { collectOxcRuntime } from '../../utils/collectOxcRuntime';
|
|
7
3
|
/**
|
|
8
4
|
* Parses the specified file, finds tags, applies run-time replacements,
|
|
9
5
|
* removes dead code.
|
|
10
6
|
*/
|
|
11
7
|
// eslint-disable-next-line require-yield
|
|
12
|
-
function* collect() {
|
|
13
|
-
const {
|
|
8
|
+
export function* collect() {
|
|
9
|
+
const { options } = this.services;
|
|
14
10
|
const { valueCache } = this.data;
|
|
15
11
|
const { entrypoint } = this;
|
|
16
12
|
const { loadedAndParsed, name } = entrypoint;
|
|
13
|
+
const preevalResult = entrypoint.getPreevalResult();
|
|
17
14
|
if (loadedAndParsed.evaluator === 'ignored') {
|
|
18
15
|
throw new Error('entrypoint was ignored');
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
collector_1.filename,
|
|
23
|
-
{
|
|
24
|
-
...options.pluginOptions,
|
|
25
|
-
values: valueCache,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
];
|
|
29
|
-
const transformConfig = (0, buildOptions_1.buildOptions)({
|
|
30
|
-
envName: 'wyw-in-js',
|
|
31
|
-
plugins: transformPlugins,
|
|
32
|
-
sourceMaps: true,
|
|
33
|
-
sourceFileName: name,
|
|
34
|
-
inputSourceMap: options.inputSourceMap,
|
|
35
|
-
root: options.root,
|
|
36
|
-
ast: true,
|
|
37
|
-
babelrc: false,
|
|
38
|
-
configFile: false,
|
|
39
|
-
sourceType: 'unambiguous',
|
|
40
|
-
});
|
|
41
|
-
const result = babel.transformFromAstSync(loadedAndParsed.ast, loadedAndParsed.code, {
|
|
42
|
-
...transformConfig,
|
|
43
|
-
cwd: options.root,
|
|
44
|
-
filename: name,
|
|
45
|
-
});
|
|
46
|
-
if (!result || !result.ast?.program) {
|
|
47
|
-
throw new Error('Babel transform failed');
|
|
17
|
+
if (loadedAndParsed.evaluator !== oxcShaker) {
|
|
18
|
+
throw new Error(`[wyw-in-js] ${name} matched a legacy evaluator. The Oxc runtime path supports only the default Oxc evaluator.`);
|
|
48
19
|
}
|
|
49
|
-
const
|
|
20
|
+
const result = collectOxcRuntime(loadedAndParsed.code, name, options.root ?? process.cwd(), {
|
|
21
|
+
...options.pluginOptions,
|
|
22
|
+
preserveSideEffectImportLocals: new Set(preevalResult?.staticSideEffectImportLocals ?? []),
|
|
23
|
+
}, valueCache, options.inputSourceMap);
|
|
50
24
|
return {
|
|
51
|
-
ast:
|
|
25
|
+
ast: null,
|
|
52
26
|
code: result.code,
|
|
53
27
|
map: result.map,
|
|
54
|
-
metadata:
|
|
28
|
+
metadata: result.metadata,
|
|
55
29
|
};
|
|
56
30
|
}
|
|
@@ -1,48 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.stylisGlobalPlugin = void 0;
|
|
37
|
-
exports.transformUrl = transformUrl;
|
|
38
|
-
exports.createStylisUrlReplacePlugin = createStylisUrlReplacePlugin;
|
|
39
|
-
exports.createKeyframeSuffixerPlugin = createKeyframeSuffixerPlugin;
|
|
40
|
-
exports.createStylisPreprocessor = createStylisPreprocessor;
|
|
41
1
|
/* eslint-disable no-continue */
|
|
42
|
-
|
|
43
|
-
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { compile, middleware, prefixer, serialize, stringify, tokenize, COMMENT, RULESET, KEYFRAMES, DECLARATION, } from 'stylis';
|
|
44
4
|
const POSIX_SEP = path.posix.sep;
|
|
45
|
-
function transformUrl(url, outputFilename, sourceFilename, platformPath = path) {
|
|
5
|
+
export function transformUrl(url, outputFilename, sourceFilename, platformPath = path) {
|
|
46
6
|
// Replace asset path with new path relative to the output CSS
|
|
47
7
|
const relative = platformPath.relative(platformPath.dirname(outputFilename),
|
|
48
8
|
// Get the absolute path to the asset from the path relative to the JS file
|
|
@@ -76,15 +36,15 @@ function propsIsString(props) {
|
|
|
76
36
|
return (typeof props === 'string' || throwIfNotProd('props', props, 'string[]'));
|
|
77
37
|
}
|
|
78
38
|
const isDeclaration = (element) => {
|
|
79
|
-
return (element.type ===
|
|
39
|
+
return (element.type === DECLARATION &&
|
|
80
40
|
propsIsString(element.props) &&
|
|
81
41
|
childrenIsString(element.children));
|
|
82
42
|
};
|
|
83
43
|
const isKeyframes = (element) => {
|
|
84
|
-
return element.type ===
|
|
44
|
+
return element.type === KEYFRAMES && propsAreStrings(element.props);
|
|
85
45
|
};
|
|
86
46
|
const isRuleset = (element) => {
|
|
87
|
-
return element.type ===
|
|
47
|
+
return element.type === RULESET && propsAreStrings(element.props);
|
|
88
48
|
};
|
|
89
49
|
function nonMediaParent(element) {
|
|
90
50
|
let { parent } = element;
|
|
@@ -99,7 +59,7 @@ function nonMediaParent(element) {
|
|
|
99
59
|
/**
|
|
100
60
|
* Stylis plugin that mimics :global() selector behavior from Stylis v3.
|
|
101
61
|
*/
|
|
102
|
-
const stylisGlobalPlugin = (element) => {
|
|
62
|
+
export const stylisGlobalPlugin = (element) => {
|
|
103
63
|
function getGlobalSelectorModifiers(el) {
|
|
104
64
|
const parent = nonMediaParent(el);
|
|
105
65
|
const value = getOriginalElementValue(el);
|
|
@@ -133,7 +93,7 @@ const stylisGlobalPlugin = (element) => {
|
|
|
133
93
|
return cssSelector;
|
|
134
94
|
}
|
|
135
95
|
const { includeBaseSelector, includeSpaceDelimiter } = getGlobalSelectorModifiers(element);
|
|
136
|
-
const tokens =
|
|
96
|
+
const tokens = tokenize(cssSelector);
|
|
137
97
|
let selector = '';
|
|
138
98
|
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
139
99
|
const token = tokens[i];
|
|
@@ -166,8 +126,7 @@ const stylisGlobalPlugin = (element) => {
|
|
|
166
126
|
}),
|
|
167
127
|
});
|
|
168
128
|
};
|
|
169
|
-
|
|
170
|
-
function createStylisUrlReplacePlugin(filename, outputFilename) {
|
|
129
|
+
export function createStylisUrlReplacePlugin(filename, outputFilename) {
|
|
171
130
|
return (element) => {
|
|
172
131
|
if (element.type === 'decl' && outputFilename) {
|
|
173
132
|
// When writing to a file, we need to adjust the relative paths inside url(..) expressions.
|
|
@@ -177,7 +136,7 @@ function createStylisUrlReplacePlugin(filename, outputFilename) {
|
|
|
177
136
|
}
|
|
178
137
|
};
|
|
179
138
|
}
|
|
180
|
-
function createKeyframeSuffixerPlugin() {
|
|
139
|
+
export function createKeyframeSuffixerPlugin() {
|
|
181
140
|
const prefixes = ['webkit', 'moz', 'ms', 'o', ''].map((i) => i ? `-${i}-` : '');
|
|
182
141
|
const getPrefixedProp = (prop) => prefixes.map((prefix) => `${prefix}${prop}`);
|
|
183
142
|
const buildPropsRegexp = (prop, isAtRule) => {
|
|
@@ -253,7 +212,7 @@ function createKeyframeSuffixerPlugin() {
|
|
|
253
212
|
if (animationPropsSet.has(element.props)) {
|
|
254
213
|
const scopedKeyframes = getDefinedKeyframes(element);
|
|
255
214
|
const patch = Object.fromEntries(keys.map((key) => {
|
|
256
|
-
const tokens =
|
|
215
|
+
const tokens = tokenize(element[key]);
|
|
257
216
|
let result = '';
|
|
258
217
|
for (let i = 0; i < tokens.length; i += 1) {
|
|
259
218
|
if (tokens[i] === ':' &&
|
|
@@ -402,12 +361,12 @@ function createStylisDisplayNormalizationPlugin() {
|
|
|
402
361
|
}
|
|
403
362
|
function createStylisStringifier(keepComments) {
|
|
404
363
|
if (!keepComments) {
|
|
405
|
-
return
|
|
364
|
+
return stringify;
|
|
406
365
|
}
|
|
407
366
|
const keepAllComments = keepComments === true;
|
|
408
367
|
const keepCommentsFilter = keepComments instanceof RegExp ? keepComments : null;
|
|
409
368
|
return (element, index, children, callback) => {
|
|
410
|
-
if (element.type ===
|
|
369
|
+
if (element.type === COMMENT) {
|
|
411
370
|
if (!keepAllComments && keepCommentsFilter) {
|
|
412
371
|
const commentValue = typeof element.children === 'string'
|
|
413
372
|
? element.children
|
|
@@ -419,20 +378,20 @@ function createStylisStringifier(keepComments) {
|
|
|
419
378
|
}
|
|
420
379
|
return element.value;
|
|
421
380
|
}
|
|
422
|
-
return
|
|
381
|
+
return stringify(element, index, children, callback);
|
|
423
382
|
};
|
|
424
383
|
}
|
|
425
|
-
function createStylisPreprocessor(options) {
|
|
384
|
+
export function createStylisPreprocessor(options) {
|
|
426
385
|
const stringifier = createStylisStringifier(options.keepComments);
|
|
427
386
|
function stylisPreprocess(selector, text) {
|
|
428
|
-
const compiled =
|
|
429
|
-
return
|
|
387
|
+
const compiled = compile(`${selector} {${text}}\n`);
|
|
388
|
+
return serialize(compiled, middleware([
|
|
430
389
|
createStylisUrlReplacePlugin(options.filename, options.outputFilename),
|
|
431
|
-
|
|
390
|
+
stylisGlobalPlugin,
|
|
432
391
|
options.prefixer === false
|
|
433
392
|
? null
|
|
434
393
|
: createStylisDisplayNormalizationPlugin(),
|
|
435
|
-
options.prefixer === false ? null :
|
|
394
|
+
options.prefixer === false ? null : prefixer,
|
|
436
395
|
createKeyframeSuffixerPlugin(),
|
|
437
396
|
stringifier,
|
|
438
397
|
].filter(isMiddleware)));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AsyncScenarioForAction, IEvalAction } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Executes the code prepared in previous steps within the current `Entrypoint`.
|
|
4
4
|
* Returns all exports that were requested in `only`.
|
|
5
5
|
*/
|
|
6
|
-
export declare function evalFile(this: IEvalAction):
|
|
6
|
+
export declare function evalFile(this: IEvalAction): AsyncScenarioForAction<IEvalAction>;
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.evalFile = evalFile;
|
|
7
|
-
const evaluators_1 = __importDefault(require("../../evaluators"));
|
|
8
|
-
const hasWywPreval_1 = __importDefault(require("../../utils/hasWywPreval"));
|
|
9
|
-
const UnprocessedEntrypointError_1 = require("../actions/UnprocessedEntrypointError");
|
|
10
|
-
const wrap = (fn) => {
|
|
11
|
-
try {
|
|
12
|
-
return fn();
|
|
13
|
-
}
|
|
14
|
-
catch (e) {
|
|
15
|
-
return e;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
1
|
+
import evaluate from '../../evaluators';
|
|
2
|
+
import { isUnprocessedEntrypointError } from '../actions/UnprocessedEntrypointError';
|
|
18
3
|
/**
|
|
19
4
|
* Executes the code prepared in previous steps within the current `Entrypoint`.
|
|
20
5
|
* Returns all exports that were requested in `only`.
|
|
21
6
|
*/
|
|
22
7
|
// eslint-disable-next-line require-yield
|
|
23
|
-
function* evalFile() {
|
|
8
|
+
export async function* evalFile() {
|
|
24
9
|
const { entrypoint } = this;
|
|
25
10
|
const { log } = entrypoint;
|
|
11
|
+
const preevalResult = entrypoint.getPreevalResult();
|
|
12
|
+
if (preevalResult && (preevalResult.dependencyNames?.length ?? 0) === 0) {
|
|
13
|
+
const valueCache = new Map();
|
|
14
|
+
preevalResult.staticValueCache?.forEach((value, key) => {
|
|
15
|
+
valueCache.set(key, value);
|
|
16
|
+
});
|
|
17
|
+
const dependencies = [...new Set(preevalResult.staticDependencies ?? [])];
|
|
18
|
+
log(`<< skipped evaluate __wywPreval %O`, valueCache);
|
|
19
|
+
return [valueCache, dependencies];
|
|
20
|
+
}
|
|
26
21
|
log(`>> evaluate __wywPreval`);
|
|
27
22
|
let evaluated;
|
|
28
23
|
while (evaluated === undefined) {
|
|
29
24
|
try {
|
|
30
|
-
|
|
25
|
+
// eslint-disable-next-line no-await-in-loop
|
|
26
|
+
evaluated = await this.services.eventEmitter.perf('transform:evalFile', () => evaluate(this.services, entrypoint));
|
|
31
27
|
}
|
|
32
28
|
catch (e) {
|
|
33
|
-
if (
|
|
29
|
+
if (isUnprocessedEntrypointError(e)) {
|
|
34
30
|
entrypoint.log('Evaluation has been aborted because one if the required files is not processed. Schedule reprocessing and repeat evaluation.');
|
|
35
31
|
yield ['processEntrypoint', e.entrypoint, undefined];
|
|
36
32
|
}
|
|
@@ -39,17 +35,19 @@ function* evalFile() {
|
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
? evaluated.value.__wywPreval
|
|
44
|
-
: undefined;
|
|
45
|
-
if (!wywPreval) {
|
|
38
|
+
if (!evaluated.values) {
|
|
46
39
|
return null;
|
|
47
40
|
}
|
|
48
|
-
const valueCache =
|
|
49
|
-
|
|
50
|
-
const value = wrap(lazyValue);
|
|
41
|
+
const valueCache = evaluated.values;
|
|
42
|
+
preevalResult?.staticValueCache?.forEach((value, key) => {
|
|
51
43
|
valueCache.set(key, value);
|
|
52
44
|
});
|
|
45
|
+
const dependencies = [
|
|
46
|
+
...new Set([
|
|
47
|
+
...evaluated.dependencies,
|
|
48
|
+
...(preevalResult?.staticDependencies ?? []),
|
|
49
|
+
]),
|
|
50
|
+
];
|
|
53
51
|
log(`<< evaluated __wywPreval %O`, valueCache);
|
|
54
|
-
return [valueCache,
|
|
52
|
+
return [valueCache, dependencies];
|
|
55
53
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.extract = extract;
|
|
4
|
-
const source_map_1 = require("source-map");
|
|
5
|
-
const createStylisPreprocessor_1 = require("./createStylisPreprocessor");
|
|
1
|
+
import { SourceMapGenerator } from 'source-map';
|
|
2
|
+
import { createStylisPreprocessor } from './createStylisPreprocessor';
|
|
6
3
|
function extractCssFromAst(rules, originalCode, options) {
|
|
7
4
|
const mappings = [];
|
|
8
5
|
let cssText = '';
|
|
@@ -18,7 +15,7 @@ function extractCssFromAst(rules, originalCode, options) {
|
|
|
18
15
|
break;
|
|
19
16
|
case 'stylis':
|
|
20
17
|
default:
|
|
21
|
-
preprocessor =
|
|
18
|
+
preprocessor = createStylisPreprocessor(options);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
Object.keys(rules).forEach((selector, index) => {
|
|
@@ -45,7 +42,7 @@ function extractCssFromAst(rules, originalCode, options) {
|
|
|
45
42
|
rules,
|
|
46
43
|
get cssSourceMapText() {
|
|
47
44
|
if (mappings?.length) {
|
|
48
|
-
const generator = new
|
|
45
|
+
const generator = new SourceMapGenerator({
|
|
49
46
|
file: options.filename.replace(/\.js$/, '.css'),
|
|
50
47
|
});
|
|
51
48
|
mappings.forEach((mapping) => generator.addMapping({ ...mapping, source: options.filename }));
|
|
@@ -60,7 +57,7 @@ function extractCssFromAst(rules, originalCode, options) {
|
|
|
60
57
|
* Extract artifacts (e.g. CSS) from processors
|
|
61
58
|
*/
|
|
62
59
|
// eslint-disable-next-line require-yield
|
|
63
|
-
function* extract() {
|
|
60
|
+
export function* extract() {
|
|
64
61
|
const { options } = this.services;
|
|
65
62
|
const { entrypoint } = this;
|
|
66
63
|
const { processors } = this.data;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const collectExportsAndImports_1 = require("../../utils/collectExportsAndImports");
|
|
6
|
-
function findExportsInImports(entrypoint, imports) {
|
|
1
|
+
/* eslint-disable no-continue */
|
|
2
|
+
import { collectOxcExportsAndImports } from '../../utils/collectOxcExportsAndImports';
|
|
3
|
+
import { oxcShaker } from '../../shaker';
|
|
4
|
+
export function findExportsInImports(entrypoint, imports) {
|
|
7
5
|
const results = [];
|
|
8
6
|
for (const imp of imports) {
|
|
9
7
|
const { resolved } = imp;
|
|
@@ -12,7 +10,6 @@ function findExportsInImports(entrypoint, imports) {
|
|
|
12
10
|
}
|
|
13
11
|
const newEntrypoint = entrypoint.createChild(resolved, []);
|
|
14
12
|
if (newEntrypoint === 'loop') {
|
|
15
|
-
// eslint-disable-next-line no-continue
|
|
16
13
|
continue;
|
|
17
14
|
}
|
|
18
15
|
results.push({
|
|
@@ -22,48 +19,44 @@ function findExportsInImports(entrypoint, imports) {
|
|
|
22
19
|
}
|
|
23
20
|
return results;
|
|
24
21
|
}
|
|
25
|
-
function* getExports() {
|
|
22
|
+
export function* getExports() {
|
|
26
23
|
const { entrypoint, services: { cache }, } = this;
|
|
27
24
|
const { loadedAndParsed } = entrypoint;
|
|
28
|
-
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
entrypoint.log(`get exports from %s`, entrypoint.name);
|
|
25
|
+
entrypoint.log('get exports from %s', entrypoint.name);
|
|
32
26
|
if (cache.has('exports', entrypoint.name)) {
|
|
33
27
|
return cache.get('exports', entrypoint.name);
|
|
34
28
|
}
|
|
35
29
|
let withWildcardReexport = [];
|
|
36
30
|
const result = [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
withWildcardReexport = reexports.filter((e) => e.exported === '*');
|
|
49
|
-
},
|
|
31
|
+
if (loadedAndParsed.evaluator !== oxcShaker) {
|
|
32
|
+
throw new Error(`[wyw-in-js] ${entrypoint.name} matched a legacy evaluator. The Oxc runtime path supports only the default Oxc evaluator.`);
|
|
33
|
+
}
|
|
34
|
+
const { exports, reexports } = collectOxcExportsAndImports(loadedAndParsed.code, loadedAndParsed.evalConfig.filename ?? entrypoint.name);
|
|
35
|
+
Object.keys(exports).forEach((token) => {
|
|
36
|
+
result.push(token);
|
|
37
|
+
});
|
|
38
|
+
reexports.forEach((reexport) => {
|
|
39
|
+
if (reexport.exported !== '*') {
|
|
40
|
+
result.push(reexport.exported);
|
|
41
|
+
}
|
|
50
42
|
});
|
|
43
|
+
withWildcardReexport = reexports.filter((reexport) => reexport.exported === '*');
|
|
51
44
|
if (withWildcardReexport.length) {
|
|
52
45
|
const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {
|
|
53
|
-
imports: new Map(withWildcardReexport.map((
|
|
46
|
+
imports: new Map(withWildcardReexport.map((item) => [item.source, []])),
|
|
54
47
|
});
|
|
55
48
|
const dependencyFilenames = resolvedImports.flatMap((dependency) => dependency.resolved ? [dependency.resolved] : []);
|
|
56
49
|
const importedEntrypoints = findExportsInImports(entrypoint, resolvedImports);
|
|
57
50
|
for (const importedEntrypoint of importedEntrypoints) {
|
|
58
|
-
const
|
|
59
|
-
result.push(...
|
|
51
|
+
const childExports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
|
|
52
|
+
result.push(...childExports);
|
|
60
53
|
}
|
|
61
54
|
cache.add('exports', entrypoint.name, result);
|
|
62
55
|
cache.setCacheDependencies('exports', entrypoint.name, dependencyFilenames);
|
|
63
|
-
entrypoint.log(
|
|
56
|
+
entrypoint.log('exports: %o', result);
|
|
64
57
|
return result;
|
|
65
58
|
}
|
|
66
|
-
entrypoint.log(
|
|
59
|
+
entrypoint.log('exports: %o', result);
|
|
67
60
|
cache.add('exports', entrypoint.name, result);
|
|
68
61
|
return result;
|
|
69
62
|
}
|
|
@@ -7,9 +7,9 @@ export declare const baseHandlers: {
|
|
|
7
7
|
evalFile: typeof evalFile;
|
|
8
8
|
extract: typeof extract;
|
|
9
9
|
workflow: typeof workflow;
|
|
10
|
-
explodeReexports:
|
|
10
|
+
explodeReexports: (this: import("../types").IExplodeReexportsAction) => import("../types").SyncScenarioForAction<import("../types").IExplodeReexportsAction>;
|
|
11
11
|
getExports: typeof import("./getExports").getExports;
|
|
12
|
-
processEntrypoint: typeof import("./processEntrypoint").
|
|
12
|
+
processEntrypoint: typeof import("./processEntrypoint").processEntrypointAsync;
|
|
13
13
|
processImports: typeof import("./processImports").processImports;
|
|
14
14
|
transform: typeof import("./transform").transform;
|
|
15
15
|
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
evalFile: evalFile_1.evalFile,
|
|
13
|
-
extract: extract_1.extract,
|
|
14
|
-
workflow: workflow_1.workflow,
|
|
1
|
+
import { baseProcessingHandlers } from './baseProcessingHandlers';
|
|
2
|
+
import { collect } from './collect';
|
|
3
|
+
import { evalFile } from './evalFile';
|
|
4
|
+
import { extract } from './extract';
|
|
5
|
+
import { workflow } from './workflow';
|
|
6
|
+
export const baseHandlers = {
|
|
7
|
+
...baseProcessingHandlers,
|
|
8
|
+
collect,
|
|
9
|
+
evalFile,
|
|
10
|
+
extract,
|
|
11
|
+
workflow,
|
|
15
12
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IProcessEntrypointAction, SyncScenarioForAction } from '../types';
|
|
1
|
+
import type { AsyncScenarioForAction, IProcessEntrypointAction, SyncScenarioForAction } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* The first stage of processing an entrypoint.
|
|
4
4
|
* This stage is responsible for:
|
|
5
|
-
* - scheduling the explodeReexports action
|
|
6
5
|
* - scheduling the transform action
|
|
7
6
|
* - rescheduling itself if the entrypoint is superseded
|
|
8
7
|
*/
|
|
9
8
|
export declare function processEntrypoint(this: IProcessEntrypointAction): SyncScenarioForAction<IProcessEntrypointAction>;
|
|
9
|
+
export declare function processEntrypointAsync(this: IProcessEntrypointAction): AsyncScenarioForAction<IProcessEntrypointAction>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
3
2
|
if (value !== null && value !== void 0) {
|
|
4
3
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -51,43 +50,29 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
50
|
var e = new Error(message);
|
|
52
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
53
52
|
});
|
|
54
|
-
|
|
55
|
-
exports.processEntrypoint = processEntrypoint;
|
|
56
|
-
const shaker_1 = require("../../shaker");
|
|
57
|
-
const AbortError_1 = require("../actions/AbortError");
|
|
58
|
-
const barrelManifest_1 = require("../barrelManifest");
|
|
59
|
-
const shouldSkipExplodeReexports = (action) => {
|
|
60
|
-
const { loadedAndParsed, only } = action.entrypoint;
|
|
61
|
-
if (only.length === 1 && only[0] === '__wywPreval') {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (loadedAndParsed.evaluator !== shaker_1.shaker || !loadedAndParsed.ast) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
const barrelAnalysis = (0, barrelManifest_1.analyzeBarrelFile)(loadedAndParsed.ast);
|
|
68
|
-
return barrelAnalysis.kind === 'barrel' && barrelAnalysis.complete;
|
|
69
|
-
};
|
|
53
|
+
import { isAborted } from '../actions/AbortError';
|
|
70
54
|
/**
|
|
71
55
|
* The first stage of processing an entrypoint.
|
|
72
56
|
* This stage is responsible for:
|
|
73
|
-
* - scheduling the explodeReexports action
|
|
74
57
|
* - scheduling the transform action
|
|
75
58
|
* - rescheduling itself if the entrypoint is superseded
|
|
76
59
|
*/
|
|
77
|
-
function* processEntrypoint() {
|
|
60
|
+
export function* processEntrypoint() {
|
|
78
61
|
const { only, log } = this.entrypoint;
|
|
79
62
|
log('start processing (only: %o)', only);
|
|
63
|
+
if (this.entrypoint.transformed) {
|
|
64
|
+
log('already transformed, skip processing');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.entrypoint.isProcessing) {
|
|
68
|
+
log('already processing, skip duplicate request');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
80
71
|
this.entrypoint.beginProcessing();
|
|
81
72
|
try {
|
|
82
73
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
83
74
|
try {
|
|
84
75
|
const abortSignal = __addDisposableResource(env_1, this.createAbortSignal(), false);
|
|
85
|
-
if (shouldSkipExplodeReexports(this)) {
|
|
86
|
-
log('skip explodeReexports for pure barrel');
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
yield ['explodeReexports', this.entrypoint, undefined, abortSignal];
|
|
90
|
-
}
|
|
91
76
|
const result = yield* this.getNext('transform', this.entrypoint, undefined, abortSignal);
|
|
92
77
|
this.entrypoint.assertNotSuperseded();
|
|
93
78
|
this.entrypoint.setTransformResult(result);
|
|
@@ -108,7 +93,56 @@ function* processEntrypoint() {
|
|
|
108
93
|
}
|
|
109
94
|
}
|
|
110
95
|
catch (e) {
|
|
111
|
-
if (
|
|
96
|
+
if (isAborted(e) && this.entrypoint.supersededWith) {
|
|
97
|
+
log('processing aborted, schedule the next attempt');
|
|
98
|
+
yield* this.getNext('processEntrypoint', this.entrypoint.supersededWith, undefined, null);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
log(`Unhandled error: %O`, e);
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this.entrypoint.endProcessing();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function* processEntrypointAsync() {
|
|
109
|
+
const { only, log } = this.entrypoint;
|
|
110
|
+
log('start processing (only: %o)', only);
|
|
111
|
+
if (this.entrypoint.transformed) {
|
|
112
|
+
log('already transformed, skip processing');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (this.entrypoint.isProcessing) {
|
|
116
|
+
log('already processing, wait for existing request');
|
|
117
|
+
await this.entrypoint.waitForProcessing();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.entrypoint.beginProcessing();
|
|
121
|
+
try {
|
|
122
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
123
|
+
try {
|
|
124
|
+
const abortSignal = __addDisposableResource(env_2, this.createAbortSignal(), false);
|
|
125
|
+
const result = yield* this.getNext('transform', this.entrypoint, undefined, abortSignal);
|
|
126
|
+
this.entrypoint.assertNotSuperseded();
|
|
127
|
+
this.entrypoint.setTransformResult(result);
|
|
128
|
+
const supersededWith = this.entrypoint.applyDeferredSupersede();
|
|
129
|
+
if (supersededWith) {
|
|
130
|
+
log('processing finished, deferred only detected; schedule next attempt');
|
|
131
|
+
yield* this.getNext('processEntrypoint', supersededWith, undefined, null);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
log('entrypoint processing finished');
|
|
135
|
+
}
|
|
136
|
+
catch (e_2) {
|
|
137
|
+
env_2.error = e_2;
|
|
138
|
+
env_2.hasError = true;
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
__disposeResources(env_2);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
if (isAborted(e) && this.entrypoint.supersededWith) {
|
|
112
146
|
log('processing aborted, schedule the next attempt');
|
|
113
147
|
yield* this.getNext('processEntrypoint', this.entrypoint.supersededWith, undefined, null);
|
|
114
148
|
return;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { IProcessImportsAction, SyncScenarioForAction } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Creates new entrypoints and emits processEntrypoint for each resolved import
|
|
4
|
-
*/
|
|
5
2
|
export declare function processImports(this: IProcessImportsAction): SyncScenarioForAction<IProcessImportsAction>;
|