[documentation] documentation on how to compile dart to js for a non-web target with webdev build
@bkonyi がすでに取り組んでいます。
2024年7月31日 から。
評価
この issue はまだ評価されていません。
説明
I want to compile dart to js for a non-web target (eg. fermyon/js, node)
I'm told it's possible with 2 possible approaches:
- webdev build --no-release suggested here
- dart compile js --server-mode suggested here with a 3rd party node_preamble
it would be nice to have some documentation on how to achieve this the 1. approach.
I admit that this is a skill issue rather than a dart issue
but maybe I'm not the only developer facing this and a minimal example would be great
here is a reproducible setup/example using node (repo)
node example
- set up node dependencies
npm init -y && \
npm install express && \
npm install --save-dev typescript @types/node @types/express ts-node-dev
- create the file
tsconfig.jsonwith the code below
{
"compilerOptions": {
"allowJs": true,
"target": "ES6",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src"]
}
- create the file `src/greeting.js with the following code
export function greeting() {
return "Hello from JS"
}
- create the file
src/index.tswith the code below
import express, { Request, Response } from 'express';
import { greeting } from './greeting.js';
const app = express();
const port = 3000;
app.get('/', (req: Request, res: Response) => {
res.send(greeting());
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
how can I create an equivalent
String greeting() => 'Hello from Dart';
import it and use it in index.ts?
notes
- packages from node_interop's family seem to me that are "replacing" node rather than actually "interop"
- stack overflow question
cc
@maks & @sigmundch from https://github.com/dart-lang/sdk/issues/53884
@nex3 I've been told on Twitter that you have experience with this use case from sass
- 主要言語
- Dart
- スター
- 224
- フォーク
- 95
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dart-lang/webdev のほかの issue
-
[dwds] WebkitDebugger.enable 5-second hardcoded timeout causes TimeoutException on large web apps対応中かも @Markzipan が 1 日前に担当しました。 オープンP1 package:dwds triaged type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
P2 triaged
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
P3 triaged
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
P2 package:dwds triaged type-bug
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
-
P2 package:dwds triaged type-bug
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
dart-lang/webdev の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aaronified/fluenough#918 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 4 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 3 日以内に返信
-
[UX][Mobile] show feedback and privacy notice button in overflow menu対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea-clientside-dartpad
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 2 日以内に返信