question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run Babel in node_modules

See original GitHub issue

Describe the bug

react-static can not minify the main entry-point because it pulls in a dependency that uses newer JavaScript features than UglifyJS can handle.

ERROR in main.51c74111.js from UglifyJs
Unexpected character '`' [/Users/redacted/dev/this-week-in-react/node_modules/performance-now/index.js:21,0][main.51c74111.js:12593,20]

To Reproduce

Steps to reproduce the behavior:

  1. Check out the repo at https://github.com/philipp-spiess/this-week-in-react/pull/10
  2. Run yarn && yarn build
  3. See error

The package that is causing issues, performance-now, seems to be pulled in via raf which is a dependency of react-static:

β this-week-in-react (react_static) yarn why performance-now
yarn why v1.12.0
[1/4] 🤔  Why do we have the module "performance-now"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "performance-now@2.1.0"
info Reasons this module exists
   - "react-static#raf" depends on it
   - Hoisted from "react-static#raf#performance-now"
   - Hoisted from "open-graph-scraper#request#performance-now"
   - Hoisted from "react-static#download-git-repo#download#decompress#performance-now"
info Disk size without dependencies: "16MB"
info Disk size with unique dependencies: "36MB"
info Disk size with transitive dependencies: "36MB"
info Number of shared dependencies: 1
✨  Done in 0.71s.

Expected behavior

The build script displays no errors, the main.js artifact ends up being is compressed.

Desktop (please complete the following information):

  • OS: macOS 10.13.5
  • Node.js: v9.7.1
  • Yarn: 1.12.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kernelwhisperercommented, Oct 21, 2018

This is still a problem, one thing to note though, it errors only when building, using the package in development works.

Repo: https://github.com/0x6431346e/build-error-repro/

I don’t think this is a problem with the multihashes package, it looks fine, but I guess it could be…

0reactions
ScriptedAlchemycommented, Dec 13, 2018

that’s an acceptable solution in my opinion.

try Tanners solution and let us know if it resolves the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/node - Babel.js
babel -node is a CLI that works exactly the same as the Node.js CLI, with the added benefit of compiling with Babel presets...
Read more >
How to Setup Babel in Node.js - freeCodeCamp
Let's setup a basic Node app which we will use for this tutorial. Create a new folder. For this tutorial, I'll call mine...
Read more >
how to run node / babel script directly in command line?
You may run it simply by typing. node_modules/.bin/babel-node --presets env app.js. Which accomplishes the same thing as the longer ...
Read more >
@babel/node - npm
Start using @babel/node in your project by running `npm i @babel/node`. There are 712 other projects in the npm registry using @babel/node.
Read more >
How to transpile node_modules with babel and webpack in a ...
Webpack is highly configurable, and can be set up so one can configure Babel from within the webpack configuration file, which is usually ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found