Cretezy / redux_persist

Persist Redux State
https://pub.dartlang.org/packages/redux_persist
MIT License
130 stars 41 forks source link

dart2js - Error: Only external js-interop functions are supported. #46

Closed konradkevin closed 5 years ago

konradkevin commented 5 years ago

dart: 2.3.0 redux_persist: ^0.8.2 redux_persist_web: ^0.8.2

I got this error when trying to compile for web using webdev build though it compiles successfuly when building with the --no-release option webdev build --no-release.

Here is the build.yaml file:

targets:
  $default:
    builders:
      build_web_compilers|entrypoint:
        options:
          dart2js_args:
            - --fast-startup
            - --minify
            - --trust-primitives
            - --omit-implicit-checks

Here is the complete error:

Creating build script, took 7450ms
[INFO] Reading cached asset graph completed, took 631ms
[INFO] Checking for updates since last build completed, took 638ms
[INFO] build_web_compilers:entrypoint on web/sw.dart:Running dart2js with --fast-startup --minify --trust-primitives --omit-implicit-check
s --suppress-hints --packages=.package-326ed239476c73afdc40eec93f45bc34 -oweb/sw.dart.js web/sw.dart
[INFO] build_web_compilers:entrypoint on web/main.dart:Running dart2js with --fast-startup --minify --trust-primitives --omit-implicit-che
cks --suppress-hints --packages=.package-51411c1b51d7dfe42ea8c5334cd016fa -oweb/main.dart.js web/main.dart
[INFO] build_web_compilers:entrypoint on web/sw.dart:Dart2Js finished with:

Compiled 7,662,883 characters Dart to 126,979 characters JavaScript in 3.83 seconds
Dart file (web\sw.dart) compiled to JavaScript: web/sw.dart.js

[SEVERE] build_web_compilers:entrypoint on web/main.dart:
Dart2Js finished with:

packages/redux_persist/src/serialization.dart:6:22:
Error: Only external js-interop functions are supported.
Try removing 'external' keyword or annotating the function as a js-interop function.
  external Uint8List encode(T state);
                     ^
packages/redux_persist/src/serialization.dart:8:14:
Error: Only external js-interop functions are supported.
Try removing 'external' keyword or annotating the function as a js-interop function.
  external T decode(Uint8List data);
             ^
packages/redux_persist/src/storage.dart:8:25:
Error: Only external js-interop functions are supported.
Try removing 'external' keyword or annotating the function as a js-interop function.
  external Future<void> save(Uint8List data);
                        ^
packages/redux_persist/src/storage.dart:11:30:
Error: Only external js-interop functions are supported.
Try removing 'external' keyword or annotating the function as a js-interop function.
  external Future<Uint8List> load();
                             ^
Error: Compilation failed.

[INFO] Running build completed, took 8.9s
[INFO] Caching finalized dependency graph completed, took 355ms
[SEVERE] Failed after 9.2s

I hope you could give me a hand with that!

Cretezy commented 5 years ago

Could you give me a full ZIP example?

konradkevin commented 5 years ago

Surely, here it is project.zip

Cretezy commented 5 years ago

Hey it seems like you didn't upload anything by accident!

Cretezy commented 5 years ago

Going to close due to inactivity.

LiewJunTung commented 5 years ago

Hello @Cretezy, I have encountered this issue as well while I was developing a web app with Flutter Web. The fix is to remove the external keyword on lines shown in the error above.

jlcool commented 4 years ago

I have the same question

konradkevin commented 4 years ago

As @LiewJunTung said, you must manually remove all the 'external' keyword from the 2 files listed in the error message

packages/redux_persist/src/serialization.dart:6:22 packages/redux_persist/src/serialization.dart:8:14

packages/redux_persist/src/storage.dart:8:25 packages/redux_persist/src/storage.dart:11:30

This is just a temporary solution but hope this helps

jlcool commented 4 years ago

thank you