Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make web examples runnable with latest dart #748

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ Web and command-line examples can be found in the `example` folder.

In order to run the web examples, please follow these steps:

1. Clone this repo and enter the directory
2. Run `dart pub get`
3. Run `dart run build_runner serve example`
4. Navigate to [http://localhost:8080/web/index.html](http://localhost:8080/web/index.html) in your browser
1. Run `dart pub global activate webdev`
2. Clone this repo and enter the directory
3. Run `dart pub get`
4. Run `webdev serve example`
5. Navigate to [http://localhost:8080/web/index.html](http://localhost:8080/web/index.html) in your browser

### Command Line Examples

Expand Down
1 change: 1 addition & 0 deletions lib/src/utils/empty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class _Empty {

/// @internal
/// Sentinel object used to represent a missing value (distinct from `null`).
// ignore: unnecessary_nullable_for_final_variable_declarations
const Object? EMPTY = _Empty(); // ignore: constant_identifier_names

/// @internal
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ environment:

dev_dependencies:
build_runner: ^2.1.2
build_web_compilers: ^3.0.0
lints: ^1.0.1
build_web_compilers: ^4.0.9
lints: ^2.0.0
Comment on lines +20 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the old version of 2 deps, because we support dart >= 2.12

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. i'll see if i can rework this so the example can be run on 2.12 as well as latest.

Copy link
Author

@dlchet dlchet Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i'm not sure how to make the examples work with past and current versions at the same time. i'm on dart 3.3.1 and i run into issues both with the old style of building

% dart run build_runner serve example
[SEVERE] build_web_compilers:sdk_js on asset:build_web_compilers/$package$ (cached):
Error compiling dartdevc module:build_web_compilers|lib/src/dev_compiler/dart_sdk.sound.js
Unhandled exception:
PathNotFoundException: Cannot open file, path = '/opt/homebrew/Caskroom/flutter/3.3.3/flutter/bin/cache/dart-sdk/lib/_internal/ddc_platform_sound.dill' (OS Error: No such file or directory, errno = 2)

and the new style

% webdev serve example               
[SEVERE] Pubspec errors: [The `build_web_compilers` version – 3.2.7 – is not within the allowed constraint – ^4.0.4.
null]
webdev could not run for this project.
The `build_web_compilers` version – 3.2.7 – is not within the allowed constraint – ^4.0.4.

and the new style using old webdev

Activated webdev 2.7.12.
dlchet@Consolation-System rxdart % webdev serve example                  
webdev could not run for this project.
This version of webdev does not support the `build_daemon` protocol used by your version of `build_runner`.
A newer version of webdev is available which supports your version of the `build_daemon`. Please update.

So I'm a bit perplexed on what if anything should be changed. It seems to me that this problem would surface when using a recent Dart even in a separate project, so maybe I will try to make a minimal reproduction in a separate project, and then submit as an issue? @hoc081098 thank you for your attention, let me know if you see anything I'm missing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlchet I think we can use a separate pubspec.yaml for web example (similar to flutter/github_search).
Could you try this approach?

stack_trace: ^1.10.0
test: ^1.17.12
1 change: 1 addition & 0 deletions test/subject/behavior_subject_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ void main() {
final a = BehaviorSubject.seeded('a');
final b = BehaviorSubject.seeded('b');
final bug =
// ignore: no_leading_underscores_for_local_identifiers
Rx.combineLatest2(a, b, (String _a, String _b) => 'ab').shareValue();
expect(await bug.first, 'ab');
expect(await bug.first, 'ab');
Expand Down