Skip to content
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

mode wrap broken in 0.4.20(#168) #172

Open
PeoB opened this issue Nov 6, 2018 · 2 comments
Open

mode wrap broken in 0.4.20(#168) #172

PeoB opened this issue Nov 6, 2018 · 2 comments

Comments

@PeoB
Copy link

PeoB commented Nov 6, 2018

We end up with

template.expression is not a function
    at wrapTemplate (/*/node_modules/babel-plugin-transform-react-remove-prop-types

From here https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/pull/168/files#diff-1fdf421c05c1140f6d71444ea2b27638R157
When we are using mode: wrap for our code-base
Installing 0.4.19 works as a workaround

/cc @oliviertassinari

@PeoB PeoB changed the title mode wrap broken in #168 mode wrap broken in 0.4.20(#168) Nov 6, 2018
@oliviertassinari
Copy link
Owner

@PeoB I have upgraded the dependency to v0.4.20 in mui/material-ui#13540 without any issue. Do you have a reproduction example?

@PeoB
Copy link
Author

PeoB commented Nov 8, 2018

Sorry, company firewall is preventing me from pushing the example right now. But essentially:

example.jsx

import React from "react";
import PropTypes from "prop-types";

export const FooBar = ({hello}) => (
  <h1>{hello}</h1>
);

FooBar.propTypes = {
  hello: PropTypes.string
};

.babelrc

{
  "presets": [
    "react"
  ],
  "plugins": [
    ["transform-react-remove-prop-types", {
      "mode": "wrap"
    }]
  ]
}

package.json

{
  "name": "babel-remove-prop-types-error",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-plugin-transform-react-remove-prop-types": "^0.4.20",
    "babel-preset-react": "^6.24.1",
    "prop-types": "^15.6.2",
    "react": "^16.6.1"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0"
  }
}

babel example.jsx

babel example.jsx 
TypeError: example.jsx: template.expression is not a function
    at wrapTemplate (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js:169:34)
    at remove (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/remove.js:94:28)
    at AssignmentExpression (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js:298:35)
    at NodePath._call (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/projects/temp/babel-fail/node_modules/babel-traverse/lib/index.js:114:17)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants