@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AA2BA,SAAS,sBAAsB;AAsF/B,MAAM,eAAe,YAAiC;CACpD,UAAU,IAAI,KAAK;CACnB;CACD;AAED,MAAM,UAAU,UACd,CAAC,CAAC,SACF,OAAO,UAAU,YACjB,UAAU,SACV,OAAQ,MAA6B,SAAS;AAEhD,MAAM,iBAAiB,MAAY,MAAc,UAA6B;CAC5E,MAAM,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI;CACtC,KAAK,KAAK;CACV,MAAM,SAAS,KAAK,SAAS,eAAe,KAAK,OAAO;CACxD,OAAO,KAAK;CACb;AAED,MAAM,wBAAwB,SAC5B,KAAK,SAAS,YAAY,KAAK,QAAQ,KAAK;AAE9C,MAAM,uBAAuB,QAAoC;AAC/D,KAAI,IAAI,SAAS,cAAc;AAC7B,SAAO,IAAI;;AAGb,KAAI,IAAI,SAAS,aAAa,OAAO,IAAI,UAAU,UAAU;AAC3D,SAAO,IAAI;;AAGb,QAAO;;AAGT,MAAM,0BAA0B,SAA0C;AACxE,KAAI,KAAK,UAAU;AACjB,SAAO,KAA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,YAAY,EAAE;EACd,gBAAgB,IAAI,KAAK;EACzB,QAAQ;GACN,aAAa,EAAE;GACf,SAAS,EAAE;GACX,SAAS,EAAE;GACX,YAAY;GACZ,WAAW,EAAE;GACd;EACF;AAED,0BAAyB,SAAS,MAAM;AACxC,OACE,SACA;EAAE,KAAK;EAAW,QAAQ;EAAM,OAAO;EAAW,EAClD,OACA,cACD;AAED,QAAO,MAAM,OAAO;;AAGtB,OAAO,SAAS,4BACd,MACA,UACmB;CACnB,MAAM,SAAS,eAAe,UAAU,MAAM,cAAc;AAE5D,QAAO,uCACL,OAAO,SACP,MACA,OAAO,OAAO,gBACf","names":[],"sources":["../../src/utils/collectOxcExportsAndImports.ts"],"version":3,"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define,no-restricted-syntax,no-continue */\n\nimport type {\n AssignmentExpression,\n BindingPattern,\n CallExpression,\n Class as OxcClass,\n ExportAllDeclaration,\n ExportDefaultDeclaration,\n ExportNamedDeclaration,\n ExportSpecifier,\n Expression,\n ExpressionStatement,\n Function as OxcFunction,\n ImportDeclaration,\n ImportExpression,\n ImportSpecifier,\n MemberExpression,\n ModuleExportName,\n Node,\n ObjectExpression,\n ObjectPattern,\n Program,\n PropertyKey,\n VariableDeclarator,\n} from 'oxc-parser';\n\nimport { parseOxcCached } from './parseOxc';\n\ntype ImportKind = 'cjs' | 'dynamic' | 'esm';\n\nexport type OxcLocal = {\n code: string;\n end: number;\n name?: string;\n start: number;\n};\n\nexport type OxcCollectedImport = {\n imported: string | 'default' | '*' | 'side-effect';\n local: OxcLocal;\n source: string;\n type: ImportKind;\n};\n\nexport type OxcCollectedExport = {\n exported: string | 'default' | '*';\n local: OxcLocal;\n};\n\nexport type OxcCollectedReexport = {\n exported: string | 'default' | '*';\n imported: string | 'default' | '*';\n local: OxcLocal;\n source: string;\n};\n\nexport type OxcCollectedState = {\n deadExports: string[];\n exports: Record<string | 'default' | '*', OxcLocal>;\n imports: OxcCollectedImport[];\n isEsModule: boolean;\n reexports: OxcCollectedReexport[];\n};\n\ntype VisitMode = 'all' | 'importsOnly';\n\ntype NamespaceBinding = {\n kind: 'namespace';\n local: OxcLocal;\n name: string;\n source: string;\n type: ImportKind;\n used: boolean;\n};\n\ntype LocalBinding = {\n kind: 'local';\n name: string;\n};\n\ntype Binding = LocalBinding | NamespaceBinding;\n\ntype Scope = {\n bindings: Map<string, Binding>;\n parent: Scope | null;\n};\n\ntype ChildContext = {\n key: string;\n parent: Node | null;\n};\n\ntype VisitContext = ChildContext & {\n scope: Scope;\n};\n\ntype AnyNode = Node & Record<string, unknown>;\n\ntype OxcIdentifier = Node & { name: string; type: 'Identifier' };\n\ntype Destructed = {\n as: Node;\n what: string | '*';\n};\n\ntype AnalyzerState = {\n code: string;\n namespaces: NamespaceBinding[];\n requireSources: Map<string, string>;\n result: OxcCollectedState;\n};\n\nconst createScope = (parent: Scope | null): Scope => ({\n bindings: new Map(),\n parent,\n});\n\nconst isNode = (value: unknown): value is Node =>\n !!value &&\n typeof value === 'object' &&\n 'type' in value &&\n typeof (value as { type?: unknown }).type === 'string';\n\nconst localFromNode = (node: Node, code: string, name?: string): OxcLocal => ({\n code: code.slice(node.start, node.end),\n end: node.end,\n name: name ?? (node.type === 'Identifier' ? node.name : undefined),\n start: node.start,\n});\n\nconst nameFromModuleExport = (node: ModuleExportName): string =>\n node.type === 'Literal' ? node.value : node.name;\n\nconst nameFromPropertyKey = (key: PropertyKey): string | null => {\n if (key.type === 'Identifier') {\n return key.name;\n }\n\n if (key.type === 'Literal' && typeof key.value === 'string') {\n return key.value;\n }\n\n return null;\n};\n\nconst nameFromMemberProperty = (node: MemberExpression): string | null => {\n if (node.computed) {\n return node.property.type === 'Literal' &&\n typeof node.property.value === 'string'\n ? node.property.value\n : null;\n }\n\n return node.property.type === 'Identifier' ? node.property.name : null;\n};\n\nconst defineBinding = (scope: Scope, binding: Binding): void => {\n scope.bindings.set(binding.name, binding);\n};\n\nconst lookupBinding = (scope: Scope, name: string): Binding | null => {\n let current: Scope | null = scope;\n while (current) {\n const binding = current.bindings.get(name);\n if (binding) {\n return binding;\n }\n\n current = current.parent;\n }\n\n return null;\n};\n\nconst collectBindingNames = (pattern: BindingPattern): string[] => {\n if (pattern.type === 'Identifier') {\n return [pattern.name];\n }\n\n if (pattern.type === 'AssignmentPattern') {\n return collectBindingNames(pattern.left);\n }\n\n if (pattern.type === 'ObjectPattern') {\n return pattern.properties.flatMap((property) =>\n property.type === 'RestElement'\n ? collectBindingNames(property.argument)\n : collectBindingNames(property.value)\n );\n }\n\n if (pattern.type === 'ArrayPattern') {\n return pattern.elements.flatMap((element) =>\n element ? collectBindingLikeNames(element) : []\n );\n }\n\n return [];\n};\n\nconst collectBindingLikeNames = (node: Node): string[] => {\n if (node.type === 'RestElement') {\n return collectBindingLikeNames(node.argument);\n }\n\n if (node.type === 'TSParameterProperty') {\n return collectBindingLikeNames(node.parameter);\n }\n\n return collectBindingNames(node as BindingPattern);\n};\n\nconst declareLocalPattern = (scope: Scope, pattern: BindingPattern): void => {\n collectBindingNames(pattern).forEach((name) =>\n defineBinding(scope, { kind: 'local', name })\n );\n};\n\nconst declareLocalBindingLike = (scope: Scope, node: Node): void => {\n collectBindingLikeNames(node).forEach((name) =>\n defineBinding(scope, { kind: 'local', name })\n );\n};\n\nconst isTypeOnlyImport = (\n declaration: ImportDeclaration,\n specifier?: ImportSpecifier\n): boolean =>\n declaration.importKind === 'type' || specifier?.importKind === 'type';\n\nconst isTypeOnlyExport = (\n declaration:\n | ExportAllDeclaration\n | ExportDefaultDeclaration\n | ExportNamedDeclaration\n | ExportSpecifier\n): boolean => 'exportKind' in declaration && declaration.exportKind === 'type';\n\nconst addImport = (\n state: AnalyzerState,\n item: Omit<OxcCollectedImport, 'local'> & { local: Node; name?: string }\n): void => {\n state.result.imports.push({\n imported: item.imported,\n local: localFromNode(item.local, state.code, item.name),\n source: item.source,\n type: item.type,\n });\n};\n\nconst addExport = (\n state: AnalyzerState,\n exported: string | 'default' | '*',\n local: Node,\n name?: string\n): void => {\n const { result } = state;\n result.exports[exported] = localFromNode(local, state.code, name);\n};\n\nconst addReexport = (\n state: AnalyzerState,\n item: Omit<OxcCollectedReexport, 'local'> & { local: Node }\n): void => {\n state.result.reexports.push({\n exported: item.exported,\n imported: item.imported,\n local: localFromNode(item.local, state.code),\n source: item.source,\n });\n};\n\nconst collectDestructed = (pattern: ObjectPattern): Destructed[] =>\n pattern.properties.flatMap((property) => {\n if (property.type === 'RestElement') {\n return collectBindingNames(property.argument).map(() => ({\n as: property.argument,\n what: '*' as const,\n }));\n }\n\n const firstKey = nameFromPropertyKey(property.key);\n if (!firstKey) {\n return [];\n }\n\n if (property.value.type === 'ObjectPattern') {\n return collectBindingNames(property.value).map(() => ({\n as: property.value,\n what: firstKey,\n }));\n }\n\n if (property.value.type === 'ArrayPattern') {\n return collectBindingNames(property.value).map(() => ({\n as: property.value,\n what: firstKey,\n }));\n }\n\n if (property.value.type === 'AssignmentPattern') {\n return collectBindingNames(property.value.left).map(() => ({\n as: property.value,\n what: firstKey,\n }));\n }\n\n return collectBindingNames(property.value).map(() => ({\n as: property.value,\n what: firstKey,\n }));\n });\n\nconst getStringConstant = (expression: Expression): string | null => {\n if (expression.type === 'Literal' && typeof expression.value === 'string') {\n return expression.value;\n }\n\n if (\n expression.type === 'TemplateLiteral' &&\n expression.expressions.length === 0\n ) {\n return expression.quasis[0]?.value.cooked ?? null;\n }\n\n if (expression.type === 'BinaryExpression' && expression.operator === '+') {\n const left = getStringConstant(expression.left);\n const right = getStringConstant(expression.right);\n return left === null || right === null ? null : left + right;\n }\n\n if (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'MemberExpression' &&\n nameFromMemberProperty(expression.callee) === 'concat'\n ) {\n const base = getStringConstant(expression.callee.object);\n if (base === null) {\n return null;\n }\n\n const parts = expression.arguments.map((arg) =>\n arg.type === 'SpreadElement' ? null : getStringConstant(arg)\n );\n if (parts.some((part) => part === null)) {\n return null;\n }\n\n return [base, ...(parts as string[])].join('');\n }\n\n if (\n expression.type === 'TSAsExpression' ||\n expression.type === 'TSSatisfiesExpression' ||\n expression.type === 'TSNonNullExpression' ||\n expression.type === 'TSTypeAssertion' ||\n expression.type === 'ParenthesizedExpression'\n ) {\n return getStringConstant(expression.expression);\n }\n\n return null;\n};\n\nconst isRequireCall = (node: Node, scope: Scope): boolean =>\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'require' &&\n lookupBinding(scope, 'require') === null;\n\nconst sourceFromRequireLike = (\n node: Node,\n scope: Scope,\n state: AnalyzerState\n): string | null => {\n if (isRequireCall(node, scope)) {\n const call = node as CallExpression;\n const [sourceArg] = call.arguments;\n if (!sourceArg || sourceArg.type === 'SpreadElement') {\n return null;\n }\n\n return getStringConstant(sourceArg);\n }\n\n if (node.type === 'Identifier') {\n return state.requireSources.get(node.name) ?? null;\n }\n\n if (node.type === 'CallExpression') {\n for (const arg of node.arguments) {\n if (arg.type === 'SpreadElement') {\n continue;\n }\n\n const source = sourceFromRequireLike(arg, scope, state);\n if (source) {\n return source;\n }\n }\n }\n\n return null;\n};\n\nconst sourceFromDirectRequireBinding = (\n node: Node,\n scope: Scope,\n state: AnalyzerState\n): string | null => {\n if (isRequireCall(node, scope)) {\n const call = node as CallExpression;\n const [sourceArg] = call.arguments;\n if (!sourceArg || sourceArg.type === 'SpreadElement') {\n return null;\n }\n\n return getStringConstant(sourceArg);\n }\n\n if (node.type === 'Identifier') {\n return state.requireSources.get(node.name) ?? null;\n }\n\n return null;\n};\n\nconst sourceFromRequireSyntax = (node: Node): string | null => {\n if (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'require'\n ) {\n const [sourceArg] = node.arguments;\n return sourceArg && sourceArg.type !== 'SpreadElement'\n ? getStringConstant(sourceArg)\n : null;\n }\n\n if (node.type === 'CallExpression') {\n for (const arg of node.arguments) {\n if (arg.type === 'SpreadElement') {\n continue;\n }\n\n const source = sourceFromRequireSyntax(arg);\n if (source) {\n return source;\n }\n }\n }\n\n return null;\n};\n\nconst sourceFromImportedMember = (\n node: Node,\n scope: Scope,\n state: AnalyzerState\n): { imported: string | '*' | 'default'; source: string } | null => {\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n const source = sourceFromRequireLike(node.object, scope, state);\n const imported = nameFromMemberProperty(node);\n if (!source || !imported) {\n return null;\n }\n\n return { imported, source };\n};\n\nconst isExportsObject = (node: Node): boolean =>\n node.type === 'Identifier' && node.name === 'exports';\n\nconst getExportAssignmentName = (node: Node): string | 'default' | null => {\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n if (isExportsObject(node.object)) {\n return nameFromMemberProperty(node);\n }\n\n if (\n node.object.type === 'Identifier' &&\n node.object.name === 'module' &&\n nameFromMemberProperty(node) === 'exports'\n ) {\n return 'default';\n }\n\n return null;\n};\n\nconst getCalleeName = (node: Expression): string | null => {\n if (node.type === 'Identifier') {\n return node.name;\n }\n\n if (node.type === 'MemberExpression') {\n return nameFromMemberProperty(node);\n }\n\n return null;\n};\n\nconst getObjectProperty = (\n objectExpression: ObjectExpression,\n name: string\n): Node | null => {\n for (const property of objectExpression.properties) {\n if (property.type === 'SpreadElement') {\n continue;\n }\n\n if (nameFromPropertyKey(property.key) === name) {\n return property.value;\n }\n }\n\n return null;\n};\n\nconst getReturnedExpression = (node: Node): Expression | null => {\n if (node.type === 'ArrowFunctionExpression') {\n return node.body.type === 'BlockStatement'\n ? getReturnedExpression(node.body)\n : node.body;\n }\n\n if (\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n return node.body ? getReturnedExpression(node.body) : null;\n }\n\n if (node.type === 'BlockStatement') {\n const returned = node.body.find(\n (statement) => statement.type === 'ReturnStatement'\n );\n return returned?.type === 'ReturnStatement' ? returned.argument : null;\n }\n\n return null;\n};\n\nconst collectFromImportDeclaration = (\n node: ImportDeclaration,\n scope: Scope,\n state: AnalyzerState\n): void => {\n if (isTypeOnlyImport(node)) {\n return;\n }\n\n const source = node.source.value;\n if (node.specifiers.length === 0) {\n addImport(state, {\n imported: 'side-effect',\n local: node,\n source,\n type: 'esm',\n });\n return;\n }\n\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === 'ImportSpecifier' &&\n isTypeOnlyImport(node, specifier)\n ) {\n return;\n }\n\n if (specifier.type === 'ImportNamespaceSpecifier') {\n const binding: NamespaceBinding = {\n kind: 'namespace',\n local: localFromNode(specifier.local, state.code, specifier.local.name),\n name: specifier.local.name,\n source,\n type: 'esm',\n used: false,\n };\n defineBinding(scope, binding);\n state.namespaces.push(binding);\n return;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n defineBinding(scope, { kind: 'local', name: specifier.local.name });\n addImport(state, {\n imported: 'default',\n local: specifier.local,\n name: specifier.local.name,\n source,\n type: 'esm',\n });\n return;\n }\n\n defineBinding(scope, { kind: 'local', name: specifier.local.name });\n addImport(state, {\n imported: nameFromModuleExport(specifier.imported),\n local: specifier.local,\n name: specifier.local.name,\n source,\n type: 'esm',\n });\n });\n};\n\nconst collectExportedDeclaration = (\n declaration: ExportNamedDeclaration['declaration'],\n state: AnalyzerState\n): void => {\n if (!declaration) {\n return;\n }\n\n if (declaration.type === 'VariableDeclaration') {\n declaration.declarations.forEach((declarator) => {\n exportFromVariableDeclarator(declarator, state);\n });\n return;\n }\n\n if (declaration.type === 'TSEnumDeclaration') {\n addExport(state, declaration.id.name, declaration.id, declaration.id.name);\n return;\n }\n\n if (\n declaration.type === 'FunctionDeclaration' ||\n declaration.type === 'ClassDeclaration'\n ) {\n const { id } = declaration as OxcFunction | OxcClass;\n if (id) {\n addExport(state, id.name, id, id.name);\n }\n }\n};\n\nconst collectFromExportNamedDeclaration = (\n node: ExportNamedDeclaration,\n state: AnalyzerState\n): void => {\n if (isTypeOnlyExport(node)) {\n return;\n }\n\n const source = node.source?.value;\n node.specifiers.forEach((specifier) => {\n if (isTypeOnlyExport(specifier)) {\n return;\n }\n\n const exported = nameFromModuleExport(specifier.exported);\n const imported = nameFromModuleExport(specifier.local);\n\n if (source) {\n addReexport(state, {\n exported,\n imported,\n local: specifier,\n source,\n });\n return;\n }\n\n addExport(state, exported, specifier.local, imported);\n });\n\n collectExportedDeclaration(node.declaration, state);\n};\n\nconst collectFromExportAllDeclaration = (\n node: ExportAllDeclaration,\n state: AnalyzerState\n): void => {\n if (isTypeOnlyExport(node)) {\n return;\n }\n\n addReexport(state, {\n exported: node.exported ? nameFromModuleExport(node.exported) : '*',\n imported: '*',\n local: node,\n source: node.source.value,\n });\n};\n\nconst collectFromExportDefaultDeclaration = (\n node: ExportDefaultDeclaration,\n state: AnalyzerState\n): void => {\n if (isTypeOnlyExport(node)) {\n return;\n }\n\n addExport(state, 'default', node.declaration);\n};\n\nconst exportFromVariableDeclarator = (\n node: VariableDeclarator,\n state: AnalyzerState\n): void => {\n if (node.id.type === 'Identifier') {\n addExport(state, node.id.name, node.init ?? node.id, node.id.name);\n return;\n }\n\n if (node.id.type === 'ObjectPattern') {\n collectDestructed(node.id).forEach((destructed) => {\n if (destructed.as.type === 'Identifier') {\n addExport(\n state,\n destructed.as.name,\n node.init ?? destructed.as,\n destructed.as.name\n );\n }\n });\n return;\n }\n\n if (node.id.type === 'ArrayPattern') {\n collectBindingNames(node.id).forEach((name) =>\n addExport(state, name, node.init ?? node.id, name)\n );\n }\n};\n\nconst collectFromImportExpression = (\n node: ImportExpression,\n parent: Node | null,\n state: AnalyzerState\n): void => {\n const source = getStringConstant(node.source);\n if (!source) {\n return;\n }\n\n let container = parent;\n let awaited = false;\n if (container?.type === 'AwaitExpression') {\n awaited = true;\n container = findParentContainer(container);\n }\n\n if (container?.type === 'VariableDeclarator') {\n importFromVariableDeclarator(container, awaited, source, 'dynamic', state);\n }\n};\n\nconst collectFromWywDynamicImport = (\n node: CallExpression,\n parent: Node | null,\n state: AnalyzerState\n): void => {\n if (\n node.callee.type !== 'Identifier' ||\n node.callee.name !== '__wyw_dynamic_import'\n ) {\n return;\n }\n\n const [sourceArg] = node.arguments;\n if (!sourceArg || sourceArg.type === 'SpreadElement') {\n return;\n }\n\n const source = getStringConstant(sourceArg);\n if (!source) {\n return;\n }\n\n let container = parent;\n let awaited = false;\n if (container?.type === 'AwaitExpression') {\n awaited = true;\n container = findParentContainer(container);\n }\n\n if (container?.type === 'VariableDeclarator') {\n importFromVariableDeclarator(container, awaited, source, 'dynamic', state);\n return;\n }\n\n addImport(state, {\n imported: '*',\n local: node,\n source,\n type: 'dynamic',\n });\n};\n\nconst parentContainers = new WeakMap<Node, Node | null>();\n\nconst findParentContainer = (node: Node): Node | null =>\n parentContainers.get(node) ?? null;\n\nconst importFromVariableDeclarator = (\n node: VariableDeclarator,\n isSync: boolean,\n source: string,\n type: ImportKind,\n state: AnalyzerState\n): void => {\n if (node.id.type === 'Identifier') {\n addImport(state, {\n imported: '*',\n local: node.id,\n name: node.id.name,\n source,\n type,\n });\n return;\n }\n\n if (!isSync || node.id.type !== 'ObjectPattern') {\n return;\n }\n\n collectDestructed(node.id).forEach((destructed) => {\n addImport(state, {\n imported: destructed.what,\n local: destructed.as,\n source,\n type,\n });\n });\n};\n\nconst collectFromRequireDeclarator = (\n node: VariableDeclarator,\n scope: Scope,\n state: AnalyzerState\n): boolean => {\n if (!node.init) {\n return false;\n }\n\n const memberImport = sourceFromImportedMember(node.init, scope, state);\n if (memberImport) {\n if (node.id.type === 'Identifier') {\n defineBinding(scope, { kind: 'local', name: node.id.name });\n addImport(state, {\n imported: memberImport.imported,\n local: node.id,\n name: node.id.name,\n source: memberImport.source,\n type: 'cjs',\n });\n }\n return true;\n }\n\n const source = sourceFromRequireLike(node.init, scope, state);\n if (!source) {\n return false;\n }\n\n if (node.id.type === 'Identifier') {\n state.requireSources.set(node.id.name, source);\n const binding: NamespaceBinding = {\n kind: 'namespace',\n local: localFromNode(node.id, state.code, node.id.name),\n name: node.id.name,\n source,\n type: 'cjs',\n used: false,\n };\n defineBinding(scope, binding);\n state.namespaces.push(binding);\n return true;\n }\n\n if (node.id.type === 'ObjectPattern') {\n collectDestructed(node.id).forEach((destructed) => {\n addImport(state, {\n imported: destructed.what,\n local: destructed.as,\n source,\n type: 'cjs',\n });\n });\n return true;\n }\n\n return false;\n};\n\nconst collectFromNamespaceReference = (\n node: OxcIdentifier,\n parent: Node | null,\n ctx: VisitContext,\n state: AnalyzerState\n): void => {\n const binding = lookupBinding(ctx.scope, node.name);\n if (!binding || binding.kind !== 'namespace') {\n return;\n }\n\n if (isBindingPosition(node, parent, ctx.key)) {\n return;\n }\n\n if (isTypeNode(parent)) {\n return;\n }\n\n binding.used = true;\n\n if (parent?.type === 'MemberExpression' && parent.object === node) {\n const imported = nameFromMemberProperty(parent);\n addImport(state, {\n imported: imported ?? '*',\n local: imported ? parent : node,\n source: binding.source,\n type: binding.type,\n });\n return;\n }\n\n if (parent?.type === 'VariableDeclarator' && parent.init === node) {\n if (parent.id.type === 'ObjectPattern') {\n collectDestructed(parent.id).forEach((destructed) => {\n addImport(state, {\n imported: destructed.what,\n local: destructed.as,\n source: binding.source,\n type: binding.type,\n });\n });\n return;\n }\n }\n\n addImport(state, {\n imported: '*',\n local: node,\n name: node.name,\n source: binding.source,\n type: binding.type,\n });\n};\n\nconst isBindingPosition = (\n node: Node,\n parent: Node | null,\n key: string\n): boolean => {\n if (!parent) {\n return false;\n }\n\n if (parent.type === 'ImportNamespaceSpecifier' && key === 'local') {\n return true;\n }\n\n if (\n (parent.type === 'ImportSpecifier' ||\n parent.type === 'ImportDefaultSpecifier') &&\n key === 'local'\n ) {\n return true;\n }\n\n if (parent.type === 'VariableDeclarator' && key === 'id') {\n return true;\n }\n\n if (parent.type === 'FunctionDeclaration' && key === 'id') {\n return true;\n }\n\n if (parent.type === 'ClassDeclaration' && key === 'id') {\n return true;\n }\n\n if (\n parent.type === 'Property' &&\n parent.value === node &&\n parent.key !== node\n ) {\n return true;\n }\n\n return false;\n};\n\nconst isTypeNode = (node: Node | null): boolean =>\n !!node && (node.type.startsWith('TS') || node.type.startsWith('JSDoc'));\n\nconst collectFromAssignmentExpression = (\n node: AssignmentExpression,\n ctx: VisitContext,\n state: AnalyzerState\n): void => {\n if (node.operator !== '=') {\n return;\n }\n\n const exported = getExportAssignmentName(node.left);\n if (!exported || exported === '__esModule') {\n return;\n }\n\n const imported = sourceFromImportedMember(node.right, ctx.scope, state);\n if (imported) {\n addReexport(state, {\n exported,\n imported: imported.imported,\n local: node,\n source: imported.source,\n });\n return;\n }\n\n const directRequireSource = sourceFromDirectRequireBinding(\n node.right,\n ctx.scope,\n state\n );\n if (directRequireSource) {\n addReexport(state, {\n exported,\n imported: '*',\n local: node,\n source: directRequireSource,\n });\n return;\n }\n\n addExport(state, exported, node.right);\n};\n\nconst collectFromRequireExpressionStatement = (\n node: ExpressionStatement,\n scope: Scope,\n state: AnalyzerState\n): void => {\n const source = sourceFromDirectRequireBinding(node.expression, scope, state);\n if (!source) {\n return;\n }\n\n addImport(state, {\n imported: 'side-effect',\n local: node.expression,\n source,\n type: 'cjs',\n });\n};\n\nconst collectFromDefineProperty = (\n node: CallExpression,\n ctx: VisitContext,\n state: AnalyzerState\n): boolean => {\n if (\n node.callee.type !== 'MemberExpression' ||\n node.callee.object.type !== 'Identifier' ||\n node.callee.object.name !== 'Object' ||\n nameFromMemberProperty(node.callee) !== 'defineProperty'\n ) {\n return false;\n }\n\n const [target, nameArg, descriptor] = node.arguments;\n if (\n !target ||\n !nameArg ||\n !descriptor ||\n target.type === 'SpreadElement' ||\n nameArg.type === 'SpreadElement' ||\n descriptor.type === 'SpreadElement' ||\n !isExportsObject(target)\n ) {\n return false;\n }\n\n const exported = getStringConstant(nameArg);\n if (!exported || exported === '__esModule') {\n return true;\n }\n\n if (descriptor.type === 'ObjectExpression') {\n const getter = getObjectProperty(descriptor, 'get');\n const returned = getter ? getReturnedExpression(getter) : null;\n const imported = returned\n ? sourceFromImportedMember(returned, ctx.scope, state)\n : null;\n\n if (imported) {\n addReexport(state, {\n exported,\n imported: imported.imported,\n local: node,\n source: imported.source,\n });\n return true;\n }\n\n const directRequireSource = returned\n ? sourceFromDirectRequireBinding(returned, ctx.scope, state)\n : null;\n if (directRequireSource) {\n addReexport(state, {\n exported,\n imported: '*',\n local: node,\n source: directRequireSource,\n });\n return true;\n }\n\n if (returned) {\n addExport(state, exported, returned);\n return true;\n }\n }\n\n addExport(state, exported, node);\n return true;\n};\n\nconst collectFromHelperCall = (\n node: CallExpression,\n ctx: VisitContext,\n state: AnalyzerState\n): void => {\n const callee = getCalleeName(node.callee);\n if (!callee) {\n return;\n }\n\n if (collectFromDefineProperty(node, ctx, state)) {\n return;\n }\n\n if (callee === 'forEach' && node.callee.type === 'MemberExpression') {\n const { object } = node.callee;\n if (\n object.type === 'CallExpression' &&\n object.callee.type === 'MemberExpression' &&\n object.callee.object.type === 'Identifier' &&\n object.callee.object.name === 'Object' &&\n nameFromMemberProperty(object.callee) === 'keys'\n ) {\n const [keysArg] = object.arguments;\n if (keysArg && keysArg.type !== 'SpreadElement') {\n const source = sourceFromRequireLike(keysArg, ctx.scope, state);\n if (source) {\n addReexport(state, {\n exported: '*',\n imported: '*',\n local: node,\n source,\n });\n }\n }\n }\n return;\n }\n\n if (\n /(?:^|_)exportStar$/i.test(callee) ||\n callee === '_export_star' ||\n callee === '__reExport'\n ) {\n for (const arg of node.arguments) {\n if (arg.type === 'SpreadElement') {\n continue;\n }\n\n const source = sourceFromRequireLike(arg, ctx.scope, state);\n if (source) {\n addReexport(state, {\n exported: '*',\n imported: '*',\n local: node,\n source,\n });\n return;\n }\n }\n }\n\n if (callee === '__export' || callee === '_export') {\n const [firstArg, secondArg] = node.arguments;\n if (firstArg && firstArg.type !== 'SpreadElement') {\n const source = sourceFromRequireLike(firstArg, ctx.scope, state);\n if (source) {\n addReexport(state, {\n exported: '*',\n imported: '*',\n local: node,\n source,\n });\n return;\n }\n }\n\n if (secondArg?.type === 'ObjectExpression') {\n secondArg.properties.forEach((property) => {\n if (property.type === 'SpreadElement') {\n return;\n }\n\n const exported = nameFromPropertyKey(property.key);\n const returned = getReturnedExpression(property.value);\n if (!exported || !returned) {\n return;\n }\n\n const imported = sourceFromImportedMember(returned, ctx.scope, state);\n if (imported) {\n addReexport(state, {\n exported,\n imported: imported.imported,\n local: property,\n source: imported.source,\n });\n return;\n }\n\n const directRequireSource = sourceFromDirectRequireBinding(\n returned,\n ctx.scope,\n state\n );\n if (directRequireSource) {\n addReexport(state, {\n exported,\n imported: '*',\n local: property,\n source: directRequireSource,\n });\n return;\n }\n\n addExport(state, exported, returned);\n });\n }\n }\n};\n\nconst visit = (\n node: Node,\n ctx: VisitContext,\n state: AnalyzerState,\n mode: VisitMode = 'all'\n): void => {\n if (mode === 'all') {\n parentContainers.set(node, ctx.parent);\n }\n\n let { scope } = ctx;\n if (\n node.type === 'Program' ||\n node.type === 'BlockStatement' ||\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n scope = createScope(ctx.scope);\n }\n\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n node.params.forEach((param) => declareLocalBindingLike(scope, param));\n }\n\n if (node.type === 'ImportDeclaration') {\n collectFromImportDeclaration(node, scope, state);\n } else if (mode === 'all' && node.type === 'ExportNamedDeclaration') {\n collectFromExportNamedDeclaration(node, state);\n } else if (mode === 'all' && node.type === 'ExportAllDeclaration') {\n collectFromExportAllDeclaration(node, state);\n } else if (mode === 'all' && node.type === 'ExportDefaultDeclaration') {\n collectFromExportDefaultDeclaration(node, state);\n } else if (node.type === 'VariableDeclarator') {\n if (!collectFromRequireDeclarator(node, scope, state)) {\n declareLocalPattern(scope, node.id);\n }\n } else if (mode === 'all' && node.type === 'ImportExpression') {\n collectFromImportExpression(node, ctx.parent, state);\n } else if (mode === 'all' && node.type === 'CallExpression') {\n collectFromWywDynamicImport(node, ctx.parent, state);\n collectFromHelperCall(node, { ...ctx, scope }, state);\n } else if (mode === 'all' && node.type === 'ExpressionStatement') {\n collectFromRequireExpressionStatement(node, scope, state);\n } else if (mode === 'all' && node.type === 'AssignmentExpression') {\n collectFromAssignmentExpression(node, { ...ctx, scope }, state);\n } else if (node.type === 'Identifier') {\n collectFromNamespaceReference(node, ctx.parent, { ...ctx, scope }, state);\n }\n\n for (const child of getChildren(node)) {\n visit(child.node, { key: child.key, parent: node, scope }, state, mode);\n }\n};\n\nconst getChildren = (node: Node): { key: string; node: Node }[] => {\n const result: { key: string; node: Node }[] = [];\n const record = node as AnyNode;\n\n Object.keys(record).forEach((key) => {\n if (key === 'type' || key === 'start' || key === 'end' || key === 'range') {\n return;\n }\n\n const value = record[key];\n if (isNode(value)) {\n result.push({ key, node: value });\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (isNode(item)) {\n result.push({ key, node: item });\n }\n });\n }\n });\n\n return result;\n};\n\nconst precollectRequireSources = (node: Node, state: AnalyzerState): void => {\n if (node.type === 'VariableDeclarator' && node.id.type === 'Identifier') {\n const source = node.init ? sourceFromRequireSyntax(node.init) : null;\n if (source) {\n state.requireSources.set(node.id.name, source);\n }\n }\n\n getChildren(node).forEach((child) =>\n precollectRequireSources(child.node, state)\n );\n};\n\nconst addUnusedNamespaceSideEffects = (state: AnalyzerState): void => {\n state.namespaces.forEach((binding) => {\n if (!binding.used) {\n state.result.imports.push({\n imported: 'side-effect',\n local: binding.local,\n source: binding.source,\n type: binding.type,\n });\n }\n });\n};\n\nexport function collectOxcExportsAndImportsFromProgram(\n program: Program,\n code: string,\n isEsModule: boolean\n): OxcCollectedState {\n const rootScope = createScope(null);\n const state: AnalyzerState = {\n code,\n namespaces: [],\n requireSources: new Map(),\n result: {\n deadExports: [],\n exports: {},\n imports: [],\n isEsModule,\n reexports: [],\n },\n };\n\n precollectRequireSources(program, state);\n visit(\n program,\n { key: 'program', parent: null, scope: rootScope },\n state,\n 'all'\n );\n addUnusedNamespaceSideEffects(state);\n\n return state.result;\n}\n\nexport function collectOxcProcessorImportsFromProgram(\n program: Program,\n code: string\n): OxcCollectedImport[] {\n const rootScope = createScope(null);\n const state: AnalyzerState = {\n code,\n namespaces: [],\n requireSources: new Map(),\n result: {\n deadExports: [],\n exports: {},\n imports: [],\n isEsModule: true,\n reexports: [],\n },\n };\n\n precollectRequireSources(program, state);\n visit(\n program,\n { key: 'program', parent: null, scope: rootScope },\n state,\n 'importsOnly'\n );\n\n return state.result.imports;\n}\n\nexport function collectOxcExportsAndImports(\n code: string,\n filename: string\n): OxcCollectedState {\n const parsed = parseOxcCached(filename, code, 'unambiguous');\n\n return collectOxcExportsAndImportsFromProgram(\n parsed.program,\n code,\n parsed.module.hasModuleSyntax\n );\n}\n"],"file":"collectOxcExportsAndImports.js"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { parseSync } from "oxc-parser";
|
|
4
|
+
import { SourceMapGenerator } from "source-map";
|
|
5
|
+
import { applyOxcProcessors } from "./applyOxcProcessors.js";
|
|
6
|
+
const remapping = createRequire(import.meta.url)("@jridgewell/remapping");
|
|
7
|
+
const countLines = (code) => code.split("\n").length;
|
|
8
|
+
const parseOxc = (code, filename) => {
|
|
9
|
+
const parsed = parseSync(filename, code, {
|
|
10
|
+
astType: filename.endsWith(".ts") || filename.endsWith(".tsx") ? "ts" : "js",
|
|
11
|
+
range: true,
|
|
12
|
+
sourceType: "module"
|
|
13
|
+
});
|
|
14
|
+
const fatalError = parsed.errors.find((error) => error.severity === "Error");
|
|
15
|
+
if (fatalError) {
|
|
16
|
+
throw new Error(fatalError.message);
|
|
17
|
+
}
|
|
18
|
+
return parsed.program;
|
|
19
|
+
};
|
|
20
|
+
const applyReplacements = (code, replacements) => {
|
|
21
|
+
let result = code;
|
|
22
|
+
replacements.sort((a, b) => b.start - a.start).forEach((replacement) => {
|
|
23
|
+
result = result.slice(0, replacement.start) + replacement.value + result.slice(replacement.end);
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
const shouldTerminateWithSemicolon = (node, parent, key) => {
|
|
28
|
+
if (node.type === "VariableDeclaration" && parent) {
|
|
29
|
+
if ((parent.type === "ForStatement" || parent.type === "ForInStatement" || parent.type === "ForOfStatement") && key && ["init", "left"].includes(key)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (parent.type === "ExportNamedDeclaration") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (node.type === "ImportDeclaration" || node.type === "ExpressionStatement" || node.type === "ReturnStatement" || node.type === "ThrowStatement" || node.type === "VariableDeclaration") {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
40
|
+
if (node.declaration) {
|
|
41
|
+
return node.declaration.type === "VariableDeclaration";
|
|
42
|
+
}
|
|
43
|
+
return Array.isArray(node.specifiers) && node.specifiers.length > 0;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
const getChildren = (node) => {
|
|
48
|
+
const result = [];
|
|
49
|
+
const record = node;
|
|
50
|
+
Object.keys(record).forEach((key) => {
|
|
51
|
+
if (key === "type" || key === "start" || key === "end" || key === "range") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const value = record[key];
|
|
55
|
+
if (value && typeof value === "object" && "type" in value) {
|
|
56
|
+
result.push({
|
|
57
|
+
key,
|
|
58
|
+
node: value
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
value.forEach((item) => {
|
|
64
|
+
if (item && typeof item === "object" && "type" in item) {
|
|
65
|
+
result.push({
|
|
66
|
+
key,
|
|
67
|
+
node: item
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
const getLineIndent = (code, offset) => {
|
|
76
|
+
const lineStart = code.lastIndexOf("\n", offset - 1) + 1;
|
|
77
|
+
let idx = lineStart;
|
|
78
|
+
while (idx < code.length && (code[idx] === " " || code[idx] === " ")) {
|
|
79
|
+
idx += 1;
|
|
80
|
+
}
|
|
81
|
+
return code.slice(lineStart, idx).replace(/\t/g, " ");
|
|
82
|
+
};
|
|
83
|
+
const isPlainObjectProperty = (property) => property.type === "Property" && property.kind === "init" && property.method !== true;
|
|
84
|
+
const isFormattableObjectExpression = (node) => node.type === "ObjectExpression" && node.properties.every((property) => property.type === "SpreadElement" || isPlainObjectProperty(property));
|
|
85
|
+
const hasNestedObjectValue = (node) => node.type === "ObjectExpression" && node.properties.some((property) => isPlainObjectProperty(property) && property.value.type === "ObjectExpression");
|
|
86
|
+
const printFormattedObjectExpression = (node, code, baseIndent) => {
|
|
87
|
+
if (node.type !== "ObjectExpression" || node.properties.length === 0 || !isFormattableObjectExpression(node)) {
|
|
88
|
+
return code.slice(node.start, node.end);
|
|
89
|
+
}
|
|
90
|
+
const lines = node.properties.map((property) => {
|
|
91
|
+
if (property.type === "SpreadElement") {
|
|
92
|
+
return `${baseIndent} ...${code.slice(property.argument.start, property.argument.end)}`;
|
|
93
|
+
}
|
|
94
|
+
const keySource = property.computed ? `[${code.slice(property.key.start, property.key.end)}]` : code.slice(property.key.start, property.key.end);
|
|
95
|
+
const valueSource = property.value.type === "ObjectExpression" ? printFormattedObjectExpression(property.value, code, `${baseIndent} `) : code.slice(property.value.start, property.value.end).trim();
|
|
96
|
+
return `${baseIndent} ${keySource}: ${valueSource}`;
|
|
97
|
+
});
|
|
98
|
+
return `{\n${lines.join(",\n")}\n${baseIndent}}`;
|
|
99
|
+
};
|
|
100
|
+
const formatRuntimeObjectLiterals = (code, filename) => {
|
|
101
|
+
const replacements = [];
|
|
102
|
+
const walk = (node, parent = null) => {
|
|
103
|
+
if (node.type === "ObjectExpression") {
|
|
104
|
+
const shouldFormat = parent?.type === "VariableDeclarator" && hasNestedObjectValue(node) || parent?.type === "CallExpression";
|
|
105
|
+
if (shouldFormat) {
|
|
106
|
+
replacements.push({
|
|
107
|
+
end: node.end,
|
|
108
|
+
start: node.start,
|
|
109
|
+
value: printFormattedObjectExpression(node, code, getLineIndent(code, node.start))
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
getChildren(node).forEach((child) => walk(child.node, node));
|
|
115
|
+
};
|
|
116
|
+
walk(parseOxc(code, filename));
|
|
117
|
+
return replacements.length > 0 ? applyReplacements(code, replacements) : code;
|
|
118
|
+
};
|
|
119
|
+
const collapseRuntimeBlankLines = (code) => {
|
|
120
|
+
const lines = code.split("\n");
|
|
121
|
+
const result = [];
|
|
122
|
+
for (let idx = 0; idx < lines.length; idx += 1) {
|
|
123
|
+
const line = lines[idx];
|
|
124
|
+
if (line.trim() !== "") {
|
|
125
|
+
result.push(line);
|
|
126
|
+
} else {
|
|
127
|
+
let nextIdx = idx;
|
|
128
|
+
while (nextIdx < lines.length && lines[nextIdx]?.trim() === "") {
|
|
129
|
+
nextIdx += 1;
|
|
130
|
+
}
|
|
131
|
+
const previousNonEmpty = [...result].reverse().find((entry) => entry.trim() !== "");
|
|
132
|
+
const nextNonEmpty = lines.slice(nextIdx).find((entry) => entry.trim() !== "");
|
|
133
|
+
if (previousNonEmpty && nextNonEmpty) {
|
|
134
|
+
const trimmedPrevious = previousNonEmpty.trim();
|
|
135
|
+
if (trimmedPrevious.startsWith("//") || trimmedPrevious.endsWith("*/")) {
|
|
136
|
+
result.push("");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
idx = nextIdx - 1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result.join("\n");
|
|
143
|
+
};
|
|
144
|
+
const ensureBlankLineAfterLeadingBlockComment = (code) => code.replace(/^(\/\*[\s\S]*?\*\/)\n(?!\n)/, "$1\n\n");
|
|
145
|
+
const insertMissingSemicolons = (code, filename) => {
|
|
146
|
+
const replacements = [];
|
|
147
|
+
const hasTrailingSemicolon = (node) => code.slice(node.start, node.end).trimEnd().endsWith(";");
|
|
148
|
+
const walk = (node, parent = null, key = null) => {
|
|
149
|
+
if (shouldTerminateWithSemicolon(node, parent, key) && !hasTrailingSemicolon(node)) {
|
|
150
|
+
replacements.push({
|
|
151
|
+
end: node.end,
|
|
152
|
+
start: node.end,
|
|
153
|
+
value: ";"
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
getChildren(node).forEach((child) => walk(child.node, node, child.key));
|
|
157
|
+
};
|
|
158
|
+
walk(parseOxc(code, filename));
|
|
159
|
+
return replacements.length > 0 ? applyReplacements(code, replacements) : code;
|
|
160
|
+
};
|
|
161
|
+
const createLineSourceMap = (generatedCode, originalCode, filename) => {
|
|
162
|
+
const generator = new SourceMapGenerator({ file: filename });
|
|
163
|
+
const generatedLines = countLines(generatedCode);
|
|
164
|
+
const originalLines = countLines(originalCode);
|
|
165
|
+
for (let line = 1; line <= generatedLines; line += 1) {
|
|
166
|
+
generator.addMapping({
|
|
167
|
+
generated: {
|
|
168
|
+
column: 0,
|
|
169
|
+
line
|
|
170
|
+
},
|
|
171
|
+
original: {
|
|
172
|
+
column: 0,
|
|
173
|
+
line: Math.min(line, originalLines)
|
|
174
|
+
},
|
|
175
|
+
source: filename
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
generator.setSourceContent(filename, originalCode);
|
|
179
|
+
return generator.toJSON();
|
|
180
|
+
};
|
|
181
|
+
const createComposedRuntimeSourceMap = (generatedCode, originalCode, filename, inputSourceMap) => {
|
|
182
|
+
const runtimeMap = createLineSourceMap(generatedCode, originalCode, filename);
|
|
183
|
+
if (!inputSourceMap) {
|
|
184
|
+
return runtimeMap;
|
|
185
|
+
}
|
|
186
|
+
const composed = remapping([runtimeMap, inputSourceMap], () => null);
|
|
187
|
+
return {
|
|
188
|
+
...composed,
|
|
189
|
+
file: runtimeMap.file
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const normalizeRuntimeCode = (code, filename) => insertMissingSemicolons(ensureBlankLineAfterLeadingBlockComment(collapseRuntimeBlankLines(formatRuntimeObjectLiterals(code.replace(/^\n+/, "").replace(/\n+$/, "").replace(/[ \t]+\n/g, "\n"), filename))), filename);
|
|
193
|
+
export const collectOxcRuntime = (code, filename, root, options, values, inputSourceMap) => {
|
|
194
|
+
const result = applyOxcProcessors(code, {
|
|
195
|
+
filename,
|
|
196
|
+
root
|
|
197
|
+
}, options, (processor) => {
|
|
198
|
+
processor.build(values);
|
|
199
|
+
processor.doRuntimeReplacement();
|
|
200
|
+
}, true);
|
|
201
|
+
const normalizedCode = normalizeRuntimeCode(result.code, filename);
|
|
202
|
+
if (result.processors.length === 0) {
|
|
203
|
+
return {
|
|
204
|
+
code: normalizedCode,
|
|
205
|
+
map: createComposedRuntimeSourceMap(normalizedCode, code, filename, inputSourceMap),
|
|
206
|
+
metadata: null
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
code: normalizedCode,
|
|
211
|
+
map: createComposedRuntimeSourceMap(normalizedCode, code, filename, inputSourceMap),
|
|
212
|
+
metadata: {
|
|
213
|
+
dependencies: [],
|
|
214
|
+
processors: result.processors,
|
|
215
|
+
replacements: [],
|
|
216
|
+
rules: {}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=collectOxcRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAEA,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAI1B,SAAS,0BAA6C;AAGtD,SAAS,0BAA0B;AAwCnC,MAAM,YAAY,cAAc,OAAO,KAAK,IAAI,CAC9C,wBACD;AAED,MAAM,cAAc,SAAyB,KAAK,MAAM,KAAK,CAAC;AAE9D,MAAM,YAAY,MAAc,aAA8B;CAC5D,MAAM,SAAS,UAAU,UAAU,MAAM;EACvC,SACE,SA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J,WAAU,iBAAiB,UAAU,aAAa;AAElD,QAAO,UAAU,QAAQ;;AAG3B,MAAM,kCACJ,eACA,cACA,UACA,mBACiB;CACjB,MAAM,aAAa,oBAAoB,eAAe,cAAc,SAAS;AAC7E,KAAI,CAAC,gBAAgB;AACnB,SAAO;;CAGT,MAAM,WAAW,UAAU,CAAC,YAAY,eAAe,QAAQ,KAAK;AACpE,QAAO;EACL,GAAG;EACH,MAAM,WAAW;EAClB;;AAGH,MAAM,wBAAwB,MAAc,aAC1C,wBACE,wCACE,0BACE,4BACE,KACG,QAAQ,QAAQ,GAAG,CACnB,QAAQ,QAAQ,GAAG,CACnB,QAAQ,aAAa,KAAK,EAC7B,SACD,CACF,CACF,EACD,SACD;AAEH,OAAO,MAAM,qBACX,MACA,UACA,MACA,SACA,QACA,mBACqB;CACrB,MAAM,SAAS,mBACb,MACA;EACE;EACA;EACD,EACD,UACC,cAAc;AACb,YAAU,MAAM,OAAO;AACvB,YAAU,sBAAsB;IAElC,KACD;CACD,MAAM,iBAAiB,qBAAqB,OAAO,MAAM,SAAS;AAElE,KAAI,OAAO,WAAW,WAAW,GAAG;AAClC,SAAO;GACL,MAAM;GACN,KAAK,+BACH,gBACA,MACA,UACA,eACD;GACD,UAAU;GACX;;AAGH,QAAO;EACL,MAAM;EACN,KAAK,+BACH,gBACA,MACA,UACA,eACD;EACD,UAAU;GACR,cAAc,EAAE;GAChB,YAAY,OAAO;GACnB,cAAc,EAAE;GAChB,OAAO,EAAE;GACV;EACF","names":[],"sources":["../../src/utils/collectOxcRuntime.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax */\n\nimport { createRequire } from 'node:module';\nimport { parseSync } from 'oxc-parser';\nimport type { Node, Program } from 'oxc-parser';\nimport type { ValueCache } from '@wyw-in-js/processor-utils';\nimport type { StrictOptions } from '@wyw-in-js/shared';\nimport { SourceMapGenerator, type RawSourceMap } from 'source-map';\n\nimport type { WYWTransformMetadata } from './TransformMetadata';\nimport { applyOxcProcessors } from './applyOxcProcessors';\n\ntype OxcCollectOptions = Pick<\n StrictOptions,\n | 'classNameSlug'\n | 'displayName'\n | 'evaluate'\n | 'extensions'\n | 'tagResolver'\n | 'variableNameConfig'\n> & {\n preserveSideEffectImportLocals?: Set<string>;\n};\n\ntype OxcCollectResult = {\n code: string;\n map: RawSourceMap;\n metadata: WYWTransformMetadata | null;\n};\n\ntype Replacement = {\n end: number;\n start: number;\n value: string;\n};\n\ntype AnyNode = Node & Record<string, unknown>;\ntype AnyProperty = AnyNode & {\n computed?: boolean;\n key: Node;\n kind?: string;\n method?: boolean;\n value: Node;\n};\n\ntype RemappingFn = (\n input: RawSourceMap | RawSourceMap[],\n loader: (source: string, context: unknown) => RawSourceMap | null | undefined\n) => RawSourceMap;\n\nconst remapping = createRequire(import.meta.url)(\n '@jridgewell/remapping'\n) as RemappingFn;\n\nconst countLines = (code: string): number => code.split('\\n').length;\n\nconst parseOxc = (code: string, filename: string): Program => {\n const parsed = parseSync(filename, code, {\n astType:\n filename.endsWith('.ts') || filename.endsWith('.tsx') ? 'ts' : 'js',\n range: true,\n sourceType: 'module',\n });\n const fatalError = parsed.errors.find((error) => error.severity === 'Error');\n if (fatalError) {\n throw new Error(fatalError.message);\n }\n\n return parsed.program as Program;\n};\n\nconst applyReplacements = (\n code: string,\n replacements: Replacement[]\n): string => {\n let result = code;\n replacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n result =\n result.slice(0, replacement.start) +\n replacement.value +\n result.slice(replacement.end);\n });\n\n return result;\n};\n\nconst shouldTerminateWithSemicolon = (\n node: Node,\n parent: Node | null,\n key: string | null\n): boolean => {\n if (node.type === 'VariableDeclaration' && parent) {\n if (\n (parent.type === 'ForStatement' ||\n parent.type === 'ForInStatement' ||\n parent.type === 'ForOfStatement') &&\n key &&\n ['init', 'left'].includes(key)\n ) {\n return false;\n }\n\n if (parent.type === 'ExportNamedDeclaration') {\n return false;\n }\n }\n\n if (\n node.type === 'ImportDeclaration' ||\n node.type === 'ExpressionStatement' ||\n node.type === 'ReturnStatement' ||\n node.type === 'ThrowStatement' ||\n node.type === 'VariableDeclaration'\n ) {\n return true;\n }\n\n if (node.type === 'ExportNamedDeclaration') {\n if (node.declaration) {\n return node.declaration.type === 'VariableDeclaration';\n }\n\n return Array.isArray(node.specifiers) && node.specifiers.length > 0;\n }\n\n return false;\n};\n\nconst getChildren = (node: Node): Array<{ key: string | null; node: Node }> => {\n const result: Array<{ key: string | null; node: Node }> = [];\n const record = node as Node & Record<string, unknown>;\n\n Object.keys(record).forEach((key) => {\n if (key === 'type' || key === 'start' || key === 'end' || key === 'range') {\n return;\n }\n\n const value = record[key];\n if (value && typeof value === 'object' && 'type' in (value as object)) {\n result.push({ key, node: value as Node });\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (item && typeof item === 'object' && 'type' in (item as object)) {\n result.push({ key, node: item as Node });\n }\n });\n }\n });\n\n return result;\n};\n\nconst getLineIndent = (code: string, offset: number): string => {\n const lineStart = code.lastIndexOf('\\n', offset - 1) + 1;\n let idx = lineStart;\n while (idx < code.length && (code[idx] === ' ' || code[idx] === '\\t')) {\n idx += 1;\n }\n\n return code.slice(lineStart, idx).replace(/\\t/g, ' ');\n};\n\nconst isPlainObjectProperty = (property: Node): property is AnyProperty =>\n property.type === 'Property' &&\n (property as AnyProperty).kind === 'init' &&\n (property as AnyProperty).method !== true;\n\nconst isFormattableObjectExpression = (node: Node): boolean =>\n node.type === 'ObjectExpression' &&\n node.properties.every(\n (property) =>\n property.type === 'SpreadElement' || isPlainObjectProperty(property)\n );\n\nconst hasNestedObjectValue = (node: Node): boolean =>\n node.type === 'ObjectExpression' &&\n node.properties.some(\n (property) =>\n isPlainObjectProperty(property) &&\n property.value.type === 'ObjectExpression'\n );\n\nconst printFormattedObjectExpression = (\n node: Node,\n code: string,\n baseIndent: string\n): string => {\n if (\n node.type !== 'ObjectExpression' ||\n node.properties.length === 0 ||\n !isFormattableObjectExpression(node)\n ) {\n return code.slice(node.start, node.end);\n }\n\n const lines = node.properties.map((property) => {\n if (property.type === 'SpreadElement') {\n return `${baseIndent} ...${code.slice(\n property.argument.start,\n property.argument.end\n )}`;\n }\n\n const keySource = property.computed\n ? `[${code.slice(property.key.start, property.key.end)}]`\n : code.slice(property.key.start, property.key.end);\n const valueSource =\n property.value.type === 'ObjectExpression'\n ? printFormattedObjectExpression(\n property.value,\n code,\n `${baseIndent} `\n )\n : code.slice(property.value.start, property.value.end).trim();\n\n return `${baseIndent} ${keySource}: ${valueSource}`;\n });\n\n return `{\\n${lines.join(',\\n')}\\n${baseIndent}}`;\n};\n\nconst formatRuntimeObjectLiterals = (\n code: string,\n filename: string\n): string => {\n const replacements: Replacement[] = [];\n\n const walk = (node: Node, parent: Node | null = null): void => {\n if (node.type === 'ObjectExpression') {\n const shouldFormat =\n (parent?.type === 'VariableDeclarator' && hasNestedObjectValue(node)) ||\n parent?.type === 'CallExpression';\n\n if (shouldFormat) {\n replacements.push({\n end: node.end,\n start: node.start,\n value: printFormattedObjectExpression(\n node,\n code,\n getLineIndent(code, node.start)\n ),\n });\n return;\n }\n }\n\n getChildren(node).forEach((child) => walk(child.node, node));\n };\n\n walk(parseOxc(code, filename));\n return replacements.length > 0 ? applyReplacements(code, replacements) : code;\n};\n\nconst collapseRuntimeBlankLines = (code: string): string => {\n const lines = code.split('\\n');\n const result: string[] = [];\n\n for (let idx = 0; idx < lines.length; idx += 1) {\n const line = lines[idx]!;\n if (line.trim() !== '') {\n result.push(line);\n } else {\n let nextIdx = idx;\n while (nextIdx < lines.length && lines[nextIdx]?.trim() === '') {\n nextIdx += 1;\n }\n\n const previousNonEmpty = [...result]\n .reverse()\n .find((entry) => entry.trim() !== '');\n const nextNonEmpty = lines\n .slice(nextIdx)\n .find((entry) => entry.trim() !== '');\n\n if (previousNonEmpty && nextNonEmpty) {\n const trimmedPrevious = previousNonEmpty.trim();\n if (\n trimmedPrevious.startsWith('//') ||\n trimmedPrevious.endsWith('*/')\n ) {\n result.push('');\n }\n }\n\n idx = nextIdx - 1;\n }\n }\n\n return result.join('\\n');\n};\n\nconst ensureBlankLineAfterLeadingBlockComment = (code: string): string =>\n code.replace(/^(\\/\\*[\\s\\S]*?\\*\\/)\\n(?!\\n)/, '$1\\n\\n');\n\nconst insertMissingSemicolons = (code: string, filename: string): string => {\n const replacements: Replacement[] = [];\n const hasTrailingSemicolon = (node: Node): boolean =>\n code.slice(node.start, node.end).trimEnd().endsWith(';');\n\n const walk = (\n node: Node,\n parent: Node | null = null,\n key: string | null = null\n ): void => {\n if (\n shouldTerminateWithSemicolon(node, parent, key) &&\n !hasTrailingSemicolon(node)\n ) {\n replacements.push({\n end: node.end,\n start: node.end,\n value: ';',\n });\n }\n\n getChildren(node).forEach((child) => walk(child.node, node, child.key));\n };\n\n walk(parseOxc(code, filename));\n return replacements.length > 0 ? applyReplacements(code, replacements) : code;\n};\n\nconst createLineSourceMap = (\n generatedCode: string,\n originalCode: string,\n filename: string\n): RawSourceMap => {\n const generator = new SourceMapGenerator({\n file: filename,\n });\n const generatedLines = countLines(generatedCode);\n const originalLines = countLines(originalCode);\n\n for (let line = 1; line <= generatedLines; line += 1) {\n generator.addMapping({\n generated: {\n column: 0,\n line,\n },\n original: {\n column: 0,\n line: Math.min(line, originalLines),\n },\n source: filename,\n });\n }\n\n generator.setSourceContent(filename, originalCode);\n\n return generator.toJSON() as RawSourceMap;\n};\n\nconst createComposedRuntimeSourceMap = (\n generatedCode: string,\n originalCode: string,\n filename: string,\n inputSourceMap?: RawSourceMap\n): RawSourceMap => {\n const runtimeMap = createLineSourceMap(generatedCode, originalCode, filename);\n if (!inputSourceMap) {\n return runtimeMap;\n }\n\n const composed = remapping([runtimeMap, inputSourceMap], () => null);\n return {\n ...composed,\n file: runtimeMap.file,\n } as RawSourceMap;\n};\n\nconst normalizeRuntimeCode = (code: string, filename: string): string =>\n insertMissingSemicolons(\n ensureBlankLineAfterLeadingBlockComment(\n collapseRuntimeBlankLines(\n formatRuntimeObjectLiterals(\n code\n .replace(/^\\n+/, '')\n .replace(/\\n+$/, '')\n .replace(/[ \\t]+\\n/g, '\\n'),\n filename\n )\n )\n ),\n filename\n );\n\nexport const collectOxcRuntime = (\n code: string,\n filename: string,\n root: string,\n options: OxcCollectOptions,\n values: ValueCache,\n inputSourceMap?: RawSourceMap\n): OxcCollectResult => {\n const result = applyOxcProcessors(\n code,\n {\n filename,\n root,\n },\n options,\n (processor) => {\n processor.build(values);\n processor.doRuntimeReplacement();\n },\n true\n );\n const normalizedCode = normalizeRuntimeCode(result.code, filename);\n\n if (result.processors.length === 0) {\n return {\n code: normalizedCode,\n map: createComposedRuntimeSourceMap(\n normalizedCode,\n code,\n filename,\n inputSourceMap\n ),\n metadata: null,\n };\n }\n\n return {\n code: normalizedCode,\n map: createComposedRuntimeSourceMap(\n normalizedCode,\n code,\n filename,\n inputSourceMap\n ),\n metadata: {\n dependencies: [],\n processors: result.processors,\n replacements: [],\n rules: {},\n },\n };\n};\n"],"file":"collectOxcRuntime.js"}
|