-
Notifications
You must be signed in to change notification settings - Fork 33
Babel plugin ramda
赵永盛 edited this page Feb 1, 2023
·
1 revision
This plugin is a transform to remove unused ramda dependencies, without forcing the user to cherry pick methods manually. This lets you use ramda naturally (aka as documented) without worrying about bundling parts you're not using.
See also babel-plugin-lodash
.
Converts
import R, {map} from 'ramda';
map(R.add(1), [1, 2, 3]);
Roughly to
import add from 'ramda/src/add';
import map from 'ramda/src/map';
map(add(1), [1, 2, 3]);
- You must be using ES6 imports (both specifiers and default work) to load ramda.
I receive
TypeError: The plugin "ramda" didn’t export a Plugin instance
or, can I use this plugin with Babel v5?
Babel v5 is no longer supported. Use v0.1.2 for support.
{
"plugins": ["ramda"]
}
or
{
"plugins": [
["ramda", {
"useES": true
}]
]
}
to use the new ramda/es/
path for imports, which is available since Ramda 0.25. This is recommended as it uses ES modules rather than CommonJS. It defaults to ramda/src/
when omitted.
$ babel --plugins ramda script.js
require("babel-core").transform("code", {
plugins: ["ramda"]
});