-
Notifications
You must be signed in to change notification settings - Fork 17
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
Equivalent Babel Plugin? #9
Comments
I was building this plugin specifically for Webpack. Not very familiar with creating Babel plugins, but based on my understanding of what Babel does, it seems this is not really Babel's responsibility. Maybe what's needed is an equivalent thing for node.js? |
Often people use babel runtime compilation for server side renders of isomorphic apps (as they need to compile JSX) to keep the codebase all with the same language features. Especially if they can't use the latest node. In this case it's normal to use the babelrc configuration for the server side code. A babel plugin is the obvious choice. There are some that already exist for the e.g.
|
I thought all Babel does is to transpile the given string in es2015 or any format supported to es5 JavaScript code. It doesn't really resolve the path itself, that part is done by Webpack, Browserify, Node.js, etc. My understanding is if Babel sees an |
You can use babel without Webpack and in that case it can handle resolving paths. |
Would you please be able to point me to some links/articles that explain how this works? When I use Babel on the server, it is |
Just had a look at the https://babeljs.io/docs/usage/babel-register/ and looks like my understanding is not correct, and there's an option |
It might be worth having a look at how https://github.com/tleunen/babel-plugin-module-resolver achieves the resolution for babel. I'm guessing it would map import paths to require calls in compilation using absolute paths. I guess it would be much trickier as an alias is a straight swap whereas this functionality is more dynamic to the existence of files. |
+1 |
I found this plugin but it's not published on npm despite saying so |
Oh nice! Did you see it working @IgnusG ? Might be worth publishing it anyway |
A month ago I was seeking for the equivalent babel plugin too and I was here to +1. But there's no such plugin really works So I wrote the plugin myself and all tests passed. However it doesn't work with my webpack and babel config. I don't know where the problem is and it may cost me much more time to solve it rather than just adding few Besides, you can try to install it directly from GitHub:
And PRs are welcomed 😎 |
If both Webpack and Babel are used, then probably just let Webpack does the resolving. And the Bebal plugin is perhaps only needed when Babel is used alone. |
Closing now given @mdluo has created a repo for this. |
For anyone looking for a solution to this: I moved from using |
This plugin looks great! However in an isomorphic app it's a no-go unless you're webpacking your node code. If there's an equivalent babel plugin, that would be great! I had a good look around but couldn't find one.
The text was updated successfully, but these errors were encountered: