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

How to import with webpack? #142

Open
coreyworrell opened this issue Feb 17, 2021 · 3 comments
Open

How to import with webpack? #142

coreyworrell opened this issue Feb 17, 2021 · 3 comments

Comments

@coreyworrell
Copy link

Expected Behaviour

Imports the default export

Actual Behaviour

Webpack outputs error: export 'default' (imported as 'balanceText') was not found in 'balance-text' (possible exports: ) and browser throws error Uncaught TypeError: root is undefined

Reproduce Scenario (including but not limited to)

npm install balance-text

Steps to Reproduce

import balanceText from 'balance-text'
balanceText()

This used to work fine. Not sure if newer Node/webpack version has caused this.

@coreyworrell
Copy link
Author

It builds without warnings when using

import * as balanceText from 'balance-text'

but then the root is undefined error still happens. Looks like this is undefined during webpack bundling or something.

@coreyworrell
Copy link
Author

It appears this is related to Babel, and adding an override for file can fix it: https://stackoverflow.com/a/34983495/214270

I haven't noticed this with other libraries though, so maybe something can be done to better support this.

@redmunds
Copy link
Contributor

@coreyworrell Thanks for reporting bug and followup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants