Skip to content

Commit

Permalink
Add support to run inside Meteor.
Browse files Browse the repository at this point in the history
When running this babel-plugin inside Meteor, it gives us
weird errors.
But, we don't  need this to use inside Meteor.
Meteor do this for us automatically.
So, we simply turn off this when using inside Meteor.
  • Loading branch information
arunoda committed Jun 23, 2016
1 parent a43785d commit 90d7686
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@ export default function({ types: t }) {
}
}

// Here's we detect the use of Meteor and send a dummy plugin.
// That's because, Meteor already do this for us.
// global.meteorBabelHelpers is something we can see when
// running inside Meteor.
if (global.meteorBabelHelpers) {
return {
visitor: {}
};
}

return new BabelRootImport();
}

5 comments on commit 90d7686

@gsabran
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break https://github.com/michaelzoidl/babel-root-import custom root (https://github.com/michaelzoidl/babel-root-import#custom-root-path-suffix) that Meteor is not handling ?
Not sure how many people are using it with your fork.

@arunoda
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I don't think they are using this for that purpose. For that, orginal repo is the best way.

This is just to mimic, Meteor's root import syntax.

@gsabran
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! It seems to now not be working with webpack:webpack
I'm not familiar with the details of this build process, but I think it handles imports directly (and I'm not sure how Meteor is interfering), but meteorBabelHelpers is still in the global scope. Let me know what you think of PR #1 . I don't see cases where it'd be not as good. I've tested it with both webpack:webpack and bare meteor, but not in production yet.

@damonmaria
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using this plugin with Wallaby (run in the style of this setup which I think a lot of people are using) the global meteorBabelHelpers exists and Wallaby can't handle the root import. I have tried removing that global during the Wallaby bootstrap but no luck. Any ideas how to get these to work together?

@arunoda
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we need to find another way to detect whether Meteor exists or not.

Please sign in to comment.