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

Not working with create-react-app #40

Open
tume opened this issue Mar 29, 2018 · 8 comments
Open

Not working with create-react-app #40

tume opened this issue Mar 29, 2018 · 8 comments
Assignees
Labels

Comments

@tume
Copy link

tume commented Mar 29, 2018

Getting this when trying to create production build:

Failed to minify the code from this file: 
	./node_modules/react-with-async-fonts/dist/font-subscriber.js:3 

Also tried importing from /lib/ directory but then getting:
Uncaught TypeError: hoist_non_react_statics_1.default is not a function

@sbekrin sbekrin added the bug label Mar 29, 2018
@sbekrin sbekrin self-assigned this Mar 29, 2018
@sbekrin
Copy link
Owner

sbekrin commented Mar 29, 2018

Hey @tume, thanks for bringing this up! 👋

I assume these are two separate problems:

  1. CRA doesn't transpile harmony modules syntax, I'll check how other libraries handles that
  2. lib/ version has corrupt reference to hoist-non-react-statics. This is most likely due to allowSyntheticDefaultImports set to true in tsconfig, not sure why this happens but it's definitely a major issue.

I'll take a look on weekend.

@Kronuz
Copy link

Kronuz commented May 7, 2018

Did you figure anything about TypeError: hoist_non_react_statics_1.default is not a function ?

I tried removing allowSyntheticDefaultImports and setting it to false, but that didn't fix it...

@sbekrin
Copy link
Owner

sbekrin commented Jun 21, 2018

Hey @Kronuz @tume, I'm sorry folks I had no time for this project for a bit of time. I've released v4.0.2 with deps updates, can you please check if issue persist with latest version?

@Kronuz
Copy link

Kronuz commented Jun 22, 2018

The real problem came from here:

https://github.com/sergeybekrin/react-with-async-fonts/blob/8314de50d9726dd8f5726f48c98d5438e2045922/src/with-fonts.tsx#L3

Because hoist-non-react-statics didn't export a default symbol, in older versions it should have been:

import * as hoistStatics from 'hoist-non-react-statics'; 

In hoist-non-react-statics v2.5.5 this default export was fixed, and since that's what react-with-async-fonts v4.0.2 uses, it how should now be working by just upgrading to v4.0.2.

@sbekrin
Copy link
Owner

sbekrin commented Jun 22, 2018

@Kronuz ah I see, thanks for digging into that! I'll consider this fixed, but feel free to re-open this issue if it doesn't work for you. Cheers 👍

@sbekrin sbekrin closed this as completed Jun 22, 2018
@ejoo
Copy link

ejoo commented Feb 10, 2019

I'm getting same issue with Typescript 3.2.2

image

@sbekrin
Copy link
Owner

sbekrin commented Feb 12, 2019

Hey @ejoo, thanks for reporting this one! Would you mind sharing your TS config to help me quickly reproduce that issue?

@sbekrin sbekrin reopened this Feb 12, 2019
@ejoo
Copy link

ejoo commented Feb 14, 2019

@sbekrin I made a quick fix with following code:

import * as hoistStatics from "hoist-non-react-statics";
// quick fix for: https://github.com/sbekrin/react-with-async-fonts/issues/40
const hoistStaticsAny: any = hoistStatics;

Following is my tsconfig

{
  "compilerOptions": {
    "sourceMap": true,
    "target": "es6",
    "jsx": "react",
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "lib": ["es2015", "es2017", "dom"],
    "removeComments": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "baseUrl": "./",
    "paths": {
      "components/*": ["src/components/*"],
      "containers/*": ["src/containers/*"],
      "models": ["src/models/index.ts"],
      "utils/*": ["src/utils/*"],
      "helpers/*": ["src/helpers"],
    },
    "typeRoots": ["./node_modules/@types"],
    "types": ["node", "webpack-env", "jest"]
  },
  "typeRoots": ["./node_modules/@types"],
  "types": ["node", "webpack-env", "jest"],
  "noEmit": true,

  "exclude": ["node_modules", "dist"]
}


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

No branches or pull requests

4 participants