@wyw-in-js/transform 0.1.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/LICENSE +21 -0
- package/esm/babel.js +2 -0
- package/esm/babel.js.map +1 -0
- package/esm/cache.js +80 -0
- package/esm/cache.js.map +1 -0
- package/esm/debug/fileReporter.js +144 -0
- package/esm/debug/fileReporter.js.map +1 -0
- package/esm/evaluators/index.js +14 -0
- package/esm/evaluators/index.js.map +1 -0
- package/esm/index.js +24 -0
- package/esm/index.js.map +1 -0
- package/esm/module.js +316 -0
- package/esm/module.js.map +1 -0
- package/esm/options/babel-merge.d.js +2 -0
- package/esm/options/babel-merge.d.js.map +1 -0
- package/esm/options/buildOptions.js +28 -0
- package/esm/options/buildOptions.js.map +1 -0
- package/esm/options/loadBabelOptions.js +24 -0
- package/esm/options/loadBabelOptions.js.map +1 -0
- package/esm/plugins/babel-transform.js +53 -0
- package/esm/plugins/babel-transform.js.map +1 -0
- package/esm/plugins/collector.js +66 -0
- package/esm/plugins/collector.js.map +1 -0
- package/esm/plugins/dynamic-import.js +28 -0
- package/esm/plugins/dynamic-import.js.map +1 -0
- package/esm/plugins/preeval.js +75 -0
- package/esm/plugins/preeval.js.map +1 -0
- package/esm/plugins/shaker.js +296 -0
- package/esm/plugins/shaker.js.map +1 -0
- package/esm/shaker.js +50 -0
- package/esm/shaker.js.map +1 -0
- package/esm/transform/BaseEntrypoint.js +164 -0
- package/esm/transform/BaseEntrypoint.js.map +1 -0
- package/esm/transform/Entrypoint.helpers.js +168 -0
- package/esm/transform/Entrypoint.helpers.js.map +1 -0
- package/esm/transform/Entrypoint.js +212 -0
- package/esm/transform/Entrypoint.js.map +1 -0
- package/esm/transform/Entrypoint.types.js +2 -0
- package/esm/transform/Entrypoint.types.js.map +1 -0
- package/esm/transform/EvaluatedEntrypoint.js +6 -0
- package/esm/transform/EvaluatedEntrypoint.js.map +1 -0
- package/esm/transform/actions/AbortError.js +8 -0
- package/esm/transform/actions/AbortError.js.map +1 -0
- package/esm/transform/actions/BaseAction.js +134 -0
- package/esm/transform/actions/BaseAction.js.map +1 -0
- package/esm/transform/actions/UnprocessedEntrypointError.js +8 -0
- package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -0
- package/esm/transform/actions/actionRunner.js +73 -0
- package/esm/transform/actions/actionRunner.js.map +1 -0
- package/esm/transform/actions/types.js +2 -0
- package/esm/transform/actions/types.js.map +1 -0
- package/esm/transform/generators/baseProcessingHandlers.js +22 -0
- package/esm/transform/generators/baseProcessingHandlers.js.map +1 -0
- package/esm/transform/generators/collect.js +58 -0
- package/esm/transform/generators/collect.js.map +1 -0
- package/esm/transform/generators/evalFile.js +50 -0
- package/esm/transform/generators/evalFile.js.map +1 -0
- package/esm/transform/generators/explodeReexports.js +63 -0
- package/esm/transform/generators/explodeReexports.js.map +1 -0
- package/esm/transform/generators/extract.js +120 -0
- package/esm/transform/generators/extract.js.map +1 -0
- package/esm/transform/generators/getExports.js +73 -0
- package/esm/transform/generators/getExports.js.map +1 -0
- package/esm/transform/generators/index.js +13 -0
- package/esm/transform/generators/index.js.map +1 -0
- package/esm/transform/generators/processEntrypoint.js +43 -0
- package/esm/transform/generators/processEntrypoint.js.map +1 -0
- package/esm/transform/generators/processImports.js +23 -0
- package/esm/transform/generators/processImports.js.map +1 -0
- package/esm/transform/generators/resolveImports.js +148 -0
- package/esm/transform/generators/resolveImports.js.map +1 -0
- package/esm/transform/generators/transform.js +117 -0
- package/esm/transform/generators/transform.js.map +1 -0
- package/esm/transform/generators/workflow.js +82 -0
- package/esm/transform/generators/workflow.js.map +1 -0
- package/esm/transform/helpers/loadLinariaOptions.js +66 -0
- package/esm/transform/helpers/loadLinariaOptions.js.map +1 -0
- package/esm/transform/helpers/withDefaultServices.js +21 -0
- package/esm/transform/helpers/withDefaultServices.js.map +1 -0
- package/esm/transform/rootLog.js +3 -0
- package/esm/transform/rootLog.js.map +1 -0
- package/esm/transform/types.js +2 -0
- package/esm/transform/types.js.map +1 -0
- package/esm/transform.js +121 -0
- package/esm/transform.js.map +1 -0
- package/esm/types.js +2 -0
- package/esm/types.js.map +1 -0
- package/esm/utils/EventEmitter.js +52 -0
- package/esm/utils/EventEmitter.js.map +1 -0
- package/esm/utils/ShakerMetadata.js +2 -0
- package/esm/utils/ShakerMetadata.js.map +1 -0
- package/esm/utils/TransformMetadata.js +11 -0
- package/esm/utils/TransformMetadata.js.map +1 -0
- package/esm/utils/addIdentifierToLinariaPreval.js +68 -0
- package/esm/utils/addIdentifierToLinariaPreval.js.map +1 -0
- package/esm/utils/collectExportsAndImports.js +974 -0
- package/esm/utils/collectExportsAndImports.js.map +1 -0
- package/esm/utils/collectTemplateDependencies.js +219 -0
- package/esm/utils/collectTemplateDependencies.js.map +1 -0
- package/esm/utils/createId.js +6 -0
- package/esm/utils/createId.js.map +1 -0
- package/esm/utils/dispose-polyfill.js +6 -0
- package/esm/utils/dispose-polyfill.js.map +1 -0
- package/esm/utils/findIdentifiers.js +62 -0
- package/esm/utils/findIdentifiers.js.map +1 -0
- package/esm/utils/findPackageJSON.js +22 -0
- package/esm/utils/findPackageJSON.js.map +1 -0
- package/esm/utils/getFileIdx.js +10 -0
- package/esm/utils/getFileIdx.js.map +1 -0
- package/esm/utils/getPluginKey.js +13 -0
- package/esm/utils/getPluginKey.js.map +1 -0
- package/esm/utils/getScope.js +6 -0
- package/esm/utils/getScope.js.map +1 -0
- package/esm/utils/getSource.js +15 -0
- package/esm/utils/getSource.js.map +1 -0
- package/esm/utils/getTagProcessor.js +304 -0
- package/esm/utils/getTagProcessor.js.map +1 -0
- package/esm/utils/getVisitorKeys.js +5 -0
- package/esm/utils/getVisitorKeys.js.map +1 -0
- package/esm/utils/hasLinariaPreval.js +7 -0
- package/esm/utils/hasLinariaPreval.js.map +1 -0
- package/esm/utils/isExports.js +22 -0
- package/esm/utils/isExports.js.map +1 -0
- package/esm/utils/isGlobal.js +6 -0
- package/esm/utils/isGlobal.js.map +1 -0
- package/esm/utils/isNode.js +2 -0
- package/esm/utils/isNode.js.map +1 -0
- package/esm/utils/isNodePath.js +4 -0
- package/esm/utils/isNodePath.js.map +1 -0
- package/esm/utils/isNotNull.js +4 -0
- package/esm/utils/isNotNull.js.map +1 -0
- package/esm/utils/isRemoved.js +46 -0
- package/esm/utils/isRemoved.js.map +1 -0
- package/esm/utils/isRequire.js +13 -0
- package/esm/utils/isRequire.js.map +1 -0
- package/esm/utils/isSerializable.js +13 -0
- package/esm/utils/isSerializable.js.map +1 -0
- package/esm/utils/isTypedNode.js +6 -0
- package/esm/utils/isTypedNode.js.map +1 -0
- package/esm/utils/isUnnecessaryReactCall.js +72 -0
- package/esm/utils/isUnnecessaryReactCall.js.map +1 -0
- package/esm/utils/peek.js +2 -0
- package/esm/utils/peek.js.map +1 -0
- package/esm/utils/processTemplateExpression.js +11 -0
- package/esm/utils/processTemplateExpression.js.map +1 -0
- package/esm/utils/removeDangerousCode.js +127 -0
- package/esm/utils/removeDangerousCode.js.map +1 -0
- package/esm/utils/scopeHelpers.js +514 -0
- package/esm/utils/scopeHelpers.js.map +1 -0
- package/esm/utils/traversalCache.js +28 -0
- package/esm/utils/traversalCache.js.map +1 -0
- package/esm/utils/unwrapSequence.js +14 -0
- package/esm/utils/unwrapSequence.js.map +1 -0
- package/esm/utils/valueToLiteral.js +59 -0
- package/esm/utils/valueToLiteral.js.map +1 -0
- package/esm/utils/visitors/JSXElementsRemover.js +51 -0
- package/esm/utils/visitors/JSXElementsRemover.js.map +1 -0
- package/esm/vm/createVmContext.js +72 -0
- package/esm/vm/createVmContext.js.map +1 -0
- package/esm/vm/process.js +29 -0
- package/esm/vm/process.js.map +1 -0
- package/lib/babel.js +2 -0
- package/lib/babel.js.map +1 -0
- package/lib/cache.js +87 -0
- package/lib/cache.js.map +1 -0
- package/lib/debug/fileReporter.js +153 -0
- package/lib/debug/fileReporter.js.map +1 -0
- package/lib/evaluators/index.js +20 -0
- package/lib/evaluators/index.js.map +1 -0
- package/lib/index.js +225 -0
- package/lib/index.js.map +1 -0
- package/lib/module.js +327 -0
- package/lib/module.js.map +1 -0
- package/lib/options/babel-merge.d.js +2 -0
- package/lib/options/babel-merge.d.js.map +1 -0
- package/lib/options/buildOptions.js +35 -0
- package/lib/options/buildOptions.js.map +1 -0
- package/lib/options/loadBabelOptions.js +31 -0
- package/lib/options/loadBabelOptions.js.map +1 -0
- package/lib/plugins/babel-transform.js +60 -0
- package/lib/plugins/babel-transform.js.map +1 -0
- package/lib/plugins/collector.js +76 -0
- package/lib/plugins/collector.js.map +1 -0
- package/lib/plugins/dynamic-import.js +34 -0
- package/lib/plugins/dynamic-import.js.map +1 -0
- package/lib/plugins/preeval.js +82 -0
- package/lib/plugins/preeval.js.map +1 -0
- package/lib/plugins/shaker.js +303 -0
- package/lib/plugins/shaker.js.map +1 -0
- package/lib/shaker.js +58 -0
- package/lib/shaker.js.map +1 -0
- package/lib/transform/BaseEntrypoint.js +175 -0
- package/lib/transform/BaseEntrypoint.js.map +1 -0
- package/lib/transform/Entrypoint.helpers.js +182 -0
- package/lib/transform/Entrypoint.helpers.js.map +1 -0
- package/lib/transform/Entrypoint.js +226 -0
- package/lib/transform/Entrypoint.js.map +1 -0
- package/lib/transform/Entrypoint.types.js +2 -0
- package/lib/transform/Entrypoint.types.js.map +1 -0
- package/lib/transform/EvaluatedEntrypoint.js +13 -0
- package/lib/transform/EvaluatedEntrypoint.js.map +1 -0
- package/lib/transform/actions/AbortError.js +16 -0
- package/lib/transform/actions/AbortError.js.map +1 -0
- package/lib/transform/actions/BaseAction.js +144 -0
- package/lib/transform/actions/BaseAction.js.map +1 -0
- package/lib/transform/actions/UnprocessedEntrypointError.js +16 -0
- package/lib/transform/actions/UnprocessedEntrypointError.js.map +1 -0
- package/lib/transform/actions/actionRunner.js +82 -0
- package/lib/transform/actions/actionRunner.js.map +1 -0
- package/lib/transform/actions/types.js +2 -0
- package/lib/transform/actions/types.js.map +1 -0
- package/lib/transform/generators/baseProcessingHandlers.js +27 -0
- package/lib/transform/generators/baseProcessingHandlers.js.map +1 -0
- package/lib/transform/generators/collect.js +66 -0
- package/lib/transform/generators/collect.js.map +1 -0
- package/lib/transform/generators/evalFile.js +57 -0
- package/lib/transform/generators/evalFile.js.map +1 -0
- package/lib/transform/generators/explodeReexports.js +70 -0
- package/lib/transform/generators/explodeReexports.js.map +1 -0
- package/lib/transform/generators/extract.js +128 -0
- package/lib/transform/generators/extract.js.map +1 -0
- package/lib/transform/generators/getExports.js +80 -0
- package/lib/transform/generators/getExports.js.map +1 -0
- package/lib/transform/generators/index.js +19 -0
- package/lib/transform/generators/index.js.map +1 -0
- package/lib/transform/generators/processEntrypoint.js +49 -0
- package/lib/transform/generators/processEntrypoint.js.map +1 -0
- package/lib/transform/generators/processImports.js +29 -0
- package/lib/transform/generators/processImports.js.map +1 -0
- package/lib/transform/generators/resolveImports.js +158 -0
- package/lib/transform/generators/resolveImports.js.map +1 -0
- package/lib/transform/generators/transform.js +130 -0
- package/lib/transform/generators/transform.js.map +1 -0
- package/lib/transform/generators/workflow.js +90 -0
- package/lib/transform/generators/workflow.js.map +1 -0
- package/lib/transform/helpers/loadLinariaOptions.js +73 -0
- package/lib/transform/helpers/loadLinariaOptions.js.map +1 -0
- package/lib/transform/helpers/withDefaultServices.js +30 -0
- package/lib/transform/helpers/withDefaultServices.js.map +1 -0
- package/lib/transform/rootLog.js +9 -0
- package/lib/transform/rootLog.js.map +1 -0
- package/lib/transform/types.js +8 -0
- package/lib/transform/types.js.map +1 -0
- package/lib/transform.js +128 -0
- package/lib/transform.js.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/EventEmitter.js +61 -0
- package/lib/utils/EventEmitter.js.map +1 -0
- package/lib/utils/ShakerMetadata.js +9 -0
- package/lib/utils/ShakerMetadata.js.map +1 -0
- package/lib/utils/TransformMetadata.js +19 -0
- package/lib/utils/TransformMetadata.js.map +1 -0
- package/lib/utils/addIdentifierToLinariaPreval.js +75 -0
- package/lib/utils/addIdentifierToLinariaPreval.js.map +1 -0
- package/lib/utils/collectExportsAndImports.js +990 -0
- package/lib/utils/collectExportsAndImports.js.map +1 -0
- package/lib/utils/collectTemplateDependencies.js +233 -0
- package/lib/utils/collectTemplateDependencies.js.map +1 -0
- package/lib/utils/createId.js +13 -0
- package/lib/utils/createId.js.map +1 -0
- package/lib/utils/dispose-polyfill.js +9 -0
- package/lib/utils/dispose-polyfill.js.map +1 -0
- package/lib/utils/findIdentifiers.js +73 -0
- package/lib/utils/findIdentifiers.js.map +1 -0
- package/lib/utils/findPackageJSON.js +29 -0
- package/lib/utils/findPackageJSON.js.map +1 -0
- package/lib/utils/getFileIdx.js +16 -0
- package/lib/utils/getFileIdx.js.map +1 -0
- package/lib/utils/getPluginKey.js +21 -0
- package/lib/utils/getPluginKey.js.map +1 -0
- package/lib/utils/getScope.js +12 -0
- package/lib/utils/getScope.js.map +1 -0
- package/lib/utils/getSource.js +24 -0
- package/lib/utils/getSource.js.map +1 -0
- package/lib/utils/getTagProcessor.js +318 -0
- package/lib/utils/getTagProcessor.js.map +1 -0
- package/lib/utils/getVisitorKeys.js +11 -0
- package/lib/utils/getVisitorKeys.js.map +1 -0
- package/lib/utils/hasLinariaPreval.js +13 -0
- package/lib/utils/hasLinariaPreval.js.map +1 -0
- package/lib/utils/isExports.js +27 -0
- package/lib/utils/isExports.js.map +1 -0
- package/lib/utils/isGlobal.js +13 -0
- package/lib/utils/isGlobal.js.map +1 -0
- package/lib/utils/isNode.js +9 -0
- package/lib/utils/isNode.js.map +1 -0
- package/lib/utils/isNodePath.js +10 -0
- package/lib/utils/isNodePath.js.map +1 -0
- package/lib/utils/isNotNull.js +10 -0
- package/lib/utils/isNotNull.js.map +1 -0
- package/lib/utils/isRemoved.js +52 -0
- package/lib/utils/isRemoved.js.map +1 -0
- package/lib/utils/isRequire.js +18 -0
- package/lib/utils/isRequire.js.map +1 -0
- package/lib/utils/isSerializable.js +19 -0
- package/lib/utils/isSerializable.js.map +1 -0
- package/lib/utils/isTypedNode.js +13 -0
- package/lib/utils/isTypedNode.js.map +1 -0
- package/lib/utils/isUnnecessaryReactCall.js +81 -0
- package/lib/utils/isUnnecessaryReactCall.js.map +1 -0
- package/lib/utils/peek.js +9 -0
- package/lib/utils/peek.js.map +1 -0
- package/lib/utils/processTemplateExpression.js +18 -0
- package/lib/utils/processTemplateExpression.js.map +1 -0
- package/lib/utils/removeDangerousCode.js +134 -0
- package/lib/utils/removeDangerousCode.js.map +1 -0
- package/lib/utils/scopeHelpers.js +544 -0
- package/lib/utils/scopeHelpers.js.map +1 -0
- package/lib/utils/traversalCache.js +38 -0
- package/lib/utils/traversalCache.js.map +1 -0
- package/lib/utils/unwrapSequence.js +20 -0
- package/lib/utils/unwrapSequence.js.map +1 -0
- package/lib/utils/valueToLiteral.js +65 -0
- package/lib/utils/valueToLiteral.js.map +1 -0
- package/lib/utils/visitors/JSXElementsRemover.js +57 -0
- package/lib/utils/visitors/JSXElementsRemover.js.map +1 -0
- package/lib/vm/createVmContext.js +80 -0
- package/lib/vm/createVmContext.js.map +1 -0
- package/lib/vm/process.js +38 -0
- package/lib/vm/process.js.map +1 -0
- package/package.json +63 -0
- package/types/babel.d.ts +2 -0
- package/types/babel.js +2 -0
- package/types/cache.d.ts +24 -0
- package/types/cache.js +85 -0
- package/types/debug/fileReporter.d.ts +27 -0
- package/types/debug/fileReporter.js +151 -0
- package/types/evaluators/index.d.ts +10 -0
- package/types/evaluators/index.js +15 -0
- package/types/index.d.ts +30 -0
- package/types/index.js +69 -0
- package/types/module.d.ts +62 -0
- package/types/module.js +318 -0
- package/types/options/buildOptions.d.ts +7 -0
- package/types/options/buildOptions.js +35 -0
- package/types/options/loadBabelOptions.d.ts +3 -0
- package/types/options/loadBabelOptions.js +27 -0
- package/types/plugins/babel-transform.d.ts +4 -0
- package/types/plugins/babel-transform.js +49 -0
- package/types/plugins/collector.d.ts +16 -0
- package/types/plugins/collector.js +67 -0
- package/types/plugins/dynamic-import.d.ts +6 -0
- package/types/plugins/dynamic-import.js +32 -0
- package/types/plugins/preeval.d.ts +16 -0
- package/types/plugins/preeval.js +69 -0
- package/types/plugins/shaker.d.ts +11 -0
- package/types/plugins/shaker.js +299 -0
- package/types/shaker.d.ts +3 -0
- package/types/shaker.js +64 -0
- package/types/transform/BaseEntrypoint.d.ts +23 -0
- package/types/transform/BaseEntrypoint.js +182 -0
- package/types/transform/Entrypoint.d.ts +50 -0
- package/types/transform/Entrypoint.helpers.d.ts +14 -0
- package/types/transform/Entrypoint.helpers.js +169 -0
- package/types/transform/Entrypoint.js +223 -0
- package/types/transform/Entrypoint.types.d.ts +23 -0
- package/types/transform/Entrypoint.types.js +2 -0
- package/types/transform/EvaluatedEntrypoint.d.ts +16 -0
- package/types/transform/EvaluatedEntrypoint.js +9 -0
- package/types/transform/actions/AbortError.d.ts +4 -0
- package/types/transform/actions/AbortError.js +12 -0
- package/types/transform/actions/BaseAction.d.ts +40 -0
- package/types/transform/actions/BaseAction.js +149 -0
- package/types/transform/actions/UnprocessedEntrypointError.d.ts +6 -0
- package/types/transform/actions/UnprocessedEntrypointError.js +13 -0
- package/types/transform/actions/actionRunner.d.ts +4 -0
- package/types/transform/actions/actionRunner.js +86 -0
- package/types/transform/actions/types.d.ts +15 -0
- package/types/transform/actions/types.js +2 -0
- package/types/transform/generators/baseProcessingHandlers.d.ts +17 -0
- package/types/transform/generators/baseProcessingHandlers.js +23 -0
- package/types/transform/generators/collect.d.ts +6 -0
- package/types/transform/generators/collect.js +57 -0
- package/types/transform/generators/evalFile.d.ts +6 -0
- package/types/transform/generators/evalFile.js +56 -0
- package/types/transform/generators/explodeReexports.d.ts +7 -0
- package/types/transform/generators/explodeReexports.js +67 -0
- package/types/transform/generators/extract.d.ts +8 -0
- package/types/transform/generators/extract.js +116 -0
- package/types/transform/generators/getExports.d.ts +8 -0
- package/types/transform/generators/getExports.js +65 -0
- package/types/transform/generators/index.d.ts +15 -0
- package/types/transform/generators/index.js +15 -0
- package/types/transform/generators/processEntrypoint.d.ts +9 -0
- package/types/transform/generators/processEntrypoint.js +88 -0
- package/types/transform/generators/processImports.d.ts +5 -0
- package/types/transform/generators/processImports.js +21 -0
- package/types/transform/generators/resolveImports.d.ts +9 -0
- package/types/transform/generators/resolveImports.js +124 -0
- package/types/transform/generators/transform.d.ts +17 -0
- package/types/transform/generators/transform.js +115 -0
- package/types/transform/generators/workflow.d.ts +7 -0
- package/types/transform/generators/workflow.js +77 -0
- package/types/transform/helpers/loadLinariaOptions.d.ts +6 -0
- package/types/transform/helpers/loadLinariaOptions.js +86 -0
- package/types/transform/helpers/withDefaultServices.d.ts +5 -0
- package/types/transform/helpers/withDefaultServices.js +40 -0
- package/types/transform/rootLog.d.ts +3 -0
- package/types/transform/rootLog.js +5 -0
- package/types/transform/types.d.ts +137 -0
- package/types/transform/types.js +4 -0
- package/types/transform.d.ts +20 -0
- package/types/transform.js +121 -0
- package/types/types.d.ts +72 -0
- package/types/types.js +5 -0
- package/types/utils/EventEmitter.d.ts +58 -0
- package/types/utils/EventEmitter.js +61 -0
- package/types/utils/ShakerMetadata.d.ts +7 -0
- package/types/utils/ShakerMetadata.js +5 -0
- package/types/utils/TransformMetadata.d.ts +13 -0
- package/types/utils/TransformMetadata.js +17 -0
- package/types/utils/addIdentifierToLinariaPreval.d.ts +4 -0
- package/types/utils/addIdentifierToLinariaPreval.js +75 -0
- package/types/utils/collectExportsAndImports.d.ts +31 -0
- package/types/utils/collectExportsAndImports.js +962 -0
- package/types/utils/collectTemplateDependencies.d.ts +17 -0
- package/types/utils/collectTemplateDependencies.js +212 -0
- package/types/utils/createId.d.ts +2 -0
- package/types/utils/createId.js +9 -0
- package/types/utils/dispose-polyfill.d.ts +0 -0
- package/types/utils/dispose-polyfill.js +5 -0
- package/types/utils/findIdentifiers.d.ts +6 -0
- package/types/utils/findIdentifiers.js +68 -0
- package/types/utils/findPackageJSON.d.ts +1 -0
- package/types/utils/findPackageJSON.js +29 -0
- package/types/utils/getFileIdx.d.ts +1 -0
- package/types/utils/getFileIdx.js +13 -0
- package/types/utils/getPluginKey.d.ts +2 -0
- package/types/utils/getPluginKey.js +16 -0
- package/types/utils/getScope.d.ts +2 -0
- package/types/utils/getScope.js +11 -0
- package/types/utils/getSource.d.ts +2 -0
- package/types/utils/getSource.js +22 -0
- package/types/utils/getTagProcessor.d.ts +6 -0
- package/types/utils/getTagProcessor.js +315 -0
- package/types/utils/getVisitorKeys.d.ts +5 -0
- package/types/utils/getVisitorKeys.js +8 -0
- package/types/utils/hasLinariaPreval.d.ts +4 -0
- package/types/utils/hasLinariaPreval.js +9 -0
- package/types/utils/isExports.d.ts +6 -0
- package/types/utils/isExports.js +20 -0
- package/types/utils/isGlobal.d.ts +2 -0
- package/types/utils/isGlobal.js +9 -0
- package/types/utils/isNode.d.ts +2 -0
- package/types/utils/isNode.js +7 -0
- package/types/utils/isNodePath.d.ts +3 -0
- package/types/utils/isNodePath.js +7 -0
- package/types/utils/isNotNull.d.ts +1 -0
- package/types/utils/isNotNull.js +7 -0
- package/types/utils/isRemoved.d.ts +5 -0
- package/types/utils/isRemoved.js +42 -0
- package/types/utils/isRequire.d.ts +6 -0
- package/types/utils/isRequire.js +15 -0
- package/types/utils/isSerializable.d.ts +2 -0
- package/types/utils/isSerializable.js +18 -0
- package/types/utils/isTypedNode.d.ts +5 -0
- package/types/utils/isTypedNode.js +9 -0
- package/types/utils/isUnnecessaryReactCall.d.ts +3 -0
- package/types/utils/isUnnecessaryReactCall.js +76 -0
- package/types/utils/peek.d.ts +1 -0
- package/types/utils/peek.js +5 -0
- package/types/utils/processTemplateExpression.d.ts +5 -0
- package/types/utils/processTemplateExpression.js +17 -0
- package/types/utils/removeDangerousCode.d.ts +3 -0
- package/types/utils/removeDangerousCode.js +144 -0
- package/types/utils/scopeHelpers.d.ts +12 -0
- package/types/utils/scopeHelpers.js +568 -0
- package/types/utils/traversalCache.d.ts +5 -0
- package/types/utils/traversalCache.js +36 -0
- package/types/utils/unwrapSequence.d.ts +8 -0
- package/types/utils/unwrapSequence.js +17 -0
- package/types/utils/valueToLiteral.d.ts +3 -0
- package/types/utils/valueToLiteral.js +64 -0
- package/types/utils/visitors/JSXElementsRemover.d.ts +3 -0
- package/types/utils/visitors/JSXElementsRemover.js +52 -0
- package/types/vm/createVmContext.d.ts +7 -0
- package/types/vm/createVmContext.js +92 -0
- package/types/vm/process.d.ts +25 -0
- package/types/vm/process.js +32 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAction.js","names":["Pending","actionIdx","BaseAction","result","activeScenario","activeScenarioNextResults","constructor","type","services","entrypoint","data","abortSignal","idx","toString","padStart","log","extend","ref","createAbortSignal","abortController","AbortController","unsubscribeFromParentAbort","onAbort","abort","unsubscribeFromSupersede","onSupersede","signal","Symbol","dispose","getNext","fn","addEventListener","removeEventListener","run","handler","call","nextIdx","throwFn","e","emitAction","throw","nextFn","arg","next","processNextResult","onError","then","r","done","value","push","processError","length","nextResult","errorInGenerator","recover","activeScenarioError","processNext","rethrowActiveScenarioError","yieldIdx","eventEmitter","action"],"sources":["../../../src/transform/actions/BaseAction.ts"],"sourcesContent":["/* eslint-disable no-plusplus */\nimport '../../utils/dispose-polyfill';\nimport type { Debugger } from '@wyw-in-js/shared';\n\nimport type { Entrypoint } from '../Entrypoint';\nimport type {\n ActionQueueItem,\n ActionTypes,\n AnyIteratorResult,\n AsyncScenarioForAction,\n Handler,\n IBaseAction,\n Services,\n SyncScenarioForAction,\n TypeOfResult,\n YieldResult,\n} from '../types';\nimport { Pending } from '../types';\n\nlet actionIdx = 0;\n\nexport type ActionByType<TType extends ActionTypes> = Extract<\n ActionQueueItem,\n {\n type: TType;\n }\n>;\n\ntype GetBase<TAction extends ActionQueueItem> = IBaseAction<\n TAction,\n TypeOfResult<TAction>,\n TAction['data']\n>;\n\nexport class BaseAction<TAction extends ActionQueueItem>\n implements GetBase<TAction>\n{\n public readonly idx: string;\n\n public result: TypeOfResult<TAction> | typeof Pending = Pending;\n\n private activeScenario:\n | SyncScenarioForAction<TAction>\n | AsyncScenarioForAction<TAction>\n | null = null;\n\n private activeScenarioError?: unknown;\n\n private activeScenarioNextResults: AnyIteratorResult<\n 'async' | 'sync',\n TypeOfResult<TAction>\n >[] = [];\n\n public constructor(\n public readonly type: TAction['type'],\n public readonly services: Services,\n public readonly entrypoint: Entrypoint,\n public readonly data: TAction['data'],\n public readonly abortSignal: AbortSignal | null\n ) {\n actionIdx += 1;\n this.idx = actionIdx.toString(16).padStart(6, '0');\n }\n\n public get log(): Debugger {\n return this.entrypoint.log.extend(this.ref);\n }\n\n public get ref() {\n return `${this.type}@${this.idx}`;\n }\n\n public createAbortSignal(): AbortSignal & Disposable {\n const abortController = new AbortController();\n\n const unsubscribeFromParentAbort = this.onAbort(() => {\n this.entrypoint.log('parent aborted');\n abortController.abort();\n });\n\n const unsubscribeFromSupersede = this.entrypoint.onSupersede(() => {\n this.entrypoint.log('entrypoint superseded, aborting processing');\n abortController.abort();\n });\n\n const abortSignal = abortController.signal as AbortSignal & Disposable;\n abortSignal[Symbol.dispose] = () => {\n unsubscribeFromParentAbort();\n unsubscribeFromSupersede();\n };\n\n return abortSignal;\n }\n\n public *getNext<\n TNextType extends ActionTypes,\n TNextAction extends ActionByType<TNextType> = ActionByType<TNextType>,\n >(\n type: TNextType,\n entrypoint: Entrypoint,\n data: TNextAction['data'],\n abortSignal: AbortSignal | null = this.abortSignal\n ): Generator<\n [TNextType, Entrypoint, TNextAction['data'], AbortSignal | null],\n TypeOfResult<TNextAction>,\n YieldResult\n > {\n return (yield [\n type,\n entrypoint,\n data,\n abortSignal,\n ]) as TypeOfResult<TNextAction>;\n }\n\n public onAbort(fn: () => void): () => void {\n this.abortSignal?.addEventListener('abort', fn);\n\n return () => {\n this.abortSignal?.removeEventListener('abort', fn);\n };\n }\n\n public run<\n TMode extends 'async' | 'sync',\n THandler extends Handler<TMode, TAction> = Handler<TMode, TAction>,\n >(handler: THandler) {\n type IterationResult = AnyIteratorResult<TMode, TypeOfResult<TAction>>;\n\n if (!this.activeScenario) {\n this.activeScenario = handler.call(this);\n this.activeScenarioNextResults = [];\n }\n\n let nextIdx = 0;\n\n const throwFn = (e: unknown) =>\n this.emitAction(nextIdx, () => this.activeScenario!.throw(e));\n\n const nextFn = (arg: YieldResult) =>\n this.emitAction(nextIdx, () => this.activeScenario!.next(arg));\n\n const processNextResult = (\n result: IterationResult,\n onError?: (e: unknown) => void\n ) => {\n if ('then' in result) {\n result.then((r) => {\n if (r.done) {\n this.result = r.value;\n }\n }, onError);\n } else if (result.done) {\n this.result = result.value;\n }\n\n this.activeScenarioNextResults.push(result);\n };\n\n const processError = (e: unknown) => {\n if (this.activeScenarioNextResults.length > nextIdx) {\n this.log(\n 'error was already handled in another branch, result idx is %d',\n nextIdx\n );\n return;\n }\n\n this.log('error processing, result idx is %d', nextIdx);\n\n try {\n const nextResult = throwFn(e);\n processNextResult(nextResult as IterationResult, processError);\n } catch (errorInGenerator) {\n const { recover } = handler;\n if (recover) {\n const nextResult = {\n done: false,\n value: recover(errorInGenerator, this),\n };\n\n processNextResult(nextResult as IterationResult, processError);\n return;\n }\n\n this.activeScenarioError = errorInGenerator;\n throw errorInGenerator;\n }\n };\n\n const processNext = (arg: YieldResult) => {\n if (this.activeScenarioNextResults.length > nextIdx) {\n this.log(\n 'next was already handled in another branch, result idx is %d',\n nextIdx\n );\n return;\n }\n\n this.log('next processing, result idx is %d', nextIdx);\n\n try {\n const nextResult = nextFn(arg);\n processNextResult(nextResult as IterationResult, processError);\n } catch (e) {\n processError(e);\n }\n };\n\n return {\n next: (arg: YieldResult): IterationResult => {\n this.rethrowActiveScenarioError();\n processNext(arg);\n return this.activeScenarioNextResults[nextIdx++] as IterationResult;\n },\n throw: (e: unknown): IterationResult => {\n this.rethrowActiveScenarioError();\n processError(e);\n return this.activeScenarioNextResults[nextIdx++] as IterationResult;\n },\n };\n }\n\n protected emitAction<TRes>(yieldIdx: number, fn: () => TRes) {\n return this.services.eventEmitter.action(\n this.type,\n `${this.idx}:${yieldIdx + 1}`,\n this.entrypoint.ref,\n fn\n );\n }\n\n private rethrowActiveScenarioError() {\n if (!this.activeScenarioError) {\n return;\n }\n\n this.log(\n 'scenario has an unhandled error from another branch, rethrow %o',\n this.activeScenarioError\n );\n\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw this.activeScenarioError;\n }\n}\n"],"mappings":"AAAA;AACA,OAAO,8BAA8B;AAgBrC,SAASA,OAAO,QAAQ,UAAU;AAElC,IAAIC,SAAS,GAAG,CAAC;AAejB,OAAO,MAAMC,UAAU,CAEvB;EAGSC,MAAM,GAA2CH,OAAO;EAEvDI,cAAc,GAGX,IAAI;EAIPC,yBAAyB,GAG3B,EAAE;EAEDC,WAAWA,CACAC,IAAqB,EACrBC,QAAkB,EAClBC,UAAsB,EACtBC,IAAqB,EACrBC,WAA+B,EAC/C;IAAA,KALgBJ,IAAqB,GAArBA,IAAqB;IAAA,KACrBC,QAAkB,GAAlBA,QAAkB;IAAA,KAClBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,IAAqB,GAArBA,IAAqB;IAAA,KACrBC,WAA+B,GAA/BA,WAA+B;IAE/CV,SAAS,IAAI,CAAC;IACd,IAAI,CAACW,GAAG,GAAGX,SAAS,CAACY,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EACpD;EAEA,IAAWC,GAAGA,CAAA,EAAa;IACzB,OAAO,IAAI,CAACN,UAAU,CAACM,GAAG,CAACC,MAAM,CAAC,IAAI,CAACC,GAAG,CAAC;EAC7C;EAEA,IAAWA,GAAGA,CAAA,EAAG;IACf,OAAQ,GAAE,IAAI,CAACV,IAAK,IAAG,IAAI,CAACK,GAAI,EAAC;EACnC;EAEOM,iBAAiBA,CAAA,EAA6B;IACnD,MAAMC,eAAe,GAAG,IAAIC,eAAe,CAAC,CAAC;IAE7C,MAAMC,0BAA0B,GAAG,IAAI,CAACC,OAAO,CAAC,MAAM;MAC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AAI,CAAC,IAAI,CAACF,mBAAmB,EAAE;MAC7B;IACF;IAEA,IAAI,CAACzC,GAAG,CACN,iEAAiE,EACjE,IAAI,CAACyC,mBACP,CAAC;;IAED;IACA,MAAM,IAAI,CAACA,mBAAmB;EAChC;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export class UnprocessedEntrypointError extends Error {
|
|
2
|
+
constructor(entrypoint) {
|
|
3
|
+
super(`Entrypoint ${entrypoint.idx} is not processed and can't be evaluated`);
|
|
4
|
+
this.entrypoint = entrypoint;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export const isUnprocessedEntrypointError = value => value instanceof UnprocessedEntrypointError;
|
|
8
|
+
//# sourceMappingURL=UnprocessedEntrypointError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnprocessedEntrypointError.js","names":["UnprocessedEntrypointError","Error","constructor","entrypoint","idx","isUnprocessedEntrypointError","value"],"sources":["../../../src/transform/actions/UnprocessedEntrypointError.ts"],"sourcesContent":["import type { Entrypoint } from '../Entrypoint';\n\nexport class UnprocessedEntrypointError extends Error {\n constructor(public entrypoint: Entrypoint) {\n super(\n `Entrypoint ${entrypoint.idx} is not processed and can't be evaluated`\n );\n }\n}\n\nexport const isUnprocessedEntrypointError = (\n value: unknown\n): value is UnprocessedEntrypointError =>\n value instanceof UnprocessedEntrypointError;\n"],"mappings":"AAEA,OAAO,MAAMA,0BAA0B,SAASC,KAAK,CAAC;EACpDC,WAAWA,CAAQC,UAAsB,EAAE;IACzC,KAAK,CACF,cAAaA,UAAU,CAACC,GAAI,0CAC/B,CAAC;IAAC,KAHeD,UAAsB,GAAtBA,UAAsB;EAIzC;AACF;AAEA,OAAO,MAAME,4BAA4B,GACvCC,KAAc,IAEdA,KAAK,YAAYN,0BAA0B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
|
|
3
|
+
import { Pending } from '../types';
|
|
4
|
+
import { AbortError } from './AbortError';
|
|
5
|
+
function getHandler(action, actionHandlers) {
|
|
6
|
+
const handler = actionHandlers[action.type];
|
|
7
|
+
if (!handler) {
|
|
8
|
+
throw new Error(`No handler for action ${action.type}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// FIXME Handlers<TMode>[TAction['type']] is not assignable to Handler<TMode, TAction>
|
|
12
|
+
return handler;
|
|
13
|
+
}
|
|
14
|
+
const getActionRef = (type, entrypoint) => `${type}@${entrypoint.ref}`;
|
|
15
|
+
const ACTION_ERROR = Symbol('ACTION_ERROR');
|
|
16
|
+
const isActionError = e => Array.isArray(e) && e[0] === ACTION_ERROR;
|
|
17
|
+
export async function asyncActionRunner(action, actionHandlers, stack = [getActionRef(action.type, action.entrypoint)]) {
|
|
18
|
+
if (action.result !== Pending) {
|
|
19
|
+
action.log('result is cached');
|
|
20
|
+
return action.result;
|
|
21
|
+
}
|
|
22
|
+
const handler = getHandler(action, actionHandlers);
|
|
23
|
+
const generator = action.run(handler);
|
|
24
|
+
let actionResult;
|
|
25
|
+
// eslint-disable-next-line no-constant-condition
|
|
26
|
+
while (true) {
|
|
27
|
+
if (action.abortSignal?.aborted) {
|
|
28
|
+
action.log('action is aborted');
|
|
29
|
+
generator.throw(new AbortError(stack[0]));
|
|
30
|
+
}
|
|
31
|
+
const result = await (isActionError(actionResult) ? generator.throw(actionResult[1]) : generator.next(actionResult));
|
|
32
|
+
if (result.done) {
|
|
33
|
+
return result.value;
|
|
34
|
+
}
|
|
35
|
+
const [type, entrypoint, data, abortSignal] = result.value;
|
|
36
|
+
const nextAction = entrypoint.createAction(type, data, abortSignal);
|
|
37
|
+
try {
|
|
38
|
+
actionResult = await asyncActionRunner(nextAction, actionHandlers, [...stack, getActionRef(type, entrypoint)]);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
nextAction.log('error', e);
|
|
41
|
+
actionResult = [ACTION_ERROR, e];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function syncActionRunner(action, actionHandlers, stack = [getActionRef(action.type, action.entrypoint)]) {
|
|
46
|
+
if (action.result !== Pending) {
|
|
47
|
+
action.log('result is cached');
|
|
48
|
+
return action.result;
|
|
49
|
+
}
|
|
50
|
+
const handler = getHandler(action, actionHandlers);
|
|
51
|
+
const generator = action.run(handler);
|
|
52
|
+
let actionResult;
|
|
53
|
+
// eslint-disable-next-line no-constant-condition
|
|
54
|
+
while (true) {
|
|
55
|
+
if (action.abortSignal?.aborted) {
|
|
56
|
+
action.log('action is aborted');
|
|
57
|
+
generator.throw(new AbortError(stack[0]));
|
|
58
|
+
}
|
|
59
|
+
const result = isActionError(actionResult) ? generator.throw(actionResult[1]) : generator.next(actionResult);
|
|
60
|
+
if (result.done) {
|
|
61
|
+
return result.value;
|
|
62
|
+
}
|
|
63
|
+
const [type, entrypoint, data, abortSignal] = result.value;
|
|
64
|
+
const nextAction = entrypoint.createAction(type, data, abortSignal);
|
|
65
|
+
try {
|
|
66
|
+
actionResult = syncActionRunner(nextAction, actionHandlers, [...stack, getActionRef(type, entrypoint)]);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
nextAction.log('error', e);
|
|
69
|
+
actionResult = [ACTION_ERROR, e];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=actionRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionRunner.js","names":["Pending","AbortError","getHandler","action","actionHandlers","handler","type","Error","getActionRef","entrypoint","ref","ACTION_ERROR","Symbol","isActionError","e","Array","isArray","asyncActionRunner","stack","result","log","generator","run","actionResult","abortSignal","aborted","throw","next","done","value","data","nextAction","createAction","syncActionRunner"],"sources":["../../../src/transform/actions/actionRunner.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport type {\n ActionQueueItem,\n Handler,\n Handlers,\n TypeOfResult,\n} from '../types';\nimport { Pending } from '../types';\n\nimport { AbortError } from './AbortError';\nimport type { BaseAction } from './BaseAction';\n\nfunction getHandler<\n TMode extends 'async' | 'sync',\n TAction extends ActionQueueItem,\n>(\n action: BaseAction<TAction>,\n actionHandlers: Handlers<TMode>\n): Handler<TMode, TAction> {\n const handler = actionHandlers[action.type];\n if (!handler) {\n throw new Error(`No handler for action ${action.type}`);\n }\n\n // FIXME Handlers<TMode>[TAction['type']] is not assignable to Handler<TMode, TAction>\n return handler as unknown as Handler<TMode, TAction>;\n}\n\nconst getActionRef = (type: string, entrypoint: { ref: string }) =>\n `${type}@${entrypoint.ref}`;\n\nconst ACTION_ERROR = Symbol('ACTION_ERROR');\ntype ActionError = [marker: typeof ACTION_ERROR, err: unknown];\nconst isActionError = (e: unknown): e is ActionError =>\n Array.isArray(e) && e[0] === ACTION_ERROR;\n\nexport async function asyncActionRunner<TAction extends ActionQueueItem>(\n action: BaseAction<TAction>,\n actionHandlers: Handlers<'async' | 'sync'>,\n stack: string[] = [getActionRef(action.type, action.entrypoint)]\n): Promise<TypeOfResult<TAction>> {\n if (action.result !== Pending) {\n action.log('result is cached');\n return action.result as TypeOfResult<TAction>;\n }\n\n const handler = getHandler(action, actionHandlers);\n const generator = action.run<'async' | 'sync'>(handler);\n let actionResult: TypeOfResult<ActionQueueItem> | ActionError | undefined;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (action.abortSignal?.aborted) {\n action.log('action is aborted');\n generator.throw(new AbortError(stack[0]));\n }\n\n const result = await (isActionError(actionResult)\n ? generator.throw(actionResult[1])\n : generator.next(actionResult));\n if (result.done) {\n return result.value as TypeOfResult<TAction>;\n }\n\n const [type, entrypoint, data, abortSignal] = result.value;\n const nextAction = entrypoint.createAction(type, data, abortSignal);\n\n try {\n actionResult = await asyncActionRunner(nextAction, actionHandlers, [\n ...stack,\n getActionRef(type, entrypoint),\n ]);\n } catch (e) {\n nextAction.log('error', e);\n actionResult = [ACTION_ERROR, e];\n }\n }\n}\n\nexport function syncActionRunner<TAction extends ActionQueueItem>(\n action: BaseAction<TAction>,\n actionHandlers: Handlers<'sync'>,\n stack: string[] = [getActionRef(action.type, action.entrypoint)]\n): TypeOfResult<TAction> {\n if (action.result !== Pending) {\n action.log('result is cached');\n return action.result as TypeOfResult<TAction>;\n }\n\n const handler = getHandler(action, actionHandlers);\n const generator = action.run<'sync'>(handler);\n let actionResult: TypeOfResult<ActionQueueItem> | ActionError | undefined;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (action.abortSignal?.aborted) {\n action.log('action is aborted');\n generator.throw(new AbortError(stack[0]));\n }\n\n const result = isActionError(actionResult)\n ? generator.throw(actionResult[1])\n : generator.next(actionResult);\n if (result.done) {\n return result.value as TypeOfResult<TAction>;\n }\n\n const [type, entrypoint, data, abortSignal] = result.value;\n const nextAction = entrypoint.createAction(type, data, abortSignal);\n\n try {\n actionResult = syncActionRunner(nextAction, actionHandlers, [\n ...stack,\n getActionRef(type, entrypoint),\n ]);\n } catch (e) {\n nextAction.log('error', e);\n actionResult = [ACTION_ERROR, e];\n }\n }\n}\n"],"mappings":"AAAA;;AAOA,SAASA,OAAO,QAAQ,UAAU;AAElC,SAASC,UAAU,QAAQ,cAAc;AAGzC,SAASC,UAAUA,CAIjBC,MAA2B,EAC3BC,cAA+B,EACN;EACzB,MAAMC,OAAO,GAAGD,cAAc,CAACD,MAAM,CAACG,IAAI,CAAC;EAC3C,IAAI,CAACD,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAE,yBAAwBJ,MAAM,CAACG,IAAK,EAAC,CAAC;EACzD;;EAEA;EACA,OAAOD,OAAO;AAChB;AAEA,MAAMG,YAAY,GAAGA,CAACF,IAAY,EAAEG,UAA2B,KAC5D,GAAEH,IAAK,IAAGG,UAAU,CAACC,GAAI,EAAC;AAE7B,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAE3C,MAAMC,aAAa,GAAIC,CAAU,IAC/BC,KAAK,CAACC,OAAO,CAACF,CAAC,CAAC,IAAIA,CAAC,CAA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,CAACU,KAAK;IAC1D,MAAME,UAAU,GAAGtB,UAAU,CAACuB,YAAY,CAAC1B,IAAI,EAAEwB,IAAI,EAAEN,WAAW,CAAC;IAEnE,IAAI;MACFD,YAAY,GAAGU,gBAAgB,CAACF,UAAU,EAAE3B,cAAc,EAAE,CAC1D,GAAGc,KAAK,EACRV,YAAY,CAACF,IAAI,EAAEG,UAAU,CAAC,CAC/B,CAAC;IACJ,CAAC,CAAC,OAAOK,CAAC,EAAE;MACViB,UAAU,CAACX,GAAG,CAAC,OAAO,EAAEN,CAAC,CAAC;MAC1BS,YAAY,GAAG,CAACZ,YAAY,EAAEG,CAAC,CAAC;IAClC;EACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/transform/actions/types.ts"],"sourcesContent":["import type { BabelFileResult } from '@babel/core';\n\nimport type { Replacements, Rules } from '@wyw-in-js/shared';\n\nexport interface IExtracted {\n cssSourceMapText: string;\n cssText: string;\n replacements: Replacements;\n rules: Rules;\n}\n\nexport interface IWorkflowActionNonLinariaResult {\n code: string;\n sourceMap: BabelFileResult['map'];\n}\n\nexport interface IWorkflowActionLinariaResult\n extends IExtracted,\n IWorkflowActionNonLinariaResult {\n dependencies: string[];\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { explodeReexports } from './explodeReexports';
|
|
2
|
+
import { getExports } from './getExports';
|
|
3
|
+
import { processEntrypoint } from './processEntrypoint';
|
|
4
|
+
import { processImports } from './processImports';
|
|
5
|
+
import { transform } from './transform';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line require-yield
|
|
8
|
+
function* emptyHandler() {
|
|
9
|
+
throw new Error(`Handler for ${this.type} is not implemented`);
|
|
10
|
+
}
|
|
11
|
+
export const baseProcessingHandlers = {
|
|
12
|
+
collect: emptyHandler,
|
|
13
|
+
evalFile: emptyHandler,
|
|
14
|
+
extract: emptyHandler,
|
|
15
|
+
workflow: emptyHandler,
|
|
16
|
+
explodeReexports,
|
|
17
|
+
getExports,
|
|
18
|
+
processEntrypoint,
|
|
19
|
+
processImports,
|
|
20
|
+
transform
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=baseProcessingHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseProcessingHandlers.js","names":["explodeReexports","getExports","processEntrypoint","processImports","transform","emptyHandler","Error","type","baseProcessingHandlers","collect","evalFile","extract","workflow"],"sources":["../../../src/transform/generators/baseProcessingHandlers.ts"],"sourcesContent":["import type {\n SyncScenarioForAction,\n ICollectAction,\n IEvalAction,\n IExtractAction,\n IWorkflowAction,\n ActionQueueItem,\n} from '../types';\n\nimport { explodeReexports } from './explodeReexports';\nimport { getExports } from './getExports';\nimport { processEntrypoint } from './processEntrypoint';\nimport { processImports } from './processImports';\nimport { transform } from './transform';\n\n// eslint-disable-next-line require-yield\nfunction* emptyHandler<T extends ActionQueueItem>(\n this: T\n): SyncScenarioForAction<T> {\n throw new Error(`Handler for ${this.type} is not implemented`);\n}\n\nexport const baseProcessingHandlers = {\n collect: emptyHandler<ICollectAction>,\n evalFile: emptyHandler<IEvalAction>,\n extract: emptyHandler<IExtractAction>,\n workflow: emptyHandler<IWorkflowAction>,\n explodeReexports,\n getExports,\n processEntrypoint,\n processImports,\n transform,\n};\n"],"mappings":"AASA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,SAAS,QAAQ,aAAa;;AAEvC;AACA,UAAUC,YAAYA,CAAA,EAEM;EAC1B,MAAM,IAAIC,KAAK,CAAE,eAAc,IAAI,CAACC,IAAK,qBAAoB,CAAC;AAChE;AAEA,OAAO,MAAMC,sBAAsB,GAAG;EACpCC,OAAO,EAAEJ,YAA4B;EACrCK,QAAQ,EAAEL,YAAyB;EACnCM,OAAO,EAAEN,YAA4B;EACrCO,QAAQ,EAAEP,YAA6B;EACvCL,gBAAgB;EAChBC,UAAU;EACVC,iBAAiB;EACjBC,cAAc;EACdC;AACF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { buildOptions } from '../../options/buildOptions';
|
|
2
|
+
import { filename as collectorPlugin } from '../../plugins/collector';
|
|
3
|
+
import { getTransformMetadata } from '../../utils/TransformMetadata';
|
|
4
|
+
/**
|
|
5
|
+
* Parses the specified file, finds tags, applies run-time replacements,
|
|
6
|
+
* removes dead code.
|
|
7
|
+
*/ // eslint-disable-next-line require-yield
|
|
8
|
+
export function* collect() {
|
|
9
|
+
const {
|
|
10
|
+
babel,
|
|
11
|
+
options
|
|
12
|
+
} = this.services;
|
|
13
|
+
const {
|
|
14
|
+
valueCache
|
|
15
|
+
} = this.data;
|
|
16
|
+
const {
|
|
17
|
+
entrypoint
|
|
18
|
+
} = this;
|
|
19
|
+
const {
|
|
20
|
+
loadedAndParsed,
|
|
21
|
+
name
|
|
22
|
+
} = entrypoint;
|
|
23
|
+
if (loadedAndParsed.evaluator === 'ignored') {
|
|
24
|
+
throw new Error('entrypoint was ignored');
|
|
25
|
+
}
|
|
26
|
+
const transformPlugins = [[collectorPlugin, {
|
|
27
|
+
...options.pluginOptions,
|
|
28
|
+
values: valueCache
|
|
29
|
+
}]];
|
|
30
|
+
const transformConfig = buildOptions({
|
|
31
|
+
envName: 'linaria',
|
|
32
|
+
plugins: transformPlugins,
|
|
33
|
+
sourceMaps: true,
|
|
34
|
+
sourceFileName: name,
|
|
35
|
+
inputSourceMap: options.inputSourceMap,
|
|
36
|
+
root: options.root,
|
|
37
|
+
ast: true,
|
|
38
|
+
babelrc: false,
|
|
39
|
+
configFile: false,
|
|
40
|
+
sourceType: 'unambiguous'
|
|
41
|
+
});
|
|
42
|
+
const result = babel.transformFromAstSync(loadedAndParsed.ast, loadedAndParsed.code, {
|
|
43
|
+
...transformConfig,
|
|
44
|
+
cwd: options.root,
|
|
45
|
+
filename: name
|
|
46
|
+
});
|
|
47
|
+
if (!result || !result.ast?.program) {
|
|
48
|
+
throw new Error('Babel transform failed');
|
|
49
|
+
}
|
|
50
|
+
const transformMetadata = getTransformMetadata(result.metadata);
|
|
51
|
+
return {
|
|
52
|
+
ast: result.ast,
|
|
53
|
+
code: result.code,
|
|
54
|
+
map: result.map,
|
|
55
|
+
metadata: transformMetadata ?? null
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=collect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect.js","names":["buildOptions","filename","collectorPlugin","getTransformMetadata","collect","babel","options","services","valueCache","data","entrypoint","loadedAndParsed","name","evaluator","Error","transformPlugins","pluginOptions","values","transformConfig","envName","plugins","sourceMaps","sourceFileName","inputSourceMap","root","ast","babelrc","configFile","sourceType","result","transformFromAstSync","code","cwd","program","transformMetadata","metadata","map"],"sources":["../../../src/transform/generators/collect.ts"],"sourcesContent":["import type { PluginItem } from '@babel/core';\n\nimport { buildOptions } from '../../options/buildOptions';\nimport { filename as collectorPlugin } from '../../plugins/collector';\nimport { getTransformMetadata } from '../../utils/TransformMetadata';\nimport type { ICollectAction, SyncScenarioForAction } from '../types';\n\n/**\n * Parses the specified file, finds tags, applies run-time replacements,\n * removes dead code.\n */\n// eslint-disable-next-line require-yield\nexport function* collect(\n this: ICollectAction\n): SyncScenarioForAction<ICollectAction> {\n const { babel, options } = this.services;\n const { valueCache } = this.data;\n const { entrypoint } = this;\n const { loadedAndParsed, name } = entrypoint;\n\n if (loadedAndParsed.evaluator === 'ignored') {\n throw new Error('entrypoint was ignored');\n }\n\n const transformPlugins: PluginItem[] = [\n [\n collectorPlugin,\n {\n ...options.pluginOptions,\n values: valueCache,\n },\n ],\n ];\n\n const transformConfig = buildOptions({\n envName: 'linaria',\n plugins: transformPlugins,\n sourceMaps: true,\n sourceFileName: name,\n inputSourceMap: options.inputSourceMap,\n root: options.root,\n ast: true,\n babelrc: false,\n configFile: false,\n sourceType: 'unambiguous',\n });\n\n const result = babel.transformFromAstSync(\n loadedAndParsed.ast,\n loadedAndParsed.code,\n {\n ...transformConfig,\n cwd: options.root,\n filename: name,\n }\n );\n\n if (!result || !result.ast?.program) {\n throw new Error('Babel transform failed');\n }\n\n const transformMetadata = getTransformMetadata(result.metadata);\n\n return {\n ast: result.ast,\n code: result.code,\n map: result.map,\n metadata: transformMetadata ?? null,\n };\n}\n"],"mappings":"AAEA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,QAAQ,IAAIC,eAAe,QAAQ,yBAAyB;AACrE,SAASC,oBAAoB,QAAQ,+BAA+B;AAGpE;AACA;AACA;AACA,GAHA,CAIA;AACA,OAAO,UAAUC,OAAOA,CAAA,EAEiB;EACvC,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAG,IAAI,CAACC,QAAQ;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAI,CAACC,IAAI;EAChC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAI;EAC3B,MAAM;IAAEC,eAAe;IAAEC;EAAK,CAAC,GAAGF,UAAU;EAE5C,IAAIC,eAAe,CAACE,SAAS,KAAK,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,wBAAwB,CAAC;EAC3C;EAEA,MAAMC,gBAA8B,GAAG,CACrC,CACEb,eAAe,EACf;IACE,GAAGI,OAAO,CAACU,aAAa;IACxBC,MAAM,EAAET;EACV,CAAC,CACF,CACF;EAED,MAAMU,eAAe,GAAGlB,YAAY,CAAC;IACnCmB,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAEL,gBAAgB;IACzBM,UAAU,EAAE,IAAI;IAChBC,cAAc,EAAEV,IAAI;IACpBW,cAAc,EAAEjB,OAAO,CAACiB,cAAc;IACtCC,IAAI,EAAElB,OAAO,CAACkB,IAAI;IAClBC,GAAG,EAAE,IAAI;IACTC,OAAO,EAAE,KAAK;IACdC,UAAU,EAAE,KAAK;IACjBC,UAAU,EAAE;EACd,CAAC,CAAC;EAEF,MAAMC,MAAM,GAAGxB,KAAK,CAACyB,oBAAoB,CACvCnB,eAAe,CAACc,GAAG,EACnBd,eAAe,CAACoB,IAAI,EACpB;IACE,GAAGb,eAAe;IAClBc,GAAG,EAAE1B,OAAO,CAACkB,IAAI;IACjBvB,QAAQ,EAAEW;EACZ,CACF,CAAC;EAED,IAAI,CAACiB,MAAM,IAAI,CAACA,MAAM,CAACJ,GAAG,EAAEQ,OAAO,EAAE;IACnC,MAAM,IAAInB,KAAK,CAAC,wBAAwB,CAAC;EAC3C;EAEA,MAAMoB,iBAAiB,GAAG/B,oBAAoB,CAAC0B,MAAM,CAACM,QAAQ,CAAC;EAE/D,OAAO;IACLV,GAAG,EAAEI,MAAM,CAACJ,GAAG;IACfM,IAAI,EAAEF,MAAM,CAACE,IAAI;IACjBK,GAAG,EAAEP,MAAM,CAACO,GAAG;IACfD,QAAQ,EAAED,iBAAiB,IAAI;EACjC,CAAC;AACH"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import evaluate from '../../evaluators';
|
|
2
|
+
import hasLinariaPreval from '../../utils/hasLinariaPreval';
|
|
3
|
+
import { isUnprocessedEntrypointError } from '../actions/UnprocessedEntrypointError';
|
|
4
|
+
const wrap = fn => {
|
|
5
|
+
try {
|
|
6
|
+
return fn();
|
|
7
|
+
} catch (e) {
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Executes the code prepared in previous steps within the current `Entrypoint`.
|
|
14
|
+
* Returns all exports that were requested in `only`.
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line require-yield
|
|
17
|
+
export function* evalFile() {
|
|
18
|
+
const {
|
|
19
|
+
entrypoint
|
|
20
|
+
} = this;
|
|
21
|
+
const {
|
|
22
|
+
log
|
|
23
|
+
} = entrypoint;
|
|
24
|
+
log(`>> evaluate __linariaPreval`);
|
|
25
|
+
let evaluated;
|
|
26
|
+
while (evaluated === undefined) {
|
|
27
|
+
try {
|
|
28
|
+
evaluated = evaluate(this.services, entrypoint);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (isUnprocessedEntrypointError(e)) {
|
|
31
|
+
entrypoint.log('Evaluation has been aborted because one if the required files is not processed. Schedule reprocessing and repeat evaluation.');
|
|
32
|
+
yield ['processEntrypoint', e.entrypoint, undefined];
|
|
33
|
+
} else {
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const linariaPreval = hasLinariaPreval(evaluated.value) ? evaluated.value.__linariaPreval : undefined;
|
|
39
|
+
if (!linariaPreval) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const valueCache = new Map();
|
|
43
|
+
Object.entries(linariaPreval).forEach(([key, lazyValue]) => {
|
|
44
|
+
const value = wrap(lazyValue);
|
|
45
|
+
valueCache.set(key, value);
|
|
46
|
+
});
|
|
47
|
+
log(`<< evaluated __linariaPreval %O`, valueCache);
|
|
48
|
+
return [valueCache, evaluated.dependencies];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=evalFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evalFile.js","names":["evaluate","hasLinariaPreval","isUnprocessedEntrypointError","wrap","fn","e","evalFile","entrypoint","log","evaluated","undefined","services","linariaPreval","value","__linariaPreval","valueCache","Map","Object","entries","forEach","key","lazyValue","set","dependencies"],"sources":["../../../src/transform/generators/evalFile.ts"],"sourcesContent":["import type { ValueCache } from '@wyw-in-js/processor-utils';\n\nimport type { IEvaluateResult } from '../../evaluators';\nimport evaluate from '../../evaluators';\nimport hasLinariaPreval from '../../utils/hasLinariaPreval';\nimport { isUnprocessedEntrypointError } from '../actions/UnprocessedEntrypointError';\nimport type { IEvalAction, SyncScenarioForAction } from '../types';\n\nconst wrap = <T>(fn: () => T): T | Error => {\n try {\n return fn();\n } catch (e) {\n return e as Error;\n }\n};\n\n/**\n * Executes the code prepared in previous steps within the current `Entrypoint`.\n * Returns all exports that were requested in `only`.\n */\n// eslint-disable-next-line require-yield\nexport function* evalFile(\n this: IEvalAction\n): SyncScenarioForAction<IEvalAction> {\n const { entrypoint } = this;\n const { log } = entrypoint;\n\n log(`>> evaluate __linariaPreval`);\n\n let evaluated: IEvaluateResult | undefined;\n\n while (evaluated === undefined) {\n try {\n evaluated = evaluate(this.services, entrypoint);\n } catch (e) {\n if (isUnprocessedEntrypointError(e)) {\n entrypoint.log(\n 'Evaluation has been aborted because one if the required files is not processed. Schedule reprocessing and repeat evaluation.'\n );\n yield ['processEntrypoint', e.entrypoint, undefined];\n } else {\n throw e;\n }\n }\n }\n\n const linariaPreval = hasLinariaPreval(evaluated.value)\n ? evaluated.value.__linariaPreval\n : undefined;\n\n if (!linariaPreval) {\n return null;\n }\n\n const valueCache: ValueCache = new Map();\n Object.entries(linariaPreval).forEach(([key, lazyValue]) => {\n const value = wrap(lazyValue);\n valueCache.set(key, value);\n });\n\n log(`<< evaluated __linariaPreval %O`, valueCache);\n\n return [valueCache, evaluated.dependencies];\n}\n"],"mappings":"AAGA,OAAOA,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,gBAAgB,MAAM,8BAA8B;AAC3D,SAASC,4BAA4B,QAAQ,uCAAuC;AAGpF,MAAMC,IAAI,GAAOC,EAAW,IAAgB;EAC1C,IAAI;IACF,OAAOA,EAAE,CAAC,CAAC;EACb,CAAC,CAAC,OAAOC,CAAC,EAAE;IACV,OAAOA,CAAC;EACV;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,UAAUC,QAAQA,CAAA,EAEa;EACpC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAI;EAC3B,MAAM;IAAEC;EAAI,CAAC,GAAGD,UAAU;EAE1BC,GAAG,CAAE,6BAA4B,CAAC;EAElC,IAAIC,SAAsC;EAE1C,OAAOA,SAAS,KAAKC,SAAS,EAAE;IAC9B,IAAI;MACFD,SAAS,GAAGT,QAAQ,CAAC,IAAI,CAACW,QAAQ,EAAEJ,UAAU,CAAC;IACjD,CAAC,CAAC,OAAOF,CAAC,EAAE;MACV,IAAIH,4BAA4B,CAACG,CAAC,CAAC,EAAE;QACnCE,UAAU,CAACC,GAAG,CACZ,8HACF,CAAC;QACD,MAAM,CAAC,mBAAmB,EAAEH,CAAC,CAACE,UAAU,EAAEG,SAAS,CAAC;MACtD,CAAC,MAAM;QACL,MAAML,CAAC;MACT;IACF;EACF;EAEA,MAAMO,aAAa,GAAGX,gBAAgB,CAACQ,SAAS,CAACI,KAAK,CAAC,GACnDJ,SAAS,CAACI,KAAK,CAACC,eAAe,GAC/BJ,SAAS;EAEb,IAAI,CAACE,aAAa,EAAE;IAClB,OAAO,IAAI;EACb;EAEA,MAAMG,UAAsB,GAAG,IAAIC,GAAG,CAAC,CAAC;EACxCC,MAAM,CAACC,OAAO,CAACN,aAAa,CAAC,CAACO,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,SAAS,CAAC,KAAK;IAC1D,MAAMR,KAAK,GAAGV,IAAI,CAACkB,SAAS,CAAC;IAC7BN,UAAU,CAACO,GAAG,CAACF,GAAG,EAAEP,KAAK,CAAC;EAC5B,CAAC,CAAC;EAEFL,GAAG,CAAE,iCAAgC,EAAEO,UAAU,CAAC;EAElD,OAAO,CAACA,UAAU,EAAEN,SAAS,CAACc,YAAY,CAAC;AAC7C"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import generate from '@babel/generator';
|
|
2
|
+
import { findExportsInImports } from './getExports';
|
|
3
|
+
const getWildcardReexport = (babel, ast) => {
|
|
4
|
+
const reexportsFrom = [];
|
|
5
|
+
ast.program.body.forEach(node => {
|
|
6
|
+
if (babel.types.isExportAllDeclaration(node) && node.source && babel.types.isStringLiteral(node.source)) {
|
|
7
|
+
reexportsFrom.push({
|
|
8
|
+
source: node.source.value,
|
|
9
|
+
node
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return reexportsFrom;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Replaces wildcard reexports with named reexports.
|
|
18
|
+
* Recursively emits getExports for each reexported module,
|
|
19
|
+
* and replaces wildcard with resolved named.
|
|
20
|
+
*/
|
|
21
|
+
export function* explodeReexports() {
|
|
22
|
+
const {
|
|
23
|
+
babel
|
|
24
|
+
} = this.services;
|
|
25
|
+
const {
|
|
26
|
+
log,
|
|
27
|
+
loadedAndParsed
|
|
28
|
+
} = this.entrypoint;
|
|
29
|
+
if (loadedAndParsed.evaluator === 'ignored') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);
|
|
33
|
+
if (!reexportsFrom.length) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
log('has wildcard reexport from %o', reexportsFrom);
|
|
37
|
+
const resolvedImports = yield* this.getNext('resolveImports', this.entrypoint, {
|
|
38
|
+
imports: new Map(reexportsFrom.map(i => [i.source, []]))
|
|
39
|
+
});
|
|
40
|
+
const importedEntrypoints = findExportsInImports(this.entrypoint, resolvedImports);
|
|
41
|
+
const replacements = new Map();
|
|
42
|
+
for (const importedEntrypoint of importedEntrypoints) {
|
|
43
|
+
const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
|
|
44
|
+
const reexport = reexportsFrom.find(i => i.source === importedEntrypoint.import);
|
|
45
|
+
if (reexport) {
|
|
46
|
+
replacements.set(reexport.node, exports.length ? babel.types.exportNamedDeclaration(null, exports.map(i => babel.types.exportSpecifier(babel.types.identifier(i), babel.types.identifier(i))), babel.types.stringLiteral(importedEntrypoint.import)) : null);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Replace wildcard reexport with named reexports
|
|
51
|
+
babel.traverse(loadedAndParsed.ast, {
|
|
52
|
+
ExportAllDeclaration(path) {
|
|
53
|
+
const replacement = replacements.get(path.node);
|
|
54
|
+
if (replacement) {
|
|
55
|
+
path.replaceWith(replacement);
|
|
56
|
+
} else {
|
|
57
|
+
path.remove();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
loadedAndParsed.code = generate(loadedAndParsed.ast).code;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=explodeReexports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explodeReexports.js","names":["generate","findExportsInImports","getWildcardReexport","babel","ast","reexportsFrom","program","body","forEach","node","types","isExportAllDeclaration","source","isStringLiteral","push","value","explodeReexports","services","log","loadedAndParsed","entrypoint","evaluator","length","resolvedImports","getNext","imports","Map","map","i","importedEntrypoints","replacements","importedEntrypoint","exports","undefined","reexport","find","import","set","exportNamedDeclaration","exportSpecifier","identifier","stringLiteral","traverse","ExportAllDeclaration","path","replacement","get","replaceWith","remove","code"],"sources":["../../../src/transform/generators/explodeReexports.ts"],"sourcesContent":["import generate from '@babel/generator';\nimport type { ExportAllDeclaration, File, Node } from '@babel/types';\n\nimport type { Core } from '../../babel';\nimport type { IExplodeReexportsAction, SyncScenarioForAction } from '../types';\n\nimport { findExportsInImports } from './getExports';\n\nconst getWildcardReexport = (babel: Core, ast: File) => {\n const reexportsFrom: { node: ExportAllDeclaration; source: string }[] = [];\n ast.program.body.forEach((node) => {\n if (\n babel.types.isExportAllDeclaration(node) &&\n node.source &&\n babel.types.isStringLiteral(node.source)\n ) {\n reexportsFrom.push({\n source: node.source.value,\n node,\n });\n }\n });\n\n return reexportsFrom;\n};\n\n/**\n * Replaces wildcard reexports with named reexports.\n * Recursively emits getExports for each reexported module,\n * and replaces wildcard with resolved named.\n */\nexport function* explodeReexports(\n this: IExplodeReexportsAction\n): SyncScenarioForAction<IExplodeReexportsAction> {\n const { babel } = this.services;\n const { log, loadedAndParsed } = this.entrypoint;\n if (loadedAndParsed.evaluator === 'ignored') {\n return;\n }\n\n const reexportsFrom = getWildcardReexport(babel, loadedAndParsed.ast);\n if (!reexportsFrom.length) {\n return;\n }\n\n log('has wildcard reexport from %o', reexportsFrom);\n\n const resolvedImports = yield* this.getNext(\n 'resolveImports',\n this.entrypoint,\n {\n imports: new Map(reexportsFrom.map((i) => [i.source, []])),\n }\n );\n\n const importedEntrypoints = findExportsInImports(\n this.entrypoint,\n resolvedImports\n );\n\n const replacements = new Map<ExportAllDeclaration, Node | null>();\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n const reexport = reexportsFrom.find(\n (i) => i.source === importedEntrypoint.import\n );\n if (reexport) {\n replacements.set(\n reexport.node,\n exports.length\n ? babel.types.exportNamedDeclaration(\n null,\n exports.map((i) =>\n babel.types.exportSpecifier(\n babel.types.identifier(i),\n babel.types.identifier(i)\n )\n ),\n babel.types.stringLiteral(importedEntrypoint.import)\n )\n : null\n );\n }\n }\n\n // Replace wildcard reexport with named reexports\n babel.traverse(loadedAndParsed.ast, {\n ExportAllDeclaration(path) {\n const replacement = replacements.get(path.node);\n if (replacement) {\n path.replaceWith(replacement);\n } else {\n path.remove();\n }\n },\n });\n\n loadedAndParsed.code = generate(loadedAndParsed.ast).code;\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAMvC,SAASC,oBAAoB,QAAQ,cAAc;AAEnD,MAAMC,mBAAmB,GAAGA,CAACC,KAAW,EAAEC,GAAS,KAAK;EACtD,MAAMC,aAA+D,GAAG,EAAE;EAC1ED,GAAG,CAACE,OAAO,CAACC,IAAI,CAACC,OAAO,CAAEC,IAAI,IAAK;IACjC,IACEN,KAAK,CAACO,KAAK,CAACC,sBAAsB,CAACF,IAAI,CAAC,IACxCA,IAAI,CAACG,MAAM,IACXT,KAAK,CAACO,KAAK,CAACG,eAAe,CAACJ,IAAI,CAACG,MAAM,CAAC,EACxC;MACAP,aAAa,CAACS,I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IACD,IAAIF,QAAQ,EAAE;MACZJ,YAAY,CAACO,GAAG,CACdH,QAAQ,CAACzB,IAAI,EACbuB,OAAO,CAACV,MAAM,GACVnB,KAAK,CAACO,KAAK,CAAC4B,sBAAsB,CAChC,IAAI,EACJN,OAAO,CAACL,GAAG,CAAEC,CAAC,IACZzB,KAAK,CAACO,KAAK,CAAC6B,eAAe,CACzBpC,KAAK,CAACO,KAAK,CAAC8B,UAAU,CAACZ,CAAC,CAAC,EACzBzB,KAAK,CAACO,KAAK,CAAC8B,UAAU,CAACZ,CAAC,CAC1B,CACF,CAAC,EACDzB,KAAK,CAACO,KAAK,CAAC+B,aAAa,CAACV,kBAAkB,CAACK,MAAM,CACrD,CAAC,GACD,IACN,CAAC;IACH;EACF;;EAEA;EACAjC,KAAK,CAACuC,QAAQ,CAACvB,eAAe,CAACf,GAAG,EAAE;IAClCuC,oBAAoBA,CAACC,IAAI,EAAE;MACzB,MAAMC,WAAW,GAAGf,YAAY,CAACgB,GAAG,CAACF,IAAI,CAACnC,IAAI,CAAC;MAC/C,IAAIoC,WAAW,EAAE;QACfD,IAAI,CAACG,WAAW,CAACF,WAAW,CAAC;MAC/B,CAAC,MAAM;QACLD,IAAI,CAACI,MAAM,CAAC,CAAC;MACf;IACF;EACF,CAAC,CAAC;EAEF7B,eAAe,CAAC8B,IAAI,GAAGjD,QAAQ,CAACmB,eAAe,CAACf,GAAG,CAAC,CAAC6C,IAAI;AAC3D"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { SourceMapGenerator } from 'source-map';
|
|
3
|
+
import stylis from 'stylis';
|
|
4
|
+
const STYLIS_DECLARATION = 1;
|
|
5
|
+
const posixSep = path.posix.sep;
|
|
6
|
+
export function transformUrl(url, outputFilename, sourceFilename, platformPath = path) {
|
|
7
|
+
// Replace asset path with new path relative to the output CSS
|
|
8
|
+
const relative = platformPath.relative(platformPath.dirname(outputFilename),
|
|
9
|
+
// Get the absolute path to the asset from the path relative to the JS file
|
|
10
|
+
platformPath.resolve(platformPath.dirname(sourceFilename), url));
|
|
11
|
+
if (platformPath.sep === posixSep) {
|
|
12
|
+
return relative;
|
|
13
|
+
}
|
|
14
|
+
return relative.split(platformPath.sep).join(posixSep);
|
|
15
|
+
}
|
|
16
|
+
function extractCssFromAst(rules, originalCode, options) {
|
|
17
|
+
const mappings = [];
|
|
18
|
+
let cssText = '';
|
|
19
|
+
let preprocessor;
|
|
20
|
+
if (typeof options.preprocessor === 'function') {
|
|
21
|
+
// eslint-disable-next-line prefer-destructuring
|
|
22
|
+
preprocessor = options.preprocessor;
|
|
23
|
+
} else {
|
|
24
|
+
switch (options.preprocessor) {
|
|
25
|
+
case 'none':
|
|
26
|
+
preprocessor = (selector, text) => `${selector} {${text}}\n`;
|
|
27
|
+
break;
|
|
28
|
+
case 'stylis':
|
|
29
|
+
default:
|
|
30
|
+
stylis.use(null)((context, decl) => {
|
|
31
|
+
const {
|
|
32
|
+
outputFilename
|
|
33
|
+
} = options;
|
|
34
|
+
if (context === STYLIS_DECLARATION && outputFilename) {
|
|
35
|
+
// When writing to a file, we need to adjust the relative paths inside url(..) expressions
|
|
36
|
+
// It'll allow css-loader to resolve an imported asset properly
|
|
37
|
+
return decl.replace(/\b(url\((["']?))(\.[^)]+?)(\2\))/g, (match, p1, p2, p3, p4) => p1 + transformUrl(p3, outputFilename, options.filename) + p4);
|
|
38
|
+
}
|
|
39
|
+
return decl;
|
|
40
|
+
});
|
|
41
|
+
preprocessor = stylis;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
Object.keys(rules).forEach((selector, index) => {
|
|
45
|
+
mappings.push({
|
|
46
|
+
generated: {
|
|
47
|
+
line: index + 1,
|
|
48
|
+
column: 0
|
|
49
|
+
},
|
|
50
|
+
original: rules[selector].start,
|
|
51
|
+
name: selector,
|
|
52
|
+
source: ''
|
|
53
|
+
});
|
|
54
|
+
if (rules[selector].atom) {
|
|
55
|
+
// For atoms, we just directly insert cssText, to give the atomizer full control over the rules
|
|
56
|
+
cssText += `${rules[selector].cssText}\n`;
|
|
57
|
+
} else {
|
|
58
|
+
// Run each rule through stylis to support nesting
|
|
59
|
+
cssText += `${preprocessor(selector, rules[selector].cssText)}\n`;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
cssText,
|
|
64
|
+
rules,
|
|
65
|
+
get cssSourceMapText() {
|
|
66
|
+
if (mappings?.length) {
|
|
67
|
+
const generator = new SourceMapGenerator({
|
|
68
|
+
file: options.filename.replace(/\.js$/, '.css')
|
|
69
|
+
});
|
|
70
|
+
mappings.forEach(mapping => generator.addMapping({
|
|
71
|
+
...mapping,
|
|
72
|
+
source: options.filename
|
|
73
|
+
}));
|
|
74
|
+
generator.setSourceContent(options.filename, originalCode);
|
|
75
|
+
return generator.toString();
|
|
76
|
+
}
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Extract artifacts (e.g. CSS) from processors
|
|
84
|
+
*/
|
|
85
|
+
// eslint-disable-next-line require-yield
|
|
86
|
+
export function* extract() {
|
|
87
|
+
const {
|
|
88
|
+
options
|
|
89
|
+
} = this.services;
|
|
90
|
+
const {
|
|
91
|
+
entrypoint
|
|
92
|
+
} = this;
|
|
93
|
+
const {
|
|
94
|
+
processors
|
|
95
|
+
} = this.data;
|
|
96
|
+
const {
|
|
97
|
+
loadedAndParsed
|
|
98
|
+
} = entrypoint;
|
|
99
|
+
if (loadedAndParsed.evaluator === 'ignored') {
|
|
100
|
+
throw new Error('entrypoint was ignored');
|
|
101
|
+
}
|
|
102
|
+
let allRules = {};
|
|
103
|
+
const allReplacements = [];
|
|
104
|
+
processors.forEach(processor => {
|
|
105
|
+
processor.artifacts.forEach(artifact => {
|
|
106
|
+
if (artifact[0] !== 'css') return;
|
|
107
|
+
const [rules, replacements] = artifact[1];
|
|
108
|
+
allRules = {
|
|
109
|
+
...allRules,
|
|
110
|
+
...rules
|
|
111
|
+
};
|
|
112
|
+
allReplacements.push(...replacements);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
...extractCssFromAst(allRules, loadedAndParsed.code, options),
|
|
117
|
+
replacements: allReplacements
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","names":["path","SourceMapGenerator","stylis","STYLIS_DECLARATION","posixSep","posix","sep","transformUrl","url","outputFilename","sourceFilename","platformPath","relative","dirname","resolve","split","join","extractCssFromAst","rules","originalCode","options","mappings","cssText","preprocessor","selector","text","use","context","decl","replace","match","p1","p2","p3","p4","filename","Object","keys","forEach","index","push","generated","line","column","original","start","name","source","atom","cssSourceMapText","length","generator","file","mapping","addMapping","setSourceContent","toString","extract","services","entrypoint","processors","data","loadedAndParsed","evaluator","Error","allRules","allReplacements","processor","artifacts","artifact","replacements","code"],"sources":["../../../src/transform/generators/extract.ts"],"sourcesContent":["import path from 'path';\n\nimport type { Mapping } from 'source-map';\nimport { SourceMapGenerator } from 'source-map';\nimport stylis from 'stylis';\n\nimport type { Replacements, Rules } from '@wyw-in-js/shared';\n\nimport type { Options, PreprocessorFn } from '../../types';\nimport type { IExtractAction, SyncScenarioForAction } from '../types';\n\nconst STYLIS_DECLARATION = 1;\nconst posixSep = path.posix.sep;\n\nexport function transformUrl(\n url: string,\n outputFilename: string,\n sourceFilename: string,\n platformPath: typeof path = path\n) {\n // Replace asset path with new path relative to the output CSS\n const relative = platformPath.relative(\n platformPath.dirname(outputFilename),\n // Get the absolute path to the asset from the path relative to the JS file\n platformPath.resolve(platformPath.dirname(sourceFilename), url)\n );\n\n if (platformPath.sep === posixSep) {\n return relative;\n }\n\n return relative.split(platformPath.sep).join(posixSep);\n}\n\nfunction extractCssFromAst(\n rules: Rules,\n originalCode: string,\n options: Pick<Options, 'preprocessor' | 'filename' | 'outputFilename'>\n): { cssSourceMapText: string; cssText: string; rules: Rules } {\n const mappings: Mapping[] = [];\n\n let cssText = '';\n\n let preprocessor: PreprocessorFn;\n if (typeof options.preprocessor === 'function') {\n // eslint-disable-next-line prefer-destructuring\n preprocessor = options.preprocessor;\n } else {\n switch (options.preprocessor) {\n case 'none':\n preprocessor = (selector, text) => `${selector} {${text}}\\n`;\n break;\n case 'stylis':\n default:\n stylis.use(null)((context, decl) => {\n const { outputFilename } = options;\n if (context === STYLIS_DECLARATION && outputFilename) {\n // When writing to a file, we need to adjust the relative paths inside url(..) expressions\n // It'll allow css-loader to resolve an imported asset properly\n return decl.replace(\n /\\b(url\\(([\"']?))(\\.[^)]+?)(\\2\\))/g,\n (match, p1, p2, p3, p4) =>\n p1 + transformUrl(p3, outputFilename, options.filename) + p4\n );\n }\n\n return decl;\n });\n\n preprocessor = stylis;\n }\n }\n\n Object.keys(rules).forEach((selector, index) => {\n mappings.push({\n generated: {\n line: index + 1,\n column: 0,\n },\n original: rules[selector].start!,\n name: selector,\n source: '',\n });\n\n if (rules[selector].atom) {\n // For atoms, we just directly insert cssText, to give the atomizer full control over the rules\n cssText += `${rules[selector].cssText}\\n`;\n } else {\n // Run each rule through stylis to support nesting\n cssText += `${preprocessor(selector, rules[selector].cssText)}\\n`;\n }\n });\n\n return {\n cssText,\n rules,\n\n get cssSourceMapText() {\n if (mappings?.length) {\n const generator = new SourceMapGenerator({\n file: options.filename.replace(/\\.js$/, '.css'),\n });\n\n mappings.forEach((mapping) =>\n generator.addMapping({ ...mapping, source: options.filename })\n );\n\n generator.setSourceContent(options.filename, originalCode);\n\n return generator.toString();\n }\n\n return '';\n },\n };\n}\n\n/**\n * Extract artifacts (e.g. CSS) from processors\n */\n// eslint-disable-next-line require-yield\nexport function* extract(\n this: IExtractAction\n): SyncScenarioForAction<IExtractAction> {\n const { options } = this.services;\n const { entrypoint } = this;\n const { processors } = this.data;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.evaluator === 'ignored') {\n throw new Error('entrypoint was ignored');\n }\n\n let allRules: Rules = {};\n const allReplacements: Replacements = [];\n processors.forEach((processor) => {\n processor.artifacts.forEach((artifact) => {\n if (artifact[0] !== 'css') return;\n const [rules, replacements] = artifact[1] as [\n rules: Rules,\n sourceMapReplacements: Replacements,\n ];\n\n allRules = {\n ...allRules,\n ...rules,\n };\n\n allReplacements.push(...replacements);\n });\n });\n\n return {\n ...extractCssFromAst(allRules, loadedAndParsed.code, options),\n replacements: allReplacements,\n };\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAGvB,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,OAAOC,MAAM,MAAM,QAAQ;AAO3B,MAAMC,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,QAAQ,GAAGJ,IAAI,CAACK,KAAK,CAACC,GAAG;AAE/B,OAAO,SAASC,YAAYA,CAC1BC,GAAW,EACXC,cAAsB,EACtBC,cAAsB,EACtBC,YAAyB,GAAGX,IAAI,EAChC;EACA;EACA,MAAMY,QAAQ,GAAGD,YAAY,CAACC,QAAQ,CACpCD,YAAY,CAACE,OAAO,CAACJ,cAAc,CAAC;EACpC;EACAE,YAAY,CAACG,OAAO,CAACH,YAAY,CAACE,OAAO,CAACH,cAAc,CAAC,EAAEF,GAAG,CAChE,CAAC;EAED,IAAIG,YAAY,CAACL,GAAG,KAAKF,QAAQ,EAAE;IACjC,OAAOQ,QAAQ;EACjB;EAEA,OAAOA,QAAQ,CAACG,KAAK,CAACJ,YAAY,CAACL,GAAG,CAAC,CAACU,IAAI,CAACZ,QAAQ,CAAC;AACxD;AAEA,SAASa,iBAAiBA,CACxBC,KAAY,EACZC,YAAoB,EACpBC,OAAsE,EACT;EAC7D,MAAMC,QAAmB,GAAG,EAAE;EAE9B,IAAIC,OAAO,GAAG,EAAE;EAEhB,IAAIC,YAA4B;EAChC,IAAI,OAAOH,OAAO,CAACG,YAAY,KAAK,UAAU,EAAE;IAC9C;IACAA,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C,IAAIA,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;MAC3B,MAAM,CAACnD,KAAK,EAAEoD,YAAY,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAGvC;MAEDJ,QAAQ,GAAG;QACT,GAAGA,QAAQ;QACX,GAAG/C;MACL,CAAC;MAEDgD,eAAe,CAAC1B,IAAI,CAAC,GAAG8B,YAAY,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACL,GAAGrD,iBAAiB,CAACgD,QAAQ,EAAEH,eAAe,CAACS,IAAI,EAAEnD,OAAO,CAAC;IAC7DkD,YAAY,EAAEJ;EAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { collectExportsAndImports } from '../../utils/collectExportsAndImports';
|
|
2
|
+
export function findExportsInImports(entrypoint, imports) {
|
|
3
|
+
const results = [];
|
|
4
|
+
for (const imp of imports) {
|
|
5
|
+
const {
|
|
6
|
+
resolved
|
|
7
|
+
} = imp;
|
|
8
|
+
if (!resolved) {
|
|
9
|
+
throw new Error(`Could not resolve import ${imp.source}`);
|
|
10
|
+
}
|
|
11
|
+
const newEntrypoint = entrypoint.createChild(resolved, []);
|
|
12
|
+
if (newEntrypoint === 'loop') {
|
|
13
|
+
// eslint-disable-next-line no-continue
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
results.push({
|
|
17
|
+
entrypoint: newEntrypoint,
|
|
18
|
+
import: imp.source
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
export function* getExports() {
|
|
24
|
+
const {
|
|
25
|
+
entrypoint,
|
|
26
|
+
services: {
|
|
27
|
+
cache
|
|
28
|
+
}
|
|
29
|
+
} = this;
|
|
30
|
+
const {
|
|
31
|
+
loadedAndParsed
|
|
32
|
+
} = entrypoint;
|
|
33
|
+
if (loadedAndParsed.ast === undefined) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
entrypoint.log(`get exports from %s`, entrypoint.name);
|
|
37
|
+
if (cache.has('exports', entrypoint.name)) {
|
|
38
|
+
return cache.get('exports', entrypoint.name);
|
|
39
|
+
}
|
|
40
|
+
let withWildcardReexport = [];
|
|
41
|
+
const result = [];
|
|
42
|
+
this.services.babel.traverse(loadedAndParsed.ast, {
|
|
43
|
+
Program(path) {
|
|
44
|
+
const {
|
|
45
|
+
exports,
|
|
46
|
+
reexports
|
|
47
|
+
} = collectExportsAndImports(path, 'disabled');
|
|
48
|
+
Object.keys(exports).forEach(token => {
|
|
49
|
+
result.push(token);
|
|
50
|
+
});
|
|
51
|
+
reexports.forEach(e => {
|
|
52
|
+
if (e.exported !== '*') {
|
|
53
|
+
result.push(e.exported);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
withWildcardReexport = reexports.filter(e => e.exported === '*');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (withWildcardReexport.length) {
|
|
60
|
+
const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {
|
|
61
|
+
imports: new Map(withWildcardReexport.map(i => [i.source, []]))
|
|
62
|
+
});
|
|
63
|
+
const importedEntrypoints = findExportsInImports(entrypoint, resolvedImports);
|
|
64
|
+
for (const importedEntrypoint of importedEntrypoints) {
|
|
65
|
+
const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
|
|
66
|
+
result.push(...exports);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
entrypoint.log(`exports: %o`, result);
|
|
70
|
+
cache.add('exports', entrypoint.name, result);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=getExports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExports.js","names":["collectExportsAndImports","findExportsInImports","entrypoint","imports","results","imp","resolved","Error","source","newEntrypoint","createChild","push","import","getExports","services","cache","loadedAndParsed","ast","undefined","log","name","has","get","withWildcardReexport","result","babel","traverse","Program","path","exports","reexports","Object","keys","forEach","token","e","exported","filter","length","resolvedImports","getNext","Map","map","i","importedEntrypoints","importedEntrypoint","add"],"sources":["../../../src/transform/generators/getExports.ts"],"sourcesContent":["import type { IReexport } from '../../utils/collectExportsAndImports';\nimport { collectExportsAndImports } from '../../utils/collectExportsAndImports';\nimport type { Entrypoint } from '../Entrypoint';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport type { IGetExportsAction, SyncScenarioForAction } from '../types';\n\nexport function findExportsInImports(\n entrypoint: Entrypoint,\n imports: IEntrypointDependency[]\n): { entrypoint: Entrypoint; import: string }[] {\n const results: {\n entrypoint: Entrypoint;\n import: string;\n }[] = [];\n\n for (const imp of imports) {\n const { resolved } = imp;\n if (!resolved) {\n throw new Error(`Could not resolve import ${imp.source}`);\n }\n\n const newEntrypoint = entrypoint.createChild(resolved, []);\n\n if (newEntrypoint === 'loop') {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n results.push({\n entrypoint: newEntrypoint,\n import: imp.source,\n });\n }\n\n return results;\n}\n\nexport function* getExports(\n this: IGetExportsAction\n): SyncScenarioForAction<IGetExportsAction> {\n const {\n entrypoint,\n services: { cache },\n } = this;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.ast === undefined) {\n return [];\n }\n\n entrypoint.log(`get exports from %s`, entrypoint.name);\n\n if (cache.has('exports', entrypoint.name)) {\n return cache.get('exports', entrypoint.name)!;\n }\n\n let withWildcardReexport: IReexport[] = [];\n const result: string[] = [];\n\n this.services.babel.traverse(loadedAndParsed.ast!, {\n Program(path) {\n const { exports, reexports } = collectExportsAndImports(path, 'disabled');\n Object.keys(exports).forEach((token) => {\n result.push(token);\n });\n\n reexports.forEach((e) => {\n if (e.exported !== '*') {\n result.push(e.exported);\n }\n });\n\n withWildcardReexport = reexports.filter((e) => e.exported === '*');\n },\n });\n\n if (withWildcardReexport.length) {\n const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {\n imports: new Map(withWildcardReexport.map((i) => [i.source, []])),\n });\n\n const importedEntrypoints = findExportsInImports(\n entrypoint,\n resolvedImports\n );\n\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n result.push(...exports);\n }\n }\n\n entrypoint.log(`exports: %o`, result);\n\n cache.add('exports', entrypoint.name, result);\n\n return result;\n}\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,sCAAsC;AAK/E,OAAO,SAASC,oBAAoBA,CAClCC,UAAsB,EACtBC,OAAgC,EACc;EAC9C,MAAMC,OAGH,GAAG,EAAE;EAER,KAAK,MAAMC,GAAG,IAAIF,OAAO,EAAE;IACzB,MAAM;MAAEG;IAAS,CAAC,GAAGD,GAAG;IACxB,IAAI,CAACC,QAAQ,EAAE;MACb,MAAM,IAAIC,KAAK,CAAE,4BAA2BF,GAAG,CAACG,MAAO,EAAC,CAAC;IAC3D;IAEA,MAAMC,aAAa,GAAGP,UAAU,CAACQ,WAAW,CAACJ,QAAQ,EAAE,EAAE,CAAC;IAE1D,IAAIG,aAAa,KAAK,MAAM,EAAE;MAC5B;MACA;IACF;IAEAL,OAAO,CAACO,IAAI,CAAC;MACXT,UAAU,EAAEO,aAAa;MACzBG,MAAM,EAAEP,GAAG,CAACG;IACd,CAAC,CAAC;EACJ;EAEA,OAAOJ,OAAO;AAChB;AAEA,OAAO,UAAUS,UAAUA,CAAA,EAEiB;EAC1C,MAAM;IACJX,UAAU;IACVY,QAAQ,EAAE;MAAEC;IAAM;EACpB,CAAC,GAAG,IAAI;EACR,MAAM;IAAEC;EAAgB,CAAC,GAAGd,UAAU;EACtC,IAAIc,eAAe,CAACC,GAAG,KAAKC,SAAS,EAAE;IACrC,OAAO,EAAE;EACX;EAEAhB,UAAU,CAACiB,GAAG,CAAE,qBAAoB,EAAEjB,UAAU,CAACkB,IAAI,CAAC;EAEtD,IAAIL,KAAK,CAACM,GAAG,CAAC,SAAS,EAAEnB,UAAU,CA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GAAG,OAAO,IAAI,CAACW,OAAO,CACjC,YAAY,EACZK,kBAAkB,CAAC3C,UAAU,EAC7BgB,SACF,CAAC;MAEDM,MAAM,CAACb,IAAI,CAAC,GAAGkB,OAAO,CAAC;IACzB;EACF;EAEA3B,UAAU,CAACiB,GAAG,CAAE,aAAY,EAAEK,MAAM,CAAC;EAErCT,KAAK,CAAC+B,GAAG,CAAC,SAAS,EAAE5C,UAAU,CAACkB,IAAI,EAAEI,MAAM,CAAC;EAE7C,OAAOA,MAAM;AACf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["baseProcessingHandlers","collect","evalFile","extract","workflow","baseHandlers"],"sources":["../../../src/transform/generators/index.ts"],"sourcesContent":["import { baseProcessingHandlers } from './baseProcessingHandlers';\nimport { collect } from './collect';\nimport { evalFile } from './evalFile';\nimport { extract } from './extract';\nimport { workflow } from './workflow';\n\nexport const baseHandlers = {\n ...baseProcessingHandlers,\n collect,\n evalFile,\n extract,\n workflow,\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,QAAQ,QAAQ,YAAY;AAErC,OAAO,MAAMC,YAAY,GAAG;EAC1B,GAAGL,sBAAsB;EACzBC,OAAO;EACPC,QAAQ;EACRC,OAAO;EACPC;AACF,CAAC"}
|