Certain function is lost in production builds
See original GitHub issue🐛 bug report
In serve mode, I was able to use chakra-ui with parcel working fine, but in production build, chakra-ui is broken.
This is because the required function has been transform to {} in the production build.
🎛 Configuration (.babelrc, package.json, cli command)
package.json
{
"name": "curly-tribble",
"version": "1.0.0",
"license": "MIT",
"main": "dist/index.html",
"scripts": {
"dev": "parcel src/index.html",
"build": "parcel build src/index.html --no-source-maps",
"lint": "prettier --check './src/**/*.{js,ts,tsx}'",
"format": "prettier --write './src/**/*.{js,ts,tsx}'"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
},
"dependencies": {
"@chakra-ui/react": "^1.1.0",
"@emotion/react": "^11.1.4",
"@emotion/styled": "^11.0.0",
"framer-motion": "^3.1.1",
"parcel": "^2.0.0-nightly.496",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
}
🤔 Expected Behavior
Works the same way as serve mode.
😯 Current Behavior
TypeError: {} is not a function
at Pb (use-style-config.js:29)
at heading.js:9
at Hs (react-dom.production.min.js:157)
at hc (react-dom.production.min.js:176)
at di (react-dom.production.min.js:271)
at bd (react-dom.production.min.js:250)
at md (react-dom.production.min.js:250)
at hd (react-dom.production.min.js:250)
at id (react-dom.production.min.js:243)
at td (react-dom.production.min.js:237)
var mergedProps = mergeWith({
theme,
colorMode
}, (_styleConfig$defaultP = styleConfig == null ? void 0 : styleConfig.defaultProps) != null ? _styleConfig$defaultP : {}, filterUndefined(omit(rest, ["children"])));
--no-source-maps
TypeError: {} is not a function
at Pb (index.9496bcd0.js:1)
at index.9496bcd0.js:1
at Hs (index.9496bcd0.js:1)
at hc (index.9496bcd0.js:1)
at di (index.9496bcd0.js:1)
at bd (index.9496bcd0.js:1)
at md (index.9496bcd0.js:1)
at hd (index.9496bcd0.js:1)
at id (index.9496bcd0.js:1)
at td (index.9496bcd0.js:1)
, d = {}({
theme: l,
colorMode: u
}, null != (r = null == c ? void 0 : c.defaultProps) ? r : {}, em(Xh(i, ["children"]), (e=>null != e)))
The function mergeWith has disappeared, which is exported from lodash in the form of default as.
https://github.com/chakra-ui/chakra-ui/blob/085891be806b855af90b86367f5b26e8151c3ff5/packages/utils/src/object.ts#L3
💁 Possible Solution
~~Maybe it has something to do with https://github.com/parcel-bundler/parcel/issues/5459.~~
Build with --no-scope-hoist, I noticed this after I submitted the Issue…
🔦 Context
Want to use chakra-ui with parcel.
💻 Code Sample
https://github.com/vivid-lapin/curly-tribble
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.0.0-nightly.496 |
| Node | v14.15.0 |
| npm/Yarn | yarn 1.22.5 |
| Operating System | macOS 10.15.7 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Android: adbd cannot run as root in production builds
I need to access to the whole filesystem of my phone. If i do "id", obviously i obtain "uid=0(root) gid=0(root)". I'd like to...
Read more >Manage functions | Cloud Functions for Firebase - Google
If you are renaming or changing the regions or trigger for functions that are handling production traffic, follow the steps in this section...
Read more >Shrink, obfuscate, and optimize your app - Android Developers
Learn how to shrink code in your release build to remove unused code and ... is useful if certain keep rules are required...
Read more >Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >CI/CD pipelines explained: Everything you need to know
Planning to implement CI/CD? This comprehensive guide explores the stages of a CI/CD pipeline, its pros and cons, best practices and more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Great, this was fixed with https://github.com/parcel-bundler/parcel/pull/4815
Just tested it… it’s fixed. 👍