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

Build Error - Static Resource Size too Large #2475

Closed
okjintao opened this issue Jun 5, 2017 · 2 comments
Closed

Build Error - Static Resource Size too Large #2475

okjintao opened this issue Jun 5, 2017 · 2 comments

Comments

@okjintao
Copy link

okjintao commented Jun 5, 2017

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Can you reproduce the problem with latest npm?

Many errors, especially related to "missing modules", are due to npm bugs.

If you're using Windows, follow these instructions to update npm.

If you're using OS X or Linux, run this to update npm:

npm install -g npm@latest

cd your_project_directory
rm -rf node_modules
npm install

Then try to reproduce the issue again.

Can you still reproduce it?
Yes!

Description

What are you reporting?
Building create-react-app with snoowrap package results in a build error.

Expected behavior

Tell us what you think should happen.

The module should build and push to heroku to allow me to deploy my website.

Actual behavior

Tell us what actually happens.

I have two different set ups, one with the site, one with only create-react app and snoowrap.

Website Error:

remote: Creating an optimized production build...
remote: Skipping static resource "/tmp/build_8c164f80abe3d0afee2a5abb6d43ec77/build/static/js/main.e6b3427a.js" (2.42 MB) - max size is 2.1 MB
remote: Failed to compile.
remote: 
remote: static/js/main.e6b3427a.js from UglifyJs
remote: Unexpected token: punc ([) [./~/snoowrap/dist/helpers.js:151,55][static/js/main.e6b3427a.js:1637,56]
remote: 
remote: 
remote: npm ERR! Linux 3.13.0-112-generic
remote: npm ERR! argv "/tmp/build_8c164f80abe3d0afee2a5abb6d43ec77/.heroku/node/bin/node" "/tmp/build_8c164f80abe3d0afee2a5abb6d43ec77/.heroku/node/bin/npm" "run" "build"
remote: npm ERR! node v6.10.3
remote: npm ERR! npm  v3.10.10
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! cdv-site@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR! 

create-react-app & snoowrap only:

remote: Creating an optimized production build...
remote: Failed to compile.
remote: 
remote: static/js/main.4dec7976.js from UglifyJs
remote: Unexpected token: punc ([) [./~/snoowrap/dist/helpers.js:151,55][static/js/main.4dec7976.js:823,56]
remote: 
remote: 
remote: npm ERR! Linux 3.13.0-112-generic
remote: npm ERR! argv "/tmp/build_b9c89a800c56a30e1c98bfa4ffeb83d3/.heroku/node/bin/node" "/tmp/build_b9c89a800c56a30e1c98bfa4ffeb83d3/.heroku/node/bin/npm" "run" "build"
remote: npm ERR! node v6.10.3
remote: npm ERR! npm  v3.10.10
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! build-fail-demo@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR! 

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.7
  2. node -v: v7.10.0
  3. npm -v: 5.0.2

Then, specify:

  1. Operating system: Mac OSX Sierra 10.12.5
  2. Browser and version: Chrome Version 58.0.3029.110 (64-bit)

Reproducible Demo

Please take the time to create a new app that reproduces the issue.

Alternatively, you could copy your app that experiences the problem and start removing things until you’re left with the minimal reproducible demo.

(Accidentally, you might get to the root of your problem during that process.)

Push to GitHub and paste the link here.
Website: https://github.com/cdvallejo/cdv-site
Basic Example: https://github.com/cdvallejo/build-error

By doing this, you're helping the Create React App contributors a big time!
Demonstrable issues gets fixed faster.

@Timer
Copy link
Contributor

Timer commented Jun 5, 2017

The real problem is here:

remote: static/js/main.4dec7976.js from UglifyJs
remote: Unexpected token: punc ([) [./~/snoowrap/dist/helpers.js:151,55][static/js/main.4dec7976.js:823,56]

snoowrap is not compiled to ES5 which is expected from dependencies. Please ask snoowrap to publish an ES5 build.

I'll close this as a duplicate of #2433 to remove the confusing message about "static resource too large".

@Timer Timer closed this as completed Jun 5, 2017
@gaearon
Copy link
Contributor

gaearon commented Jun 5, 2017

Please ignore the "static resource" warning. It's irrelevant and we'll mute it soon.

The real error is just below:

remote: static/js/main.e6b3427a.js from UglifyJs
remote: Unexpected token: punc ([) [./~/snoowrap/dist/helpers.js:151,55][static/js/main.e6b3427a.js:1637,56]
remote: 

It means node_modules/snoowrap/dist/helpers.js has ES6 code that Uglify doesn't understand.
I looked at it, and it does:

return obj && (0, _omit3.default)(_extends({}, obj, { [newKey]: obj[oldKey] }), oldKey);

In particular, { [newKey]: obj[oldKey] } is ES6. Please ask snoowrap maintainers to compile it down to ES5, and it will work.

tlvince added a commit to tlvince/create-react-app that referenced this issue Jun 6, 2017
This crops up in the form of uglify errors during a production build, e.g. facebook#2236, facebook#2433, facebook#2475. The suggestion there is to transpile deps down to ES5 and/or remove `module`. However, `module` is there specifically to indicate ES module support, which uglify doesn't support, so ask webpack not to resolve it.
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants