Closed exaby73 closed 11 months ago
Description
When using jaspr generate, platform imports do not work.
jaspr generate
Steps To Reproduce
Have a platform import in one of your files. This is a snippet of my code:
import 'dart:async'; import 'package:jaspr/html.dart'; @Import.onWeb('dart:html', show: [#PointerEvent]) // ignore: always_use_package_imports import 'events.imports.dart'; /// Type safe click handler EventCallback click(FutureOr<void> Function(PointerEvent event) callback) { return (event) async { if (event is! PointerEventOrStubbed) { print('event is not a PointerEventOrStubbed'); return; } event.preventDefault(); await callback(event); }; }
The above function can be used in a Component like so:
yield button( events: { 'click': click((/*PointerEvent*/ event) { doSomething(); }), }. [text('Foo')], );
Expected Behavior
jaspr generate should work
Error logs
$ jaspr generate ✓ [CLI] Completed building web assets. (7.4s) ✗ [SERVER] [ERROR] lib/app.dart:1:8: Error: Dart library 'dart:js_util' is not available on this platform. (1.2s) [SERVER] [ERROR] import 'dart:js_util'; [SERVER] [ERROR] ^ [SERVER] [ERROR] Context: The unavailable library 'dart:js_util' is imported through these packages: [SERVER] [ERROR] [SERVER] [ERROR] package:my_app => dart:js_util [SERVER] [ERROR] [SERVER] [ERROR] Detailed import paths for (some of) the these imports: [SERVER] [ERROR] [SERVER] [ERROR] package:my_app/main.dart => package:my_app/app.dart => dart:js_util ✗ [SERVER] (0ms)
Additional Information
Snippet of pubspec.yaml:
pubspec.yaml
dependencies: jaspr: ^0.9.0 jaspr_router: ^0.3.0 dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.5 jaspr_builder: ^0.9.0 jaspr_tailwind: ^0.1.0 lint: ^2.1.2 jaspr: uses-ssr: true
dart --version output:
dart --version
Dart SDK version: 3.1.1 (stable) (Tue Sep 5 12:20:14 2023 +0000) on "macos_arm64"
This seems to also be reproducible with jaspr build. If this is indeed an error on my end, this issue could also be considered a documentation issue.
jaspr build
Sorry, there was a rouge import :p I'll close the issue now
Description
When using
jaspr generate
, platform imports do not work.Steps To Reproduce
Have a platform import in one of your files. This is a snippet of my code:
The above function can be used in a Component like so:
Expected Behavior
jaspr generate
should workError logs
Additional Information
Snippet of
pubspec.yaml
:dart --version
output: