megawac / babel-plugin-ramda Goto Github PK
View Code? Open in Web Editor NEWEasy :ram: modular builds
Easy :ram: modular builds
We're not checking if the import source is from ramda
here
So it throws the error on every single export *
statement
Hi there,
There seems to be an error when using for await
(from stage-3 preset) in combination with the ramda babel plugin.
TypeError: .../ramda-plugin-async-problem/index.js: Cannot read property 'file' of undefined
at PluginPass.Identifier (.../ramda-plugin-async-problem/node_modules/babel-plugin-ramda/lib/index.js:108:23)
I managed to create a repository where this can be reproduced easily. As soon as you remove the ramda plugin from .babelrc
it works again.
git clone https://github.com/davidknezic/ramda-plugin-async-problem
cd ramda-plugin-async-problem
yarn
yarn start
I'm sure this is a configuration issue on my end, but I'm a bit stuck.
.babelrc
: ["ramda", { "useES": true }]
Here's my full babel file, if that helps:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
],
"plugins": [
["ramda", { "useES": true }],
"syntax-dynamic-import",
"transform-object-rest-spread",
["transform-class-properties", { "spec": true }]
]
}
Please let me know if there's anything else I can provide.
Hi team,
We recently upgraded from v2.0.0 to v2.1.0, and noticed that the ramda package was removed from the dependencies. In v2.0.0, ramda was listed under dependencies:
"dependencies": {
"@babel/helper-module-imports": "^7.0.0",
"ramda": "*"
}
After upgrading, our application started breaking with the following error:
Cannot find module 'ramda'
[0] Require stack:
[0] - /home/sprinternal/app/node_modules/babel-plugin-ramda/lib/modules.js
[0] - /home/sprinternal/app/node_modules/babel-plugin-ramda/lib/index.js
Could you please provide some insight into why ramda was removed in v2.1.0?
Thank you!
Firstly, thanks for creating this plugin! I've found it incredibly useful.
However when adding v1.6.1
to a project recently, we got this strange error when running babel:
NodePath has been removed so is read-only. (This is an error on an internal node. Probably an internal error)
.
However, v1.6.0
does not have the issue. I'm guessing the package-lock.json
added alongside v1.6.1
locked down a dodgy babel dependancy?
Might be worth regenerating a fresh package lock?
With the release of ramda v25, would it be possible to use ramda/es
instead of ramda/src
? As I understand it, this plugin might very well be the solution to the tree shaking problems that I and many others have with ramda, as discussed in ramda/ramda#2355 and ramda/ramda#1505, but that seems to necessitate the use of ramda/es
. If so, I could help with a PR.
Ramda should be a direct dependency in package.json
The plugin throws an error when i use it in projects which doesnt use ramda
. (Using it as part of my own preset)
The plugin supports 2 modes:
import { compose } from 'ramda'
...
compose(...)
import R from 'ramda'
R.compose(...)
But there is no support for using the first approach without invoking the function:
import R, { __ } from 'ramda'
R.curry(function add(a, b) {
return a + b;
})(__, 2)
The __
is ignored because its not called expression and not a member.
Hi; this one is baffling me.
I have code like such, which imports modules using ramda.
export * from './foo'
When running babel over my code with this plugin it fails with the following errors:
Cannot read property 'file' of undefined
at PluginPass.Identifier (/code/test/ramda-plugin-fix/node_modules/babel-plugin-ramda/lib/index.js:80:23)
at newFn (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/visitors.js:293:19)
at NodePath._call (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/path/context.js:75:18)
at NodePath.call (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/path/context.js:47:17)
at NodePath.visit (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/context.js:156:16)
at TraversalContext.visitSingle (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/context.js:113:19)
at TraversalContext.visit (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/context.js:200:19)
at Function.traverse.node (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/index.js:141:17)
at NodePath.visit (/code/test/ramda-plugin-fix/node_modules/babel-traverse/lib/path/context.js:115:22)
I forked your repo and included a test specifically for this use case, but no errors whilst running the tests. I thought perhaps another babel plugin or dependency may be causing the issue. So then I created a super simple project with no other dependencies but when running the project it fell over immediately. Very peculiar.
I have included the project I created in this link: https://www.dropbox.com/s/qc99y5578o46860/ramda-plugin-fix.zip?dl=0
It's using node 4.3.1 and npm 3.7.3 as specified in the package.json file.
If you do an npm install && npm run build
you'll see the error.
I've come across that error for a few functions like mergeRight
and includes
. I'm using babel-plugin-ramda version of 2.0.0 with ramda on version 0.27.0. My configuration for babel lives in my webpack config, in this part:
rules: [
{
test: /\.js$/,
exclude: /mapbox-gl/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'ramda',
'babel-plugin-styled-components',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import'
]
}
}
]
},
I've tried to look this issue up and found some similar ones but I couldn't apply any of those solutions here. Any ideas what I might be doing wrong here?
Right now, when I install, the babel plugin & ramda, I get two versions installed. It appears the babel plugin does correctly resolves to the top-level version (rather than the old-ish version it installs itself) but it seems unnecessarily duplicative to install both versions of ramda
. Moving to a peer dependency would fix this.
Hi! This piece of code doesn't work properly.
const mySort = (items, descending) => {
const direction = descending ? 'descend' : 'ascend'
return R.sort(R[direction](R.prop('id')))(items)
}
Use case when we access ramda methods via variable and square brackets. It shows me the error during building.
Ramda method direction was not a known function
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Ramda method includes was not a known function
Noob question here, do I still need this preset if I migrate to webpack 2 and enable tree shaking?
Related to #19, but with a different syntax; this is broken:
import { pipe, map, add } from 'ramda'
const operations = [map(add(1)), map(add(2))]
pipe(...operations)([1])
while this does work:
import R from 'ramda'
const operations = [R.map(R.add(1)), R.map(R.add(2))]
R.pipe(...operations)([1])
As merge
has been deprecated in v0.28.0 of Ramda we can't upgrade our Ramda version due to a dependency on this package.
I see support for this change has already been committed here - replacing merge
with mergeRight
.
Can you tag a release with this commit in so we can upgrade please?
http://ramdajs.com/docs/#startsWith
added in 0.25.0
import * as R from "ramda"
- this is recommended in Ramda >= 0.25.0. However, the import is just removed, usages stay the same and you get a runtime error of R is not defined
.
I am getting an error with babel6, the lodash version seems to be working great. I haven't diffed the changes between code base.
TypeError: Plugin is not a function
at exports.default (/home/risto/my-app-name-here/node_modules/babel-plugin-ramda/lib/index.js:33:10)
at Function.memoisePluginContainer (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:1
27:13)
at Function.normalisePlugin (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:161:32)
at /home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:197:30
at Array.map (native)
at Function.normalisePlugins (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20)
at OptionManager.mergeOptions (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36
)
at OptionManager.mergeOptions (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:303:10
)
at OptionManager.addConfig (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:221:10)
at OptionManager.findConfigs (/home/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:364:16)
In a file (for debugging purposes) I have:
import R from 'ramda'
...
window.R = R
This causes the following build error in webpack:
ERROR in ./frontend/src/utils.js
Module build failed: TypeError: /Users/andrew/Projects/TransparentClassroom/frontend/src/utils.js: Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "NullLiteral"
at validate (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-types/lib/definitions/core.js:412:50)
at Object.validate (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-types/lib/index.js:505:9)
at NodePath._replaceWith (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/path/replacement.js:176:7)
at NodePath.replaceWith (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/path/replacement.js:160:8)
at PluginPass.Identifier (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-plugin-ramda/lib/index.js:134:16)
at newFn (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/Users/andrew/Projects/TransparentClassroom/node_modules/babel-traverse/lib/path/context.js:105:12)
@ ./frontend/src/application.js 17:13-31
@ ./frontend/src/locales/application.en.js
@ multi (webpack)-dev-server/client?http://localhost:3808 ./frontend/src/locales/application.en.js
webpack: Failed to compile.
When I comment out the line window.R = R
, everything compiles fine.
Have others seen this before?
I found that using babel-plugin-import
to enable tree shaking is recommended by various other utility libraries (Lodash, Material UI, Ant Design).
If I understand correctly, it solves exactly the same problem as this project. Is there any reason to use this library specifically (anything that it is doing better) or I will achieve same results with babel import plugin?
node
: 9.7.1
webpack
: 3.8.1
ramda
: 0.25.0
babel-plugin-ramda
: 1.6.1
I've been having issues compiling my project using babel-plugin-ramda
.
Here's what the source code import looks like:
import { compose, lensProp } from 'ramda'
And here's the error I'm receiving:
Uncaught ReferenceError: _lensProp is not defined
What's odd, is that if I change the import order to something like this:
import { lensProp, compose } from 'ramda'
The error changes to:
Uncaught ReferenceError: _compose is not defined
This plugin has worked for me in the past, but stopped working this past Thursday, and I've been unable to debug it since...
Here's what my babel configuration looks like:
"babel": {
"presets": [
"react-app"
],
"plugins": [
"macros","ramda"
]
},
Any insights into debugging this would be greatly appreciated!
hi ! awesome lib ! thanks ;)
I'm trying to use it with Jest to have a full coverage and I'm getting this error:
ReferenceError: R is not defined
help?
It’s not a big deal but this plugin doesn’t work when reexporting Ramda functions with the new syntax introduced by this proposal .
For instance the following:
export { path, pathOr } from 'ramda';
should be rewritten to:
export path from 'ramda/src/path';
export pathOr from 'ramda/src/pathOr';
instead of being left untouched.
Special care must be taken to preserve renaming:
export { path as getIn } from 'ramda';
should be rewritten to:
export getIn from 'ramda/src/path';
Same as #11 ?
The last release seems to have a conflict with babel. I've got the following error after npm i
:
Error: Plugin 0 specified in "path/to/project/.babelrc" provided an invalid property of "F"
My .babelrc
{
"presets": ["react", "es2015", "stage-0"],
"plugins": ["ramda"]
}
Thank you!
Is this still being maintained for babel 7 support? it's in beta now so would be worth preparing this plugin so people can experiment before 7 goes stable.
For the reasons I mentioned in chat
Its seems that plugin does not work with spread operator or invoking function using call
Example:
const result = R.pipe(R.inc, R.inc)(1); //Working
const resultB = R.pipe(...[R.inc, R.inc])(1); //Not working
const resultC = R.pipe.call(R, [R.inc, R.inc])(1); //Not working
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.