-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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: Skipping static resource ... - max size is 2.1 MB #2433
Comments
I think I found out the root of this error. CRA build failed if I use package [email protected] to do http request. |
Replace |
As mentioned in #321, how can I make UglifyJS supports minifying ES2015 code during CRA build process? |
You can't. Please ask your dependencies to be compiled to ES5. Builds are pretty slow already, and compiling them with Babel is just going to make them slower. Additionally, Babel sometimes breaks code so we can't arbitrarily compile everything with it. |
I see now. Thank you, Dan. I will close this ticket. |
The message about "skipping" is misleading though. We should remove that message as it obscures the real issue. |
Can someone explain what the cause and solution to this is? I'm getting the same when trying to build a pretty much empty {
"dependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router-dom": "^4.1.1",
"semantic-ui-css": "^2.2.10",
"semantic-ui-react": "^0.68.4"
},
"devDependencies": {
"@types/jest": "^19.2.3",
"@types/node": "^7.0.22",
"@types/react": "^15.0.25",
"@types/react-dom": "^15.5.0",
"@types/react-router-dom": "^4.0.4",
"react-scripts-ts": "2.2.0"
},
"scripts": {
"start": "NODE_PATH=src react-scripts-ts start",
"build": "NODE_PATH=src react-scripts-ts build",
"test": "NODE_PATH=src react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
}
} Do I need to eject and modify something in Webpack to get it working? The error I'm getting is:
|
@codeaid Please report this to
What is |
@gaearon - my import asyncComponent from 'components/AsyncComponent';
const HomeScreen = asyncComponent(() => import('screens/HomeScreen'));
const LoginScreen = asyncComponent(() => import('screens/LoginScreen'));
export default [
{
path: '/',
title: 'Home',
component: HomeScreen,
layout: true,
},
{
path: '/login',
title: 'Login',
component: LoginScreen,
},
]; The async loader is taken from here and looks like this. I don't think the |
There are similar issues because the underlying problem is the same: Uglify can only handle ES5 code. So if you give it ES6 it will choke. People having similar issues experience this because they are consuming dependencies that aren't compiled to ES5. The solution in this case is to raise an issue with authors of these packages and ask them to compile to ES5. But in your case The bottom line is:
Also "it just adds support for TypeScript" is not very accurate description in my opinion. It is a fork, and forks can contain arbitrary mistakes. |
Hmm, converted my routes to load like this: import HomeScreen from 'screens/HomeScreen';
import LoginScreen from 'screens/LoginScreen'; ...and it built successfully, so you're probably right. Looks like TypeScript doesn't support |
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.
Not to do with this specific PR, but same Uglify error.* My IDE's syntax highlighting** was indicating an unresolved export in my component, so thinking I had done something wrong tried to import from within an NPM published module. Bad idea, it turned out I managed to inadvertently import an ES6 file and determining why builds failed in the above-described manner was pretty tricky. e.g. MyComponent.js:
* Posting in hopes this saves someone else (or future me) time resolving! ** JetBrains (latest at time of writing). |
I suggest you not to rely on IDEs for imports too much. They don’t really understand what’s going on, and can offer confusing suggestions. You should write imports the way they’re written in package documentation, regardless of whether IDE thinks it’s right or not. |
Closing, as misleading message was removed in #2645. If you find this issue by googling because you see this message please check for Uglify error below: most likely that's the one you want to look at. |
Dan you make an excellent point regarding IDEs. |
Hi all, I got problem when run
yarn build
.I'm using the lates
yarn
withnode 6.10.3
I created an example repo with build error here.
Can you help me to figure out why the project failed to compile? Thank you!!!
The text was updated successfully, but these errors were encountered: