Code Monkey home page Code Monkey logo

babel-plugin-ramda's People

Contributors

adamjmcgrath avatar borisirota avatar dependabot[bot] avatar hhogg avatar jacobblomgren avatar lensbart avatar maadhattah avatar megawac avatar mjrussell avatar phyllisstein avatar probablyoptimal avatar rmdort avatar sinewyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

babel-plugin-ramda's Issues

Problem with for await

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

Can't seem to get it to work...

I'm sure this is a configuration issue on my end, but I'm a bit stuck.

  1. I've installed v1.6.3 (as I'm on babel 6.26)
  2. I added this to my .babelrc: ["ramda", { "useES": true }]
  3. I rebuild everything... and my package size is the same, even though I'm only using a bit of Ramda

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.

Why was ramda removed as a dependency in v2.1.0?

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!

1.6.1: Strange NodePath error, not present with 1.6.0

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?

ramda/src vs ramda/es

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.

Using ramda members as specified imports without invocation not supported

The plugin supports 2 modes:

  • call expression
import { compose } from 'ramda'
...
compose(...)
  • as a member
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.

Troubles with wildcard exports of ES6

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.

Ramda method A was not a known function

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?

`ramda` better as a peer dependency

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.

Ramda method direction was not a known function

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

Spread operator not working for pipe with specifier.

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])

Add tag to support Ramda v0.28.0

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?

Star import not working

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.

Does this work with babel6 ?

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)

Failed to compile with webpack when using `import R from 'ramda'`

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?

Allow import * as R from 'ramda'

Specifying import like import * as R from 'ramda'; breaks the plugin, causing it to remove the import statement and do nothing else.

With import * as R from 'ramda';:

screen shot 2017-04-03 at 12 59 32

With import R from 'ramda';:

screen shot 2017-04-03 at 12 58 18

With import * as R from 'ramda'; and without the ramda plugin:

screen shot 2017-04-03 at 13 01 30

Is there any specific functionality compared to Babel import plugin?

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?

Undefined imports

Version Info

  • node: 9.7.1
  • webpack: 3.8.1
  • ramda: 0.25.0
  • babel-plugin-ramda: 1.6.1

Explanation

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!

Doesn’t seem to work with `export from`

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';

useES config not work in 1.5.0

I want to use ['ramda', { 'useES': true }] so that turn 'ramda/src/' to 'ramda/es/', but it does not work.
when I saw the source code, I find the release of 1.5.0 is the same as 1.4.3.
here is my modules info
image
image

Error with plugin in .babelrc

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!

Missing lib folder in v2.1.0

Hello 👋

It seems the lib/ folder is missing in the published NPM package for version 2.1.0, published 2 days ago.

Compare v2.0.0 (source):
Screenshot 2022-06-16 at 15 58 12

and v2.1.0 (source):
Screenshot 2022-06-16 at 15 56 17

Could you please publish a new version with the missing files?

Many thanks

babel 7 support

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.

Does not work with spread / call

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.