Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[documentation] documentation on how to compile dart to js for a non-web target with webdev build

オープン
#2,432 コメント 3 件 リアクション 3 件 担当者 1 名 GitHub で見る

@bkonyi がすでに取り組んでいます。

2024年7月31日 から。

評価

この issue はまだ評価されていません。

説明

P3 package:webdev triaged type-documentation

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:

  1. webdev build --no-release suggested here
  2. 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.json with 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.ts with 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

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dart-lang/webdev のほかの issue

dart-lang/webdev の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。