aboutsummaryrefslogtreecommitdiff
path: root/node_modules/babel-core/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/babel-core/lib')
-rw-r--r--node_modules/babel-core/lib/transformation/file/index.js44
-rw-r--r--node_modules/babel-core/lib/transformation/file/options/option-manager.js2
-rw-r--r--node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js36
3 files changed, 27 insertions, 55 deletions
diff --git a/node_modules/babel-core/lib/transformation/file/index.js b/node_modules/babel-core/lib/transformation/file/index.js
index 76dc7c522..d3d0e0705 100644
--- a/node_modules/babel-core/lib/transformation/file/index.js
+++ b/node_modules/babel-core/lib/transformation/file/index.js
@@ -51,10 +51,6 @@ var _babelTraverse = require("babel-traverse");
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
-var _sourceMap = require("source-map");
-
-var _sourceMap2 = _interopRequireDefault(_sourceMap);
-
var _babelGenerator = require("babel-generator");
var _babelGenerator2 = _interopRequireDefault(_babelGenerator);
@@ -89,6 +85,10 @@ var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
+var _mergeMap = require("./merge-map");
+
+var _mergeMap2 = _interopRequireDefault(_mergeMap);
+
var _resolve = require("../../helpers/resolve");
var _resolve2 = _interopRequireDefault(_resolve);
@@ -446,40 +446,8 @@ var File = function (_Store) {
File.prototype.mergeSourceMap = function mergeSourceMap(map) {
var inputMap = this.opts.inputSourceMap;
- if (inputMap) {
- var inputMapConsumer = new _sourceMap2.default.SourceMapConsumer(inputMap);
- var outputMapConsumer = new _sourceMap2.default.SourceMapConsumer(map);
-
- var mergedGenerator = new _sourceMap2.default.SourceMapGenerator({
- file: inputMapConsumer.file,
- sourceRoot: inputMapConsumer.sourceRoot
- });
-
- var source = outputMapConsumer.sources[0];
-
- inputMapConsumer.eachMapping(function (mapping) {
- var generatedPosition = outputMapConsumer.generatedPositionFor({
- line: mapping.generatedLine,
- column: mapping.generatedColumn,
- source: source
- });
- if (generatedPosition.column != null) {
- mergedGenerator.addMapping({
- source: mapping.source,
-
- original: mapping.source == null ? null : {
- line: mapping.originalLine,
- column: mapping.originalColumn
- },
-
- generated: generatedPosition
- });
- }
- });
-
- var mergedMap = mergedGenerator.toJSON();
- inputMap.mappings = mergedMap.mappings;
- return inputMap;
+ if (inputMap && map) {
+ return (0, _mergeMap2.default)(inputMap, map);
} else {
return map;
}
diff --git a/node_modules/babel-core/lib/transformation/file/options/option-manager.js b/node_modules/babel-core/lib/transformation/file/options/option-manager.js
index 571c834ec..a15e47cb9 100644
--- a/node_modules/babel-core/lib/transformation/file/options/option-manager.js
+++ b/node_modules/babel-core/lib/transformation/file/options/option-manager.js
@@ -220,7 +220,7 @@ var OptionManager = function () {
this.log.error("Using removed Babel 5 option: " + alias + "." + _key2 + " - " + _removed2.default[_key2].message, ReferenceError);
} else {
var unknownOptErr = "Unknown option: " + alias + "." + _key2 + ". Check out http://babeljs.io/docs/usage/options/ for more information about options.";
- var presetConfigErr = "A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.";
+ var presetConfigErr = "A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options.";
this.log.error(unknownOptErr + "\n\n" + presetConfigErr, ReferenceError);
diff --git a/node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js b/node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js
index ae1d7b3d1..e7f8739c3 100644
--- a/node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js
+++ b/node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js
@@ -104,29 +104,33 @@ function remap(path, key) {
if (!passedShadowFunction) return;
var cached = fnPath.getData(key);
- if (cached) return path.replaceWith(cached);
+ if (!cached) {
+ var id = path.scope.generateUidIdentifier(key);
- var id = path.scope.generateUidIdentifier(key);
+ fnPath.setData(key, id);
+ cached = id;
- fnPath.setData(key, id);
-
- var classPath = fnPath.findParent(function (p) {
- return p.isClass();
- });
- var hasSuperClass = !!(classPath && classPath.node && classPath.node.superClass);
+ var classPath = fnPath.findParent(function (p) {
+ return p.isClass();
+ });
+ var hasSuperClass = !!(classPath && classPath.node && classPath.node.superClass);
- if (key === "this" && fnPath.isMethod({ kind: "constructor" }) && hasSuperClass) {
- fnPath.scope.push({ id: id });
+ if (key === "this" && fnPath.isMethod({ kind: "constructor" }) && hasSuperClass) {
+ fnPath.scope.push({ id: id });
- fnPath.traverse(superVisitor, { id: id });
- } else {
- var init = key === "this" ? t.thisExpression() : t.identifier(key);
+ fnPath.traverse(superVisitor, { id: id });
+ } else {
+ var init = key === "this" ? t.thisExpression() : t.identifier(key);
- if (shadowFunction) init._shadowedFunctionLiteral = shadowFunction;
+ if (shadowFunction) init._shadowedFunctionLiteral = shadowFunction;
- fnPath.scope.push({ id: id, init: init });
+ fnPath.scope.push({ id: id, init: init });
+ }
}
- return path.replaceWith(id);
+ var node = t.cloneDeep(cached);
+ node.loc = path.node.loc;
+
+ return path.replaceWith(node);
}
module.exports = exports["default"]; \ No newline at end of file