Skip to content

Commit 2f24fff

Browse files
committed
fix cycle bug
1 parent 6981360 commit 2f24fff

File tree

8 files changed

+150
-132
lines changed

8 files changed

+150
-132
lines changed

package-lock.json

Lines changed: 129 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"license": "MIT",
1111
"main": "transform-cjs-dew.js",
1212
"devDependencies": {
13-
"@babel/core": "^7.23.2",
13+
"@babel/core": "^7.24.5",
1414
"mocha": "^10.2.0"
1515
},
1616
"scripts": {

test/fixtures/datatables/actual.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var o, a;
2+
"function" == typeof define && define.amd
3+
? void 0
4+
: "object" == typeof exports
5+
? (module.exports = function (e, t) { return t; })
6+
: void 0;

test/fixtures/datatables/expected.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var exports = {},
2+
_dewExec = false;
3+
export function dew() {
4+
if (_dewExec) return exports;
5+
_dewExec = true;
6+
var o, a;
7+
true ? exports = function (e, t) {
8+
return t;
9+
} : void 0;
10+
return exports;
11+
}

test/fixtures/debug/expected.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export function dew() {
5353
hash = (hash << 5) - hash + namespace.charCodeAt(i);
5454
hash |= 0; // Convert to 32bit integer
5555
}
56-
5756
return exports.colors[Math.abs(hash) % exports.colors.length];
5857
}
5958

test/fixtures/jquery/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ var exports = {};
427427
// declare themselves as anonymous modules, and avoid setting a global if an
428428
// AMD loader is present. jQuery is a special case. For more information, see
429429
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
430+
430431
var
431432
// Map over jQuery in case of overwrite
432433
_jQuery = window.jQuery,

test/fixtures/process-redef/expected.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function processArgs(argv, options, fs, path) {
4444
if (Array.isArray(argumentValue)) {
4545
argumentValue = argumentValue.pop(); // If the same argument is defined multiple times, override.
4646
}
47-
4847
options[helper.dashToCamel(name)] = argumentValue;
4948
}
5049
});

transform-cjs-dew.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ const strictReservedOrKeyword = Object.assign(
2424
function hasBinding (path, bindingName) {
2525
// Babel bug with replacement scoping creating circular scope
2626
// work around by calling the id check directly
27-
if (path.scope === path.scope.parent)
27+
if (path.scope === path.scope.parentScope) {
2828
return path.scope.hasOwnBinding(bindingName);
29+
}
2930
return path.scope.hasBinding(bindingName);
3031
}
3132

0 commit comments

Comments
 (0)