the-forest/client/node_modules/@babel/plugin-transform-modules-amd/lib/index.js.map

1 line
12 KiB
Plaintext
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"version":3,"names":["_helperPluginUtils","require","_helperModuleTransforms","_core","buildWrapper","template","statement","buildAnonymousWrapper","injectWrapper","path","wrapper","body","directives","node","amdFactoryCall","pushContainer","get","amdFactoryCallArgs","amdFactory","length","_default","exports","default","declare","api","options","_api$assumption","_api$assumption2","assertVersion","allowTopLevelThis","strict","strictMode","importInterop","noInterop","constantReexports","assumption","loose","enumerableModuleMeta","name","pre","file","set","visitor","types","importExpression","state","has","isCallExpression","isImport","requireId","resolveId","rejectId","scope","generateUidIdentifier","result","t","identifier","wrapInterop","replaceWith","buildDynamicImport","specifier","expression","ast","cloneNode","Program","exit","isModule","REQUIRE","amdArgs","importNames","push","stringLiteral","moduleName","getModuleName","opts","meta","headers","rewriteModuleStatementsAndPrepareHeader","filename","hasExports","exportName","source","metadata","isSideEffectImport","interop","header","expressionStatement","assignmentExpression","loc","buildNamespaceInitStatements","ensureStatementsHoisted","unshiftContainer","MODULE_NAME","AMD_ARGUMENTS","arrayExpression","IMPORT_NAMES"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport {\n buildDynamicImport,\n isModule,\n rewriteModuleStatementsAndPrepareHeader,\n type RewriteModuleStatementsAndPrepareHeaderOptions,\n hasExports,\n isSideEffectImport,\n buildNamespaceInitStatements,\n ensureStatementsHoisted,\n wrapInterop,\n getModuleName,\n} from \"@babel/helper-module-transforms\";\nimport { template, types as t } from \"@babel/core\";\nimport type { PluginOptions } from \"@babel/helper-module-transforms\";\nimport type { NodePath, PluginPass } from \"@babel/core\";\n\nconst buildWrapper = template.statement(`\n define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) {\n })\n`);\n\nconst buildAnonymousWrapper = template.statement(`\n define([\"require\"], function(REQUIRE) {\n })\n`);\n\nfunction injectWrapper(\n path: NodePath<t.Program>,\n wrapper: t.ExpressionStatement,\n) {\n const { body, directives } = path.node;\n path.node.directives = [];\n path.node.body = [];\n const amdFactoryCall = path\n .pushContainer(\"body\", wrapper)[0]\n .get(\"expression\") as NodePath<t.CallExpression>;\n const amdFactoryCallArgs = amdFactoryCall.get(\"arguments\");\n const amdFactory = (\n amdFactoryCallArgs[\n amdFactoryCallArgs.length - 1\n ] as NodePath<t.FunctionExpression>\n ).get(\"body\");\n amdFactory.pushContainer(\"directives\", directives);\n amdFactory.pushContainer(\"body\", body);\n}\n\nexport interface Options extends PluginOptions {\n allowTopLevelThis?: boolean;\n importInterop?: RewriteModuleStatementsAndPrepareHeaderOptions[\"importInterop\"];\n loose?: boolean;\n noInterop?: boolean;\n strict?: boolean;\n strictMode?: boolean;\n}\n\ntype State = {\n requireId?: t.Identifier;\n resolveId?: t.Identifier;\n rejectId?: t.Identifier;\n};\n\nexport default declare<State>((api, options: Options) => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n const { allowTopLevelThis, strict, strictMode, importInterop, noInterop } =\n options;\n\n const constantReexports =\n api.assumption(\"constantReexports\") ?? options.loose;\n const enumerableModuleMeta =\n api.assumption(\"enumerableModuleMeta\") ?? options.loose;\n\n return {\n name: \"transform-modules-amd\",\n\n pre() {\n this.file.set(\"@babel/plugin-transform-modules-*\", \"amd\");\n },\n\n visitor: {\n [\"CallExpression\" +\n (api.types.importExpression ? \"|ImportExpression\" : \"\")](\n this: State & PluginPass,\n path: NodePath<t.CallExpression | t.ImportExpression>,\n state: State,\n ) {\n if (!this.file.has(\"@babel/plugin-proposal-dynamic-import\")) return;\n if (path.isCallExpression() && !path.get(\"callee\").isImport()) retu