add back strict module formatters
This commit is contained in:
parent
2808bc2c90
commit
c7c99efa8e
14
lib/6to5/transformation/modules/_strict.js
Normal file
14
lib/6to5/transformation/modules/_strict.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var util = require("../../util");
|
||||
|
||||
module.exports = function (Parent) {
|
||||
var Constructor = function () {
|
||||
this.noInteropRequire = true;
|
||||
Parent.apply(this, arguments);
|
||||
};
|
||||
|
||||
util.inherits(Constructor, Parent);
|
||||
|
||||
return Constructor;
|
||||
};
|
||||
3
lib/6to5/transformation/modules/amd-strict.js
Normal file
3
lib/6to5/transformation/modules/amd-strict.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./_strict")(require("./amd"));
|
||||
@ -99,7 +99,7 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
};
|
||||
|
||||
AMDFormatter.prototype.exportDeclaration = function (node) {
|
||||
if (node.default && !this.noInteropRequire && !this.hasNonDefaultExports) {
|
||||
if (this.doDefaultExportInterop(node)) {
|
||||
this.passModuleArg = true;
|
||||
}
|
||||
|
||||
|
||||
3
lib/6to5/transformation/modules/common-strict.js
Normal file
3
lib/6to5/transformation/modules/common-strict.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./_strict")(require("./common"));
|
||||
@ -60,8 +60,12 @@ CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
|
||||
}, true));
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.doDefaultExportInterop = function (node) {
|
||||
return node.default && !this.noInteropRequire && !this.hasNonDefaultExports;
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
|
||||
if (node.default && !this.noInteropRequire && !this.hasNonDefaultExports) {
|
||||
if (this.doDefaultExportInterop(node)) {
|
||||
var declar = node.declaration;
|
||||
var assign = util.template("exports-default-assign", {
|
||||
VALUE: this._pushStatement(declar, nodes)
|
||||
|
||||
@ -10,7 +10,7 @@ var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
function SystemFormatter(file) {
|
||||
this.exportIdentifier = file.generateUidIdentifier("export");
|
||||
this.exportIdentifier = file.generateUidIdentifier("export");
|
||||
this.noInteropRequire = true;
|
||||
|
||||
AMDFormatter.apply(this, arguments);
|
||||
|
||||
3
lib/6to5/transformation/modules/umd-strict
Normal file
3
lib/6to5/transformation/modules/umd-strict
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./_strict")(require("./umd"));
|
||||
@ -86,11 +86,14 @@ transform.deprecatedTransformerMap = {
|
||||
transform.transformers = object();
|
||||
|
||||
transform.moduleFormatters = {
|
||||
common: require("./modules/common"),
|
||||
system: require("./modules/system"),
|
||||
ignore: require("./modules/ignore"),
|
||||
amd: require("./modules/amd"),
|
||||
umd: require("./modules/umd")
|
||||
commonStrict: require("./modules/common-strict"),
|
||||
amdStrict: require("./modules/amd-strict"),
|
||||
umdStrict: require("./modules/umd-strict"),
|
||||
common: require("./modules/common"),
|
||||
system: require("./modules/system"),
|
||||
ignore: require("./modules/ignore"),
|
||||
amd: require("./modules/amd"),
|
||||
umd: require("./modules/umd")
|
||||
};
|
||||
|
||||
_.each({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user