-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-default imports #1
Comments
Hi Tylor! I started this only to experiment with the process of building babel plugins to solve the same global provides functionality of webpack. However my knowledge of writing babel plugins is very limited! I'm actually not using this anywhere either -- happy to accept PRs though! :) NB. Does this package actually work for you? |
Yes my knowledge is very limited on babel plugins as well, did try to create one once but I didn't find it possible currently. Thank you for your very quick response, if I do decide to move away from webpack I'll likely see if I'm able to create the above and submit a PR if successful 😄 |
@tomatau @TylorS its not that hard, here is an example (for babel v5.x):
|
Feel free to make a PR. I'll be looking to hack on this again in around 2 weeks from now (between jobs) but am waiting on gaearon/babel-plugin-react-transform#46 before moving to babel6. @vyorkin are you using this plugin currently? |
No, I'm just playing around with babel, nothing serious |
@tomatau any chance of updating this for Babel 6? or do you know of an existing solution? (nice username btw ;-)) Edit: for anyone else ending up here; found this, seems to work: https://www.npmjs.com/package/babel-plugin-module-provider |
Hey @tomat, glad that you found my experiment to be useful. My apologies for not sharing it myself, I almost forgot about this thread. |
Only thing I couldn't figure out was how to do |
I've just published version 1 for babel6 with the following setup: {
"plugins": [
["provide-modules", {
"debug": "debug", // default
"lodash": ["get", "assign"], // de-structured
"react-dom": [{"findDOMNode" : "find"}], // de-structured with alias
// both default and de-structured imports with alias
"react": {
"default": "React",
"destructured": ["PropTypes", {"cloneElement": "clone" }],
}
}]
]
} The above will inject the following into every file: import debug from 'debug';
import {get, assign} from 'lodash';
import {findDOMNode as find} from 'react-dom';
import React, {PropTypes, cloneElement as clone} from 'react'; Thanks @TylorS for your version of it, stole your API as it felt clean -- but didn't want to impose on your code too much and just keen to practice and get this up to date :) |
Looks like you have it all figured out 👍 I think it's safe to close this one now, great work! |
Hello, currently I'm using webpack to provide this kind of functionality. I'm investigating the possibility of removing webpack from my builds, and I came along this project. First I'd like to say thank you for your work on this package.
I was wondering though, would it be possible to do the following.
Where it would insert
This would be an awesome capability, at least in my use case.
Thank you for your time!
The text was updated successfully, but these errors were encountered: