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.

Type-only files cause issues with Parcel bundler

See original GitHub issue

Description

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

  1. Clone https://github.com/matt-tingen/parcel-export-repro
  2. git checkout chakra
  3. yarn
  4. yarn full
  5. Open page in browser
  6. 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:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
matt-tingencommented, Oct 14, 2021

This is now resolved within parcel. The ask here (updating babel) is no longer relevant so I’m closing the issue.

1reaction
matt-tingencommented, Jul 3, 2021

My workaround is to use patch-package to add export {}; to the following files:

  • node_modules/@chakra-ui/react-utils/dist/esm/types.js
  • node_modules/@chakra-ui/utils/dist/esm/types.js
Read more comments on GitHub >

github_iconTop 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 >

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