pc-dart icon indicating copy to clipboard operation
pc-dart copied to clipboard

Support dart2wasm

Open leecommamichael opened this issue 1 year ago • 3 comments

To reproduce:

  • have the dart2wasm compiler
  • import this package into a main.dart with void main
  • run dart compile wasm main.dart Output:

../../../AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.4/lib/src/platform_check/node_crypto.dart:5:1: Error: JS interop library 'package:js/js.dart' can't be imported when compiling to Wasm. Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead. import 'package:js/js.dart'; ^ ../../../AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.4/lib/src/platform_check/web.dart:5:1: Error: JS interop library 'package:js/js.dart' can't be imported when compiling to Wasm. Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead. import 'package:js/js.dart'; ^

This library impacts the popular package:image. I've filed a matching report with them here.

leecommamichael avatar Jan 28 '24 20:01 leecommamichael

Definitely needed since the package is used in many known packages making them unusable with Wasm. Thank you

The-RootCause avatar Feb 17 '24 19:02 The-RootCause

I started porting my code to the web package to support wasm. It was quite hard to get into it, but finally got it. I might be able to help here.

I only saw 2 files where actual web code was written. Is that right? I could exchange the old package:js with package:web. That package:web is fully compatible with the dart2wasm compiler.

konsultaner avatar Feb 26 '24 19:02 konsultaner

Dart fixed the blocking issue. If someone would take a look at my PR, this issue could be closed 😇

konsultaner avatar Mar 13 '24 18:03 konsultaner

@leecommamichael this issue is fixed. You might want to close this issue.

konsultaner avatar Apr 04 '24 06:04 konsultaner

Close as the PR is merged and live on pub.dev.

Ephenodrom avatar Apr 05 '24 11:04 Ephenodrom

doesn't work, you are includeing teh js package.

dart:js_interop, which replaces package:js and dart:js

sgehrman avatar Oct 22 '24 20:10 sgehrman

Where is it used? Im using pc-dart in my package and it compiles to wasm.

konsultaner avatar Oct 26 '24 18:10 konsultaner