summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-object-super
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/plugin-transform-object-super')
-rw-r--r--node_modules/@babel/plugin-transform-object-super/README.md2
-rw-r--r--node_modules/@babel/plugin-transform-object-super/lib/index.js35
-rw-r--r--node_modules/@babel/plugin-transform-object-super/lib/index.js.map2
-rw-r--r--node_modules/@babel/plugin-transform-object-super/package.json6
4 files changed, 35 insertions, 10 deletions
diff --git a/node_modules/@babel/plugin-transform-object-super/README.md b/node_modules/@babel/plugin-transform-object-super/README.md
index a89ae805..1ab1b4d3 100644
--- a/node_modules/@babel/plugin-transform-object-super/README.md
+++ b/node_modules/@babel/plugin-transform-object-super/README.md
@@ -2,7 +2,7 @@
> Compile ES2015 object super to ES5
-See our website [@babel/plugin-transform-object-super](https://babeljs.io/docs/en/babel-plugin-transform-object-super) for more information.
+See our website [@babel/plugin-transform-object-super](https://babeljs.io/docs/babel-plugin-transform-object-super) for more information.
## Install
diff --git a/node_modules/@babel/plugin-transform-object-super/lib/index.js b/node_modules/@babel/plugin-transform-object-super/lib/index.js
index 59dad106..345090db 100644
--- a/node_modules/@babel/plugin-transform-object-super/lib/index.js
+++ b/node_modules/@babel/plugin-transform-object-super/lib/index.js
@@ -15,11 +15,27 @@ function replacePropertySuper(path, getObjectRef, file) {
});
replaceSupers.replace();
}
-var _default = (0, _helperPluginUtils.declare)(api => {
+var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
+ const newLets = new Set();
return {
name: "transform-object-super",
visitor: {
+ Loop: {
+ exit(path) {
+ newLets.forEach(v => {
+ if (v.scopePath === path) {
+ path.scope.push({
+ id: v.id,
+ kind: "let"
+ });
+ path.scope.crawl();
+ path.requeue();
+ newLets.delete(v);
+ }
+ });
+ }
+ },
ObjectExpression(path, state) {
let objectRef;
const getObjectRef = () => objectRef = objectRef || path.scope.generateUidIdentifier("obj");
@@ -28,15 +44,24 @@ var _default = (0, _helperPluginUtils.declare)(api => {
replacePropertySuper(propPath, getObjectRef, state.file);
});
if (objectRef) {
- path.scope.push({
- id: _core.types.cloneNode(objectRef)
- });
+ const scopePath = path.findParent(p => p.isFunction() || p.isProgram() || p.isLoop());
+ const useLet = scopePath.isLoop();
+ if (useLet) {
+ newLets.add({
+ scopePath,
+ id: _core.types.cloneNode(objectRef)
+ });
+ } else {
+ path.scope.push({
+ id: _core.types.cloneNode(objectRef),
+ kind: "var"
+ });
+ }
path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(objectRef), path.node));
}
}
}
};
});
-exports.default = _default;
//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-transform-object-super/lib/index.js.map b/node_modules/@babel/plugin-transform-object-super/lib/index.js.map
index 60a70759..769b0c28 100644
--- a/node_modules/@babel/plugin-transform-object-super/lib/index.js.map
+++ b/node_modules/@babel/plugin-transform-object-super/lib/index.js.map
@@ -1 +1 @@
-{"version":3,"names":["_helperPluginUtils","require","_helperReplaceSupers","_core","replacePropertySuper","path","getObjectRef","file","replaceSupers","ReplaceSupers","methodPath","replace","_default","declare","api","assertVersion","name","visitor","ObjectExpression","state","objectRef","scope","generateUidIdentifier","get","forEach","propPath","isMethod","push","id","t","cloneNode","replaceWith","assignmentExpression","node","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport ReplaceSupers from \"@babel/helper-replace-supers\";\nimport { types as t, type File } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\n\nfunction replacePropertySuper(\n path: NodePath<t.ObjectMethod>,\n getObjectRef: () => t.Identifier,\n file: File,\n) {\n // @ts-expect-error todo(flow->ts):\n const replaceSupers = new ReplaceSupers({\n getObjectRef: getObjectRef,\n methodPath: path,\n file: file,\n });\n\n replaceSupers.replace();\n}\n\nexport default declare(api => {\n api.assertVersion(7);\n\n return {\n name: \"transform-object-super\",\n\n visitor: {\n ObjectExpression(path, state) {\n let objectRef: t.Identifier;\n const getObjectRef = () =>\n (objectRef = objectRef || path.scope.generateUidIdentifier(\"obj\"));\n\n path.get(\"properties\").forEach(propPath => {\n if (!propPath.isMethod()) return;\n\n replacePropertySuper(propPath, getObjectRef, state.file);\n });\n\n if (objectRef) {\n path.scope.push({ id: t.cloneNode(objectRef) });\n path.replaceWith(\n t.assignmentExpression(\"=\", t.cloneNode(objectRef), path.node),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAGA,SAASG,oBAAoBA,CAC3BC,IAA8B,EAC9BC,YAAgC,EAChCC,IAAU,EACV;EAEA,MAAMC,aAAa,GAAG,IAAIC,4BAAa,CAAC;IACtCH,YAAY,EAAEA,YAAY;IAC1BI,UAAU,EAAEL,IAAI;IAChBE,IAAI,EAAEA;EACR,CAAC,CAAC;EAEFC,aAAa,CAACG,OAAO,CAAC,CAAC;AACzB;AAAC,IAAAC,QAAA,GAEc,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAC,CAAC,CAAC;EAEpB,OAAO;IACLC,IAAI,EAAE,wBAAwB;IAE9BC,OAAO,EAAE;MACPC,gBAAgBA,CAACb,IAAI,EAAEc,KAAK,EAAE;QAC5B,IAAIC,SAAuB;QAC3B,MAAMd,YAAY,GAAGA,CAAA,KAClBc,SAAS,GAAGA,SAAS,IAAIf,IAAI,CAACgB,KAAK,CAACC,qBAAqB,CAAC,KAAK,CAAE;QAEpEjB,IAAI,CAACkB,GAAG,CAAC,YAAY,CAAC,CAACC,OAAO,CAACC,QAAQ,IAAI;UACzC,IAAI,CAACA,QAAQ,CAACC,QAAQ,CAAC,CAAC,EAAE;UAE1BtB,oBAAoB,CAACqB,QAAQ,EAAEnB,YAAY,EAAEa,KAAK,CAACZ,IAAI,CAAC;QAC1D,CAAC,CAAC;QAEF,IAAIa,SAAS,EAAE;UACbf,IAAI,CAACgB,KAAK,CAACM,IAAI,CAAC;YAAEC,EAAE,EAAEC,WAAC,CAACC,SAAS,CAACV,SAAS;UAAE,CAAC,CAAC;UAC/Cf,IAAI,CAAC0B,WAAW,CACdF,WAAC,CAACG,oBAAoB,CAAC,GAAG,EAAEH,WAAC,CAACC,SAAS,CAACV,SAAS,CAAC,EAAEf,IAAI,CAAC4B,IAAI,CAC/D,CAAC;QACH;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAvB,QAAA"} \ No newline at end of file
+{"version":3,"names":["_helperPluginUtils","require","_helperReplaceSupers","_core","replacePropertySuper","path","getObjectRef","file","replaceSupers","ReplaceSupers","methodPath","replace","_default","exports","default","declare","api","assertVersion","newLets","Set","name","visitor","Loop","exit","forEach","v","scopePath","scope","push","id","kind","crawl","requeue","delete","ObjectExpression","state","objectRef","generateUidIdentifier","get","propPath","isMethod","findParent","p","isFunction","isProgram","isLoop","useLet","add","t","cloneNode","replaceWith","assignmentExpression","node"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport ReplaceSupers from \"@babel/helper-replace-supers\";\nimport { types as t, type File } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\n\nfunction replacePropertySuper(\n path: NodePath<t.ObjectMethod>,\n getObjectRef: () => t.Identifier,\n file: File,\n) {\n // @ts-expect-error todo(flow->ts):\n const replaceSupers = new ReplaceSupers({\n getObjectRef: getObjectRef,\n methodPath: path,\n file: file,\n });\n\n replaceSupers.replace();\n}\n\nexport default declare(api => {\n api.assertVersion(\n process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH\n ? PACKAGE_JSON.version\n : 7,\n );\n const newLets = new Set<{\n scopePath: NodePath;\n id: t.Identifier;\n }>();\n\n return {\n name: \"transform-object-super\",\n\n visitor: {\n Loop: {\n exit(path) {\n newLets.forEach(v => {\n if (v.scopePath === path) {\n path.scope.push({\n id: v.id,\n kind: \"let\",\n });\n path.scope.crawl();\n path.requeue();\n newLets.delete(v);\n }\n });\n },\n },\n ObjectExpression(path, state) {\n let objectRef: t.Identifier;\n const getObjectRef = () =>\n (objectRef = objectRef || path.scope.generateUidIdentifier(\"obj\"));\n\n path.get(\"properties\").forEach(propPath => {\n if (!propPath.isMethod()) return;\n\n replacePropertySuper(propPath, getObjectRef, state.file);\n });\n\n if (objectRef) {\n const scopePath = path.findParent(\n p => p.isFunction() || p.isProgram() || p.isLoop(),\n );\n const useLet = scopePath.isLoop();\n // For transform-block-scoping\n if (useLet) {\n newLets.add({ scopePath, id: t.cloneNode(objectRef) });\n } else {\n path.scope.push({\n id: t.cloneNode(objectRef),\n kind: \"var\",\n });\n }\n\n path.replaceWith(\n t.assignmentExpression(\"=\", t.cloneNode(objectRef), path.node),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAGA,SAASG,oBAAoBA,CAC3BC,IAA8B,EAC9BC,YAAgC,EAChCC,IAAU,EACV;EAEA,MAAMC,aAAa,GAAG,IAAIC,4BAAa,CAAC;IACtCH,YAAY,EAAEA,YAAY;IAC1BI,UAAU,EAAEL,IAAI;IAChBE,IAAI,EAAEA;EACR,CAAC,CAAC;EAEFC,aAAa,CAACG,OAAO,CAAC,CAAC;AACzB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAGX,CACN,CAAC;EACD,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAGpB,CAAC;EAEJ,OAAO;IACLC,IAAI,EAAE,wBAAwB;IAE9BC,OAAO,EAAE;MACPC,IAAI,EAAE;QACJC,IAAIA,CAAClB,IAAI,EAAE;UACTa,OAAO,CAACM,OAAO,CAACC,CAAC,IAAI;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AAI,CAAC;cACdC,EAAE,EAAEmB,WAAC,CAACC,SAAS,CAACb,SAAS,CAAC;cAC1BN,IAAI,EAAE;YACR,CAAC,CAAC;UACJ;UAEAzB,IAAI,CAAC6C,WAAW,CACdF,WAAC,CAACG,oBAAoB,CAAC,GAAG,EAAEH,WAAC,CAACC,SAAS,CAACb,SAAS,CAAC,EAAE/B,IAAI,CAAC+C,IAAI,CAC/D,CAAC;QACH;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC"} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-object-super/package.json b/node_modules/@babel/plugin-transform-object-super/package.json
index caf160ec..c70428d5 100644
--- a/node_modules/@babel/plugin-transform-object-super/package.json
+++ b/node_modules/@babel/plugin-transform-object-super/package.json
@@ -1,6 +1,6 @@
{
"name": "@babel/plugin-transform-object-super",
- "version": "7.22.5",
+ "version": "7.23.3",
"description": "Compile ES2015 object super to ES5",
"repository": {
"type": "git",
@@ -18,13 +18,13 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
- "@babel/helper-replace-supers": "^7.22.5"
+ "@babel/helper-replace-supers": "^7.22.20"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
- "@babel/core": "^7.22.5",
+ "@babel/core": "^7.23.3",
"@babel/helper-plugin-test-runner": "^7.22.5"
},
"engines": {