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

Can't build with dfa 1.2.0 #643

Closed
nodepond opened this issue Jun 18, 2019 · 7 comments · Fixed by #1285
Closed

Can't build with dfa 1.2.0 #643

nodepond opened this issue Jun 18, 2019 · 7 comments · Fixed by #1285
Labels

Comments

@nodepond
Copy link

nodepond commented Jun 18, 2019

Describe the bug
I have a rails project with react, using webpacker and mostly babel for transforming javascript. When I try to use the @react-pdf/renderer in the project, the compiling of webpacker fails. I get the following error:

ERROR in ./node_modules/@react-pdf/fontkit/dist/fontkit.browser.es.js 8713:23-35 "export 'default' (imported as 'StateMachine') was not found in 'dfa'

To Reproduce
0. Setup a Ruby on Rails project with react, i.e. with react-rails

  1. yarn install @react-pdf/renderer
  2. import { Page, Text, View, Document, StyleSheet } from '@react-pdf/renderer' in React-Component
  3. Compile the project with webpacker or ./bin/webpack-dev-server

Indeed, if I look in the file /node_modules/@react-pdf/fontkit/dist/fontkit.browser.es.js line 6, where it tries to load the StateMachine it really looks like a bug to me.

import StateMachine from 'dfa'

And then in ./node_modules/dfa/index.js
The last line: module.exports = StateMachine is trying to export as commonJS and not as es-format.

Am I overseeing something here? Or is this actually a bug? I currently try to do some babel or webpack-config to solve this problem, but it seems like an issue to me.

Expected behavior
Make this instantly work, without the need to do additional webpack or babel config.

Desktop (please complete the following information):

  • React-pdf version [e.g. v1.1.0]
  • @react-pdf/fontkit version 1.13.0
@nodepond
Copy link
Author

After some deeper research I currently have the feeling, that this comes back to an issue with dfa 1.2.0 (that was published yesterday!). https://www.npmjs.com/package/dfa

When I install the version 1.1.0 I get a precompliled version, that is understood by fontkit. The index.js at the 1.2.0 seems to be not precompiled, causing issues at importing it property at fontkit.

@diegomura
Copy link
Owner

diegomura commented Jun 18, 2019

Thanks! We can clse it then since it’s not a react-pdf bug?

@nodepond
Copy link
Author

Hm, it actually has an impact on installing react-pdf currently (fails to install), if my suspicion is correct. But yeah, I should try to adress this at dfa.

@cristofer
Copy link

I solved it adding the resolutions section in package.json

"dfa": "1.1.0"

And of course the package with that version as well

@zhonggithub
Copy link

zhonggithub commented Sep 2, 2019

I get the error like this:
ERROR in 113e60489ac1aee4007d.bundle.js from UglifyJs
Unexpected token: name (StateMachine)

solved use dfa verison 1.1.0 in @react-pdf/fontkit

@americos
Copy link

I just had this same problem and the fix from @cristofer worked pretty well.

@jhilden
Copy link

jhilden commented Sep 24, 2019

It looks like there is a potential fix for the downstream issue here foliojs/dfa#4

@diegomura diegomura changed the title Issues when importing @react-pdf: "export 'default' (imported as 'StateMachine') was not found in 'dfa' Can't build with dfa 1.2.0 Apr 7, 2021
@diegomura diegomura added the bug label Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants