sweetalert2 / sweetalert2-react-content

Official SweetAlert2 enhancer adding support for React elements as content
MIT License
702 stars 48 forks source link

With RollupJS: "Uncaught TypeError: MySwal.fire is not a function" #79

Closed blacksmoke26 closed 5 years ago

blacksmoke26 commented 5 years ago

Followed homepage example but leads to an error!

zenflow commented 5 years ago

Seems to be working fine here: https://codesandbox.io/s/826xvvxrv2

Do you happen to be working with TypeScript? Is this a duplicate of #33?

Can you reproduce the error on https://codesandbox.io or https://codepen.io/ or https://jsfiddle.net/ or something like that?

blacksmoke26 commented 5 years ago

Well I am using RollupJS.

ReactJs + Flow

zenflow commented 5 years ago

Can you share your project? If not, can you please reproduce the problem on one of the above websites, or a GitHub repo?

blacksmoke26 commented 5 years ago

I will try to reproduce, maybe CodeSandBox will be useful to share code. Thanks!

zenflow commented 5 years ago

@blacksmoke26 any update on this?

blacksmoke26 commented 5 years ago

@zenflow Moved to Webpack, dropped RollupJS due to so many issues.

Thanks! You can close it now!

zenflow commented 5 years ago

Strange that the problem went away when you dropped Rollup..

I'm thinking this could still be a valid issue (when using Rollup, but not when using Webpack or Parcel), but we have no reproduction.. @limonte what would you do here?

limonte commented 5 years ago

It might be a valid issue, but I'd still wait for some effort from the community with the reproduction. We can keep the issue opened so people will find it easier when they will stumble upon the same problem.

blacksmoke26 commented 5 years ago

This walkthrough involves the following libs:

Finally reproduced:

index.js:7 Uncaught TypeError: MySwal.fire is not a function
    at index.js:7
    at index.js:7

Note: I assume that you have installed gulp globally.

Steps to reproduce:

You can skip above and download the following zip file (contains compiled version) to test: build-files.zip

P.S. Please let me know if you need more details.

zenflow commented 5 years ago

Thank you very much for your contribution @blacksmoke26 .. I will review this and track down the problem first chance I get

zenflow commented 5 years ago

Ok, well it's not a bug in sweetalert2-react-content, because if you take the reproduction and replace the contents of src/index.js with this:

class SomeClass {
    static someStaticMethod () {
        alert('ok')
    }
}
class SomeSubClass extends SomeClass {}
SomeSubClass.someStaticMethod('ok');

... we get a very similar error: Uncaught TypeError: SomeSubClass.someStaticMethod is not a function.

It's a bug in rollup, but it was fixed a long time ago.

The reason it was coming up here is because the rollup-stream package used here has a hard dependency on rollup@^0.49.2.

Don't use that package.