最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Why do I seemingly need to add @client on most Jaspr components (Dart)? - Stack Overflow

programmeradmin0浏览0评论

While I worked a lot with Flutter, I am relatively new to using Jaspr to build Dart based web projects.

So, I started by analyzing and modifying the counter web project that is shipped with Jaspr (mixed server-side / client-side rendering). Building is actually quite a lot of fun.

But, there are countless components where I do not see the client really having to do anything. There is not State, there is no visible client-side code. So, I deleted some of the @client annotations that according to the documentation should only be needed if there was some client-side rendering / hydration.

I get error messages like this when Jaspr is building:

[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.ddc.dill
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.dart
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.dart
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.ddc.dill
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.bootstrap.ddc.js.metadata
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.bootstrap.ddc.js.metadata
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.dart

The errors disappear when I put the @client annotations back. But it bugs me that I do not understand why they are occurring.

One example for such a page where @client seems to be necessary.

import 'package:jaspr/jaspr.dart';

@client
class EmptyPage extends StatelessComponent {
  const EmptyPage({super.key});

  @override
  Iterable<Component> build(BuildContext context) sync* {
    final page = context.binding.currentUri.pathSegments.last;
    yield h1([text('Empty: $page')]);
  }
}

Any useful advice?

  • Read documentation
  • googled for more information
  • experimented

Had to put @client back but I'm not happy with it. :-)

I could imagine the context object to be only available on the client side, but then how do I extract the route on the server side?

While I worked a lot with Flutter, I am relatively new to using Jaspr to build Dart based web projects.

So, I started by analyzing and modifying the counter web project that is shipped with Jaspr (mixed server-side / client-side rendering). Building is actually quite a lot of fun.

But, there are countless components where I do not see the client really having to do anything. There is not State, there is no visible client-side code. So, I deleted some of the @client annotations that according to the documentation should only be needed if there was some client-side rendering / hydration.

I get error messages like this when Jaspr is building:

[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.ddc.dill
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.dart
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.dart
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.ddc.dill
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.bootstrap.ddc.js.metadata
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/about_page/about_page.client.bootstrap.ddc.js.metadata
[BUILDER] [ERROR] AssetNotFoundException: xxx|web/pages/empty_page/empty_page.client.dart

The errors disappear when I put the @client annotations back. But it bugs me that I do not understand why they are occurring.

One example for such a page where @client seems to be necessary.

import 'package:jaspr/jaspr.dart';

@client
class EmptyPage extends StatelessComponent {
  const EmptyPage({super.key});

  @override
  Iterable<Component> build(BuildContext context) sync* {
    final page = context.binding.currentUri.pathSegments.last;
    yield h1([text('Empty: $page')]);
  }
}

Any useful advice?

  • Read documentation
  • googled for more information
  • experimented

Had to put @client back but I'm not happy with it. :-)

I could imagine the context object to be only available on the client side, but then how do I extract the route on the server side?

Share Improve this question edited Mar 10 at 15:10 its-me-mahmud 7091 gold badge7 silver badges15 bronze badges asked Feb 20 at 23:51 cdemy Leitungcdemy Leitung 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 2

Kilian responded to this on Jaspr's Discord. Also, I think this issue was encountered during the live demo with Craig on observable flutter and doing jaspr clean solved it.

Kilian's response: Thats not a user error, but a weird build_runner issue with removing @client components and hotreloading. Doing jaspr clean and restarting jaspr serve should make the error go away.

发布评论

评论列表(0)

  1. 暂无评论