UNPKG

1.46 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7exports.default = function (_ref) {
8 var t = _ref.types;
9
10 var BabelRootImport = function BabelRootImport() {
11 _classCallCheck(this, BabelRootImport);
12
13 var that = this;
14 return {
15 visitor: {
16 ImportDeclaration: function ImportDeclaration(path, state) {
17 var givenPath = path.node.source.value;
18
19 var rootPathSuffix = state && state.opts && typeof state.opts.rootPathSuffix === 'string' ? '/' + state.opts.rootPathSuffix.replace(/^(\/)|(\/)$/g, '') : '';
20
21 if ((0, _helper2.default)().hasRoot(givenPath)) {
22 path.node.source.value = (0, _helper2.default)().transformRelativeToRootPath(givenPath, rootPathSuffix);
23 }
24 }
25 }
26 };
27 };
28
29 // Here's we detect the use of Meteor and send a dummy plugin.
30 // That's because, Meteor already do this for us.
31 // global.meteorBabelHelpers is something we can see when
32 // running inside Meteor.
33
34
35 if (global.meteorBabelHelpers) {
36 return {
37 visitor: {}
38 };
39 }
40
41 return new BabelRootImport();
42};
43
44var _helper = require('./helper');
45
46var _helper2 = _interopRequireDefault(_helper);
47
48function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
50function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
\No newline at end of file