[documentation] documentation on how to compile dart to js for a non-web target with webdev build
Los mantenedores suelen responder en 3 días
@bkonyi ya está trabajando en esto.
Desde el 31/7/2024.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- Dart
- Estrellas
- 224
- Forks
- 95
- Merge medio
- 3 d 17 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dart-lang/webdev
-
[dwds] WebkitDebugger.enable 5-second hardcoded timeout causes TimeoutException on large web appsPosiblemente ocupada @Markzipan la tomó hace 1 día. AbiertoP1 package:dwds triaged type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
dart-lang/webdev#2883 · 5 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
PUBLISH 4.1.0 w/ the deprecated js interop fix!Posiblemente ocupada @kevmoo la tomó hace 1 día. Abiertopackage:webdev
dart-lang/webdev#2884 · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
P2 triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 3 días
-
P3 triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
dart-lang/webdev#2865 · 6 comentarios ·
Los mantenedores suelen responder en 3 días
-
P2 package:dwds triaged type-bug
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
dart-lang/webdev#2852 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
Todos los issues de dart-lang/webdev
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
mollykitten/waveform#112 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Suwayomi/Suwayomi-Tsumiru#698 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
google/protobuf.dart#1107 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100