Fix T2929, T6796, stop leaking directives

This commit is contained in:
Casey Foster 2016-01-08 13:21:35 -06:00
parent fb0977b4b3
commit c7c4d7f5fd
32 changed files with 94 additions and 93 deletions

View File

@ -1,9 +1,13 @@
import template from "babel-template";
let buildDefine = template(`
define(MODULE_NAME, [SOURCES], function (PARAMS) {
define(MODULE_NAME, [SOURCES], FACTORY);
`);
let buildFactory = template(`
(function (PARAMS) {
BODY;
});
})
`);
export default function ({ types: t }) {
@ -96,11 +100,18 @@ export default function ({ types: t }) {
params.unshift(t.identifier("module"));
}
path.node.body = [buildDefine({
let { node } = path;
let factory = buildFactory({
PARAMS: params,
BODY: node.body
});
factory.expression.body.directives = node.directives;
node.directives = [];
node.body = [buildDefine({
MODULE_NAME: moduleName,
SOURCES: sources,
PARAMS: params,
BODY: path.node.body
FACTORY: factory
})];
}
}

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports"], function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports"], function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports", "foo"], function (exports, _foo) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports"], function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports"], function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,3 +1 @@
"use strict";
define("my custom module name", [], function () {});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports", "./evens"], function (exports, _evens) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["foo"], function (_foo) {
"use strict";
var _foo2 = babelHelpers.interopRequireDefault(_foo);
_foo2.default;

View File

@ -1,6 +1,6 @@
"use strict";
define(["foo"], function (_foo) {
"use strict";
var foo = babelHelpers.interopRequireWildcard(_foo);
foo;
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["foo"], function (_foo) {
"use strict";
var _foo2 = babelHelpers.interopRequireDefault(_foo);
_foo2.default;

View File

@ -1,6 +1,6 @@
"use strict";
define(["foo"], function (_foo) {
"use strict";
_foo.bar;
_foo.bar2;
_foo.baz;

View File

@ -1,3 +1 @@
"use strict";
define(["foo", "foo-bar", "./directory/foo-bar"], function () {});

View File

@ -1,5 +1,5 @@
"use strict";
define("amd/module-name/expected", [], function () {
"use strict";
foobar();
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports, _foo) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,6 +1,6 @@
"use strict";
define(["exports"], function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "foo"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("my custom module name", [], factory);

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "./evens"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports, _evens) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["foo"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (_foo) {
"use strict";
var _foo2 = babelHelpers.interopRequireDefault(_foo);
_foo2.default;

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["foo"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (_foo) {
"use strict";
var foo = babelHelpers.interopRequireWildcard(_foo);
foo;
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["foo"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (_foo) {
"use strict";
var _foo2 = babelHelpers.interopRequireDefault(_foo);
_foo.baz;

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["foo"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (_foo) {
"use strict";
_foo.bar;
_foo.bar2;
_foo.baz;

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["foo", "foo-bar", "./directory/foo-bar"], factory);

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("MyLib", [], factory);
@ -13,5 +11,7 @@
global.MyLib = mod.exports;
}
})(this, function () {
"use strict";
foobar();
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("umd/module-name/expected", [], factory);
@ -13,5 +11,7 @@
global.umdModuleNameExpected = mod.exports;
}
})(this, function () {
"use strict";
foobar();
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["./lib/render"], factory);

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports, _foo) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@ -1,5 +1,3 @@
"use strict";
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
@ -13,6 +11,8 @@
global.actual = mod.exports;
}
})(this, function (exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});