Skip to content

Add TodoMVC for dart2js & dart2wasm #502

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions experimental/dart-jaspr-todomvc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dart_tool/
build/
22 changes: 22 additions & 0 deletions experimental/dart-jaspr-todomvc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# todomvc

A Jaspr implementation of todomvc, written in Dart and compilable to either JavaScript or WebAssembly.

## Setup

Install [dart](https://dart.dev/get-dart).

## Running the project

Run your project using `dart run jaspr_cli:jaspr serve`.

The development server will be available on `http://localhost:8080`.

## Building the project

Build your project using either:

- Generate JavaScript via: `jaspr build -O4 --extra-js-compiler-option=--no-minify`
- Generate WebAssembly via: `jaspr build -O4 --experimental-wasm --extra-wasm-compiler-option=--no-strip-wasm`

The output will be located inside the `build/jaspr/` directory.
9 changes: 9 additions & 0 deletions experimental/dart-jaspr-todomvc/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: package:lints/recommended.yaml

analyzer:
# Jaspr has a custom lint package 'jaspr_lints', which needs the 'custom_lint' analyzer plugin.
#
# Unfortunately, running 'dart analyze' does not pick up the custom lints. Instead, you need to
# run a separate command for this: `jaspr analyze`
plugins:
- custom_lint
47 changes: 47 additions & 0 deletions experimental/dart-jaspr-todomvc/build.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
+ set -e
+ echo 'Current Dart SDK version'
Current Dart SDK version
+ dart --version
Dart SDK version: 3.9.0-edge.eb41d43c0dba5021ba37b11e54e0fe09f7b192b5 (main) (Tue May 6 04:09:12 2025 -0700) on "macos_arm64"
+ echo 'Fetching dependencies'
Fetching dependencies
+ dart pub get
Resolving dependencies...
Downloading packages...
_fe_analyzer_shared 80.0.0 (82.0.0 available)
analyzer 7.3.0 (7.4.4 available)
analyzer_plugin 0.12.0 (0.13.0 available)
custom_lint 0.7.3 (0.7.5 available)
custom_lint_builder 0.7.3 (0.7.5 available)
custom_lint_core 0.7.1 (0.7.5 available)
dds 4.2.7 (5.0.0 available)
devtools_shared 10.0.2 (11.2.0 available)
dwds 24.3.5 (24.3.10 available)
freezed_annotation 2.4.4 (3.0.0 available)
http 1.3.0 (1.4.0 available)
json_rpc_2 3.0.3 (4.0.0 available)
mime 1.0.6 (2.0.0 available)
shelf_web_socket 2.0.1 (3.0.0 available)
vm_service 14.3.1 (15.0.0 available)
web 1.1.0 (1.1.1 available)
Got dependencies!
16 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
+ echo 'Building dart2js version in -O4'
Building dart2js version in -O4
+ rm -rf build dist/out-dart2js-O4
+ dart run jaspr_cli:jaspr build -O4 --extra-js-compiler-option=--disable-program-split
Building jaspr for client rendering mode.
⠋ Building web assets......⠙ Building web assets...... (0ms)✓ Completed building web assets. (10.7s)
Completed building project to /build/jaspr.
+ mkdir -p dist/out-dart2js-O4
+ cp build/jaspr/index.html build/jaspr/base.css build/jaspr/index.css build/jaspr/favicon.ico build/jaspr/main.dart.js dist/out-dart2js-O4
+ echo 'Building dart2js version in -O4'
Building dart2js version in -O4
+ rm -rf build dist/out-dart2wasm-O2
+ dart run jaspr_cli:jaspr build -O2 --experimental-wasm
Building jaspr for client rendering mode.
⠋ Building web assets......⠙ Building web assets...... (0ms)✓ Completed building web assets. (11.3s)
Completed building project to /build/jaspr.
+ mkdir -p dist/out-dart2wasm-O2
+ cp build/jaspr/index.html build/jaspr/base.css build/jaspr/index.css build/jaspr/favicon.ico build/jaspr/main.dart.js build/jaspr/main.mjs build/jaspr/main.wasm dist/out-dart2wasm-O2
Expand Down
29 changes: 29 additions & 0 deletions experimental/dart-jaspr-todomvc/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

JS_OUT=dist/out-dart2js-O4
WASM_OUT=dist/out-dart2wasm-O2

set -x
set -e

echo "Current Dart SDK version"
dart --version

echo "Fetching dependencies"
dart pub get

# NOTE: For profiling add the following argument to get symbols
# --extra-js-compiler-option=--no-minify
echo "Building dart2js version in -O4"
rm -rf build $JS_OUT
dart run jaspr_cli:jaspr build -O4 --extra-js-compiler-option=--disable-program-split
mkdir -p $JS_OUT
cp build/jaspr/{index.html,base.css,index.css,favicon.ico,main.dart.js} $JS_OUT

# NOTE: For profiling add the following argument to get symbols
# --extra-wasm-compiler-option=--no-strip-wasm
echo "Building dart2js version in -O4"
rm -rf build $WASM_OUT
dart run jaspr_cli:jaspr build -O2 --experimental-wasm
mkdir -p $WASM_OUT
cp build/jaspr/{index.html,base.css,index.css,favicon.ico,main.dart.js,main.mjs,main.wasm} $WASM_OUT
141 changes: 141 additions & 0 deletions experimental/dart-jaspr-todomvc/dist/out-dart2js-O4/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
hr {
margin: 20px 0;
border: 0;
border-top: 1px dashed #c5c5c5;
border-bottom: 1px dashed #f7f7f7;
}

.learn a {
font-weight: normal;
text-decoration: none;
color: #b83f45;
}

.learn a:hover {
text-decoration: underline;
color: #787e7e;
}

.learn h3,
.learn h4,
.learn h5 {
margin: 10px 0;
font-weight: 500;
line-height: 1.2;
color: #000;
}

.learn h3 {
font-size: 24px;
}

.learn h4 {
font-size: 18px;
}

.learn h5 {
margin-bottom: 0;
font-size: 14px;
}

.learn ul {
padding: 0;
margin: 0 0 30px 25px;
}

.learn li {
line-height: 20px;
}

.learn p {
font-size: 15px;
font-weight: 300;
line-height: 1.3;
margin-top: 0;
margin-bottom: 0;
}

#issue-count {
display: none;
}

.quote {
border: none;
margin: 20px 0 60px 0;
}

.quote p {
font-style: italic;
}

.quote p:before {
content: "“";
font-size: 50px;
opacity: 0.15;
position: absolute;
top: -20px;
left: 3px;
}

.quote p:after {
content: "”";
font-size: 50px;
opacity: 0.15;
position: absolute;
bottom: -42px;
right: 3px;
}

.quote footer {
position: absolute;
bottom: -40px;
right: 0;
}

.quote footer img {
border-radius: 3px;
}

.quote footer a {
margin-left: 5px;
vertical-align: middle;
}

.speech-bubble {
position: relative;
padding: 10px;
background: rgba(0, 0, 0, 0.04);
border-radius: 5px;
}

.speech-bubble:after {
content: "";
position: absolute;
top: 100%;
right: 30px;
border: 13px solid transparent;
border-top-color: rgba(0, 0, 0, 0.04);
}

.learn-bar > .learn {
position: absolute;
width: 272px;
top: 8px;
left: -300px;
padding: 10px;
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.6);
transition-property: left;
transition-duration: 500ms;
}

@media (min-width: 899px) {
.learn-bar {
width: auto;
padding-left: 300px;
}

.learn-bar > .learn {
left: 8px;
}
}
Binary file not shown.
Loading