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

Ansi-to-react doesn't compile to ES5 #4955

Closed
ibrahima opened this issue Feb 25, 2020 · 4 comments
Closed

Ansi-to-react doesn't compile to ES5 #4955

ibrahima opened this issue Feb 25, 2020 · 4 comments
Labels
outdated workflow: issue should stay closed workflow: needs user info Additional info is needed from issue filer

Comments

@ibrahima
Copy link

ibrahima commented Feb 25, 2020

Application or Package Used
ansi-to-react

Describe the bug

I've added ansi-to-react to my package.json and have been using it since around v3. After upgrading to v5 and v6, it seems that it's breaking the UglifyJS step in my build process. It looks like the distributed version of ansi-to-react is not being compiled down to ES5 so UglifyJS is unhappy.

ERROR in vendor-ee0bec9920209c414558.js from UglifyJs
Unexpected token operator «=», expected punc «,» [./node_modules/ansi-to-react/lib/index.js:26,0][vendor-ee0bec9920209c414558.js:20987,39]

The relevant line is

function ansiToJSON(input, use_classes = false) {

Default function arguments are an ES6 (or newer? not sure) feature and are not compatible with ES5. IDK if there's a way configure UglifyJS or upgrade it to get it to deal with ES6 but I think in general we are not running stuff in node_modules through babel or anything like that, and that generally works fine.

To Reproduce

  1. Add ansi-to-react to package.json (e.g. yarn add ansi-to-react@^6.0.0)
  2. Also be using UglifyJS (I am not totally sure how we're using it but we are using Rails 5.2/Webpacker v3)
  3. Try to compile an uglified version
  4. Get an error message

Expected behavior

It should compile

Additional context

Stack:

  • Rails 5.2
  • Webpacker 3.2.0
  • Webpack v3.12.0
  • uglifyjs-webpack-plugin@^0.4.6:
  • uglify-js@^2.8.29

Hope that's enough detail! It seems like perhaps the TS compiler needs to be configured to output ES5 or something along those lines?

@ibrahima
Copy link
Author

In the meantime I've worked around this by adding a rule to my webpack config to process the ansi-to-react package via babel, following an approach recommended in webpack/webpack#2031 (comment)

@willingc
Copy link
Member

willingc commented Mar 8, 2020

Hi @ibrahima. Thanks for the detailed report. Just to clarify this issue:

  • are you seeing this when working on nteract for development?
  • or is this unrelated to nteract?

@willingc willingc added the workflow: needs user info Additional info is needed from issue filer label Mar 8, 2020
@ibrahima
Copy link
Author

ibrahima commented Mar 8, 2020

Hi! This is unrelated to nteract, I'm just trying to use the ansi-to-react npm package in a different application. Thanks!

@willingc
Copy link
Member

willingc commented Mar 8, 2020

Thanks for letting us know @ibrahima

@willingc willingc closed this as completed Mar 8, 2020
@lock lock bot added the outdated workflow: issue should stay closed label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated workflow: issue should stay closed workflow: needs user info Additional info is needed from issue filer
Projects
None yet
Development

No branches or pull requests

2 participants