amis-rpc-design/node_modules/@babel/helper-create-class-features-plugin/lib/features.js.map

1 line
14 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["_decorators","require","FEATURES","Object","freeze","fields","privateMethods","decorators","privateIn","staticBlocks","exports","featuresSameLoose","Map","featuresKey","looseKey","looseLowPriorityKey","enableFeature","file","feature","loose","hasFeature","canIgnoreLoose","set","get","setLoose","resolvedLoose","higherPriorityPluginName","mask","name","isLoose","Error","undefined","console","warn","shouldTransform","path","decoratorPath","publicFieldPath","privateFieldPath","privateMethodPath","staticBlockPath","hasOwnDecorators","node","el","isClassProperty","isClassPrivateProperty","isClassPrivateMethod","isStaticBlock","buildCodeFrameError"],"sources":["../src/features.ts"],"sourcesContent":["import type { File, types as t } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\nimport { hasOwnDecorators } from \"./decorators.ts\";\n\nexport const FEATURES = Object.freeze(\n process.env.BABEL_8_BREAKING\n ? {\n //classes: 1 << 0,\n fields: 1 << 1,\n privateMethods: 1 << 2,\n privateIn: 1 << 3,\n staticBlocks: 1 << 4,\n }\n : {\n //classes: 1 << 0,\n fields: 1 << 1,\n privateMethods: 1 << 2,\n decorators: 1 << 3,\n privateIn: 1 << 4,\n staticBlocks: 1 << 5,\n },\n);\n\nconst featuresSameLoose = new Map([\n [FEATURES.fields, \"@babel/plugin-transform-class-properties\"],\n [FEATURES.privateMethods, \"@babel/plugin-transform-private-methods\"],\n [FEATURES.privateIn, \"@babel/plugin-transform-private-property-in-object\"],\n]);\n\n// We can't use a symbol because this needs to always be the same, even if\n// this package isn't deduped by npm. e.g.\n// - node_modules/\n// - @babel/plugin-class-features\n// - @babel/plugin-proposal-decorators\n// - node_modules\n// - @babel-plugin-class-features\nconst featuresKey = \"@babel/plugin-class-features/featuresKey\";\nconst looseKey = \"@babel/plugin-class-features/looseKey\";\n\n// See https://github.com/babel/babel/issues/11622.\n// Since preset-env sets loose for the fields and private methods plugins, it can\n// cause conflicts with the loose mode set by an explicit plugin in the config.\n// To solve this problem, we ignore preset-env's loose mode if another plugin\n// explicitly sets it\n// The code to handle this logic doesn't check that \"low priority loose\" is always\n// the same. However, it is only set by the preset and not directly by users:\n// unless someone _wants_ to break it, it shouldn't be a problem.\nconst looseLowPriorityKey =\n \"@babel/plugin-class-features/looseLowPriorityKey/#__internal__@babel/preset-env__please-overwrite-loose-instead-of-throwing\";\n\nexport function enableFeature(file: File, feature: number, loose: boolean) {\n // We can't blindly enable the feature because, if it was already set,\n // \"loose\" can't be changed, so that\n // @babel/plugin-class-properties { loose: true }\n // @babel/plugin-class-properties { loose: false }\n // is transformed in loose mode.\n // We only enabled the feature if it was previously disabled.\n if (!hasFeature(file, feature) || canIgnoreLoose(file, feature)) {\n file.set(featuresKey, file.get(featuresKey) | feature);\n if (\n // @ts-expect-error comparing loose with internal private magic string\n loose ===\n \"#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error\"\n ) {\n setLoose(file, feature, true);\n file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);\n } else if (\n // @ts-expect-error comparing loose with internal private magic string\n loose ===\n \"#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error\"\n ) {\n setLoose(file, feature, false);\n file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);\n } else {\n setLoose(file, feature, loose);\n }\n }\n\n let resolvedLoose: boolean | undefined;\n let higherPriorityPluginName: string | undefined;\n\n for (c