es6-module-transpiler
Advanced tools
Comparing version 0.9.1 to 0.9.2
@@ -54,2 +54,4 @@ /* jshint node:true, undef:true, unused:true */ | ||
return new FunctionExportDeclaration(this.module, node); | ||
} else if (n.ClassDeclaration.check(node.declaration)) { | ||
return new ClassExportDeclaration(this.module, node); | ||
} else if (n.ExportBatchSpecifier.check(node.specifiers[0])) { | ||
@@ -207,2 +209,27 @@ throw new Error( | ||
* | ||
* export class Foo {} | ||
* | ||
* @constructor | ||
* @extends ExportDeclaration | ||
* @param {Module} mod | ||
* @param {AST.ExportDeclaration} node | ||
*/ | ||
function ClassExportDeclaration(mod, node) { | ||
ExportDeclaration.call(this, mod, node); | ||
} | ||
extend(ClassExportDeclaration, ExportDeclaration); | ||
/** | ||
* Gets the list of export specifiers for this declaration. | ||
* | ||
* @type {ExportSpecifier[]} | ||
* @name ClassExportDeclaration#specifiers | ||
*/ | ||
memo(ClassExportDeclaration.prototype, 'specifiers', /** @this ClassExportDeclaration */function() { | ||
return [new ExportSpecifier(this, this.node.declaration)]; | ||
}); | ||
/** | ||
* Represents an export declaration of the form: | ||
* | ||
* export function foo() {} | ||
@@ -209,0 +236,0 @@ * |
@@ -332,2 +332,10 @@ /* jshint node:true, undef:true, unused:true */ | ||
); | ||
} else if (n.ClassDeclaration.check(node.declaration)) { | ||
return Replacement.swaps( | ||
// drop `export` | ||
nodePath, node.declaration | ||
).and( | ||
// transform the class | ||
this.processClassDeclaration(mod, nodePath.get('declaration')) | ||
); | ||
} else if (n.VariableDeclaration.check(node.declaration)) { | ||
@@ -399,2 +407,24 @@ return Replacement.swaps( | ||
/** | ||
* Rename the top-level class declaration to a unique name. | ||
* | ||
* ```js | ||
* class Foo {} | ||
* ``` | ||
* | ||
* Becomes e.g. | ||
* | ||
* ```js | ||
* class mod$$Foo {} | ||
* ``` | ||
* | ||
* @override | ||
*/ | ||
BundleFormatter.prototype.processClassDeclaration = function(mod, nodePath) { | ||
return Replacement.swaps( | ||
nodePath.get('id'), | ||
this.reference(mod, nodePath.node.id) | ||
); | ||
}; | ||
/** | ||
* Since import declarations only control how we rewrite references we can just | ||
@@ -401,0 +431,0 @@ * remove them -- they don't turn into any actual statements. |
{ | ||
"name": "es6-module-transpiler", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"description": "es6-module-transpiler is an experimental compiler that allows you to write your JavaScript using a subset of the current ES6 module syntax, and compile it into various formats.", | ||
@@ -49,2 +49,3 @@ "homepage": "http://esnext.github.io/es6-module-transpiler", | ||
"browserify": "^5.12.1", | ||
"es6-class": "^0.9.1", | ||
"example-runner": "^0.1.0", | ||
@@ -59,2 +60,2 @@ "fake-fs": "^0.4.0", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116025
3587
6