From f2c5accab322b30b6c52c8d185638a76e3e61920 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 20 Feb 2015 23:23:50 +1100 Subject: [PATCH] add `getModuleName` option - fixes #844 --- lib/babel/transformation/file.js | 4 +++- lib/babel/transformation/modules/_default.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/babel/transformation/file.js b/lib/babel/transformation/file.js index 758a658fd3..6d0ea188a1 100644 --- a/lib/babel/transformation/file.js +++ b/lib/babel/transformation/file.js @@ -86,10 +86,12 @@ File.validOptions = [ "format", "playground", "experimental", - "resolveModuleSource", "externalHelpers", "auxiliaryComment", + "resolveModuleSource", + "getModuleName", + // these are used by plugins "ignore", "only", diff --git a/lib/babel/transformation/modules/_default.js b/lib/babel/transformation/modules/_default.js index 93353752cd..0e80537bdf 100644 --- a/lib/babel/transformation/modules/_default.js +++ b/lib/babel/transformation/modules/_default.js @@ -146,6 +146,8 @@ DefaultFormatter.prototype.isLocalReference = function (node, scope) { DefaultFormatter.prototype.getModuleName = function () { var opts = this.file.opts; + if (opts.getModuleName) return opts.getModuleName(opts.filename); + var filenameRelative = opts.filenameRelative; var moduleName = "";