capacitor-community / react-hooks

⚡️ React hooks for Capacitor ⚡️
Other
249 stars 22 forks source link

Bug: Failed to parse source map from on Ionic 6 with react-scripts@5 #43

Open bipoza opened 2 years ago

bipoza commented 2 years ago

Describe the bug After upgrading to react-script@5 the following error appears in the console: Failed to parse source map from

The problem: The problem here is that Ionic React 6 uses react-scripts@5. This new version of react-scripts has sourcemap parsing enabled and will log a warning when no sourcemaps are found for a library. This did not happen in Ionic React 5 as that version required react-scripts@4 which did not have sourcemap parsing.

To Reproduce Steps to reproduce the behavior:

$ npm install -g @ionic/cli
$ ionic start myApp blank --type=react
$ cd myApp
$ npm install @capacitor/browser
$ npm install @capacitor-community/browser-react
$ ionic serve

Screenshots

capacitor-react-hooks-sourcemaps

Possible solution:

The same thing happened to me with a library we created to display images with pinch-to-zoom in Ionic React. https://github.com/codesyntax/ionic-react-photo-viewer

In my case I have used rollupjs as a module builder, and adding the sourcemaps in the configuration works perfectly. Example: https://github.com/codesyntax/ionic-react-photo-viewer/pull/14/files