Type-only files cause issues with Parcel bundler
See original GitHub issueDescription
When bundling chakra with parcel, a runtime error occurs because type-only files in chakra get compiled to empty modules which cannot be identified as ESM.
Link to Reproduction
Cannot be reproed in code sandbox; see STR.
Steps to reproduce
- Clone https://github.com/matt-tingen/parcel-export-repro
git checkout chakra
yarn
yarn full
- Open page in browser
- Observe error in console e.g.
Uncaught ReferenceError: $b8b48c5226d10867$exports is not defined
Chakra UI Version
1.6.4
Browser
Firefox 89.0
Operating System
- macOS
- Windows
- Linux
Additional Information
See https://github.com/parcel-bundler/parcel/issues/6361 for background.
Per the parcel team, the correct fix here is for empty ESM modules to export {}
which will be applied automatically in babel >= 7.14.4
. Could we update babel in chakra or otherwise disambiguate/exclude type-only files?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How It Works - Parcel
A bundle is created for the entry asset, and child bundles are created for dynamic import() s, which cause code splitting to occur....
Read more >Parcel-bundler NPM - npm.io
parcel takes as input a single entry asset, which could be any file type: JS, HTML, CSS, image, etc. There are various asset...
Read more >What you need to know about Parcel 2 - LogRocket Blog
From transformers, which take one file type and convert it to another, ... aspect of Parcel in previous iterations of the Parcel bundler....
Read more >Untitled
Install with yarn: ```shell yarn global add parcel-bundler ``` or with npm: ```shell ... Parcel can take any type of file as an...
Read more >Bundling and Building with Parcel - Beginner JavaScript
npm install parcel-bundler --save--dev. Instead of --save-dev you could also type -D which is a short form. That will add Parcel as a...
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 FreeTop 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
Top GitHub Comments
This is now resolved within parcel. The ask here (updating babel) is no longer relevant so I’m closing the issue.
My workaround is to use
patch-package
to addexport {};
to the following files:node_modules/@chakra-ui/react-utils/dist/esm/types.js
node_modules/@chakra-ui/utils/dist/esm/types.js