@xnoxs/flux-lang 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +459 -1
- package/dist/flux-cli.js +234 -112
- package/dist/flux.cjs.js +1 -1
- package/dist/flux.esm.js +1 -1
- package/dist/flux.min.js +1 -1
- package/package.json +1 -1
- package/src/self/cli.flux +169 -50
- package/src/self/cli.js +1 -818
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [3.4.2] — 2026-06-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **`## Flux Ecosystem`** — tabel + diagram ASCII lengkap semua 18 modul, perintah yang terkait, dan fungsinya
|
|
14
|
+
- **`## flux.json — Konfigurasi Proyek`** — dokumentasi lengkap setiap field (name, version, entry, outDir, sourcemap, typecheck, mangle, jsx, jsxTarget, ignore, scripts, dependencies, devDependencies), tabel referensi, prioritas konfigurasi, dan penggunaan `flux.local.json`
|
|
15
|
+
- **`## Dari Nol ke Production`** — panduan 10-langkah lengkap: instalasi → init → run → tulis kode → type check & lint → test → bundle → deploy (Node.js / Vercel / Railway / Render / Cloudflare Workers) → manajemen dependensi → ringkasan alur kerja
|
|
16
|
+
- README versi bumped ke v3.4.1
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- `package.json` version bumped ke `3.4.2`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
10
23
|
## [3.4.0] — 2026-06-25
|
|
11
24
|
|
|
12
25
|
### Added
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ⚡ Flux Lang v3.4.
|
|
1
|
+
# ⚡ Flux Lang v3.4.1
|
|
2
2
|
|
|
3
3
|
**Flux** is a modern programming language that transpiles to clean JavaScript — combining Python-style indentation, TypeScript-grade type safety, Rust-inspired pattern matching, and a rich standard library — all with **zero runtime overhead**.
|
|
4
4
|
|
|
@@ -91,6 +91,464 @@ console.log(result.output);
|
|
|
91
91
|
|
|
92
92
|
---
|
|
93
93
|
|
|
94
|
+
## Flux Ecosystem
|
|
95
|
+
|
|
96
|
+
Flux bukan hanya sebuah bahasa — ia hadir dengan ekosistem lengkap yang semuanya ditulis dalam Flux sendiri.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
100
|
+
│ FLUX ECOSYSTEM v3.4 │
|
|
101
|
+
├─────────────────────────┬───────────────────────────────────────────┤
|
|
102
|
+
│ Compiler Pipeline │ Toolchain │
|
|
103
|
+
│ ───────────────── │ ───────────────── │
|
|
104
|
+
│ css-preprocessor.flux │ formatter.flux → flux fmt │
|
|
105
|
+
│ jsx.flux │ linter.flux → flux lint │
|
|
106
|
+
│ lexer.flux │ bundler.flux → flux bundle │
|
|
107
|
+
│ parser.flux │ test-runner.flux→ flux test │
|
|
108
|
+
│ checker.flux │ sourcemap.flux → .js.map generation │
|
|
109
|
+
│ type-checker.flux │ mangler.flux → minification │
|
|
110
|
+
│ codegen.flux │ stdlib.flux → standard library │
|
|
111
|
+
│ transpiler.flux │ │
|
|
112
|
+
├─────────────────────────┴───────────────────────────────────────────┤
|
|
113
|
+
│ Ecosystem Tools (baru di v3.4) │
|
|
114
|
+
│ ───────────────────────────── │
|
|
115
|
+
│ config.flux → membaca flux.json, validasi skema proyek │
|
|
116
|
+
│ pkg.flux → package manager (flux add / install / publish) │
|
|
117
|
+
│ cli.flux → seluruh CLI flux ditulis dalam Flux itu sendiri │
|
|
118
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Deskripsi Setiap Komponen
|
|
122
|
+
|
|
123
|
+
| Modul | Perintah | Fungsi |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `lexer.flux` | — | Mengubah source code menjadi token (angka, kata kunci, operator, dll.) |
|
|
126
|
+
| `parser.flux` | — | Mengubah token menjadi AST (Abstract Syntax Tree) |
|
|
127
|
+
| `checker.flux` | `flux check` | Analisis semantik: scope, variabel tak terdeklarasi, penggunaan salah |
|
|
128
|
+
| `type-checker.flux` | `flux check` | Inferensi & pengecekan tipe secara statis |
|
|
129
|
+
| `codegen.flux` | — | Mengubah AST menjadi kode JavaScript |
|
|
130
|
+
| `transpiler.flux` | — | Koordinator pipeline penuh: lexer → parser → checker → codegen |
|
|
131
|
+
| `jsx.flux` | — | Transform JSX ke `h(...)` calls (target: browser / server / react) |
|
|
132
|
+
| `css-preprocessor.flux` | — | Substitusi variabel CSS, nesting, di-embed dalam Flux |
|
|
133
|
+
| `formatter.flux` | `flux fmt` | Memformat kode Flux ke gaya kanonik |
|
|
134
|
+
| `linter.flux` | `flux lint` | Deteksi: variabel tak dipakai, shadowing, kode tak terjangkau |
|
|
135
|
+
| `bundler.flux` | `flux bundle` | Menyatukan semua `import` menjadi satu file `.js` |
|
|
136
|
+
| `sourcemap.flux` | `--sourcemap` | Membuat file `.js.map` (spec V3) untuk debugging di browser |
|
|
137
|
+
| `mangler.flux` | `--mangle` | Obfuskasi nama identifier untuk output yang lebih kecil |
|
|
138
|
+
| `stdlib.flux` | otomatis | 80+ fungsi standar — hanya yang dipakai yang di-inject (tree-shaking) |
|
|
139
|
+
| `test-runner.flux` | `flux test` | Menemukan dan menjalankan semua `*.test.flux` |
|
|
140
|
+
| `config.flux` | otomatis | Membaca dan memvalidasi `flux.json` dari direktori proyek |
|
|
141
|
+
| `pkg.flux` | `flux add/install` | Package manager Flux — mengelola dependensi di `flux.json` |
|
|
142
|
+
| `cli.flux` | `flux` | Seluruh antarmuka command-line, ditulis dalam Flux |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## `flux.json` — Konfigurasi Proyek
|
|
147
|
+
|
|
148
|
+
`flux.json` adalah file konfigurasi di root proyek Flux. File ini dibaca secara otomatis oleh semua perintah `flux`. Buat dengan `flux init` atau buat manual.
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"name": "nama-proyek",
|
|
153
|
+
"version": "1.0.0",
|
|
154
|
+
"description": "Deskripsi proyek",
|
|
155
|
+
"author": "Nama Kamu",
|
|
156
|
+
"license": "MIT",
|
|
157
|
+
|
|
158
|
+
"entry": "src/main.flux",
|
|
159
|
+
"outDir": "dist",
|
|
160
|
+
|
|
161
|
+
"sourcemap": false,
|
|
162
|
+
"typecheck": true,
|
|
163
|
+
"mangle": false,
|
|
164
|
+
"jsx": false,
|
|
165
|
+
"jsxTarget": "browser",
|
|
166
|
+
|
|
167
|
+
"ignore": ["tests/fixtures/**", "vendor/**"],
|
|
168
|
+
|
|
169
|
+
"scripts": {
|
|
170
|
+
"start": "flux run src/main.flux",
|
|
171
|
+
"build": "flux bundle src/main.flux -o dist/bundle.js",
|
|
172
|
+
"dev": "flux watch src/main.flux",
|
|
173
|
+
"check": "flux check src/main.flux",
|
|
174
|
+
"test": "flux test tests/",
|
|
175
|
+
"fmt": "flux fmt src/",
|
|
176
|
+
"lint": "flux lint src/"
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
"dependencies": {
|
|
180
|
+
"express": "^4.18.0"
|
|
181
|
+
},
|
|
182
|
+
"devDependencies": {
|
|
183
|
+
"@xnoxs/flux-lang": "^3.4.1"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Referensi Lengkap Setiap Field
|
|
189
|
+
|
|
190
|
+
| Field | Tipe | Default | Keterangan |
|
|
191
|
+
|---|---|---|---|
|
|
192
|
+
| `name` | `string` | wajib | Nama paket/proyek |
|
|
193
|
+
| `version` | `string` | `"1.0.0"` | Versi semver |
|
|
194
|
+
| `description` | `string` | `""` | Deskripsi singkat |
|
|
195
|
+
| `author` | `string` | `""` | Nama penulis |
|
|
196
|
+
| `license` | `string` | `"MIT"` | Jenis lisensi |
|
|
197
|
+
| `entry` | `string` | `"src/main.flux"` | Entry point default untuk `flux bundle` |
|
|
198
|
+
| `outDir` | `string` | `"dist"` | Direktori output kompilasi |
|
|
199
|
+
| `sourcemap` | `boolean` | `false` | Generate file `.js.map` (untuk debugging di browser DevTools) |
|
|
200
|
+
| `typecheck` | `boolean` | `true` | Jalankan type checker saat kompilasi |
|
|
201
|
+
| `mangle` | `boolean` | `false` | Obfuskasi nama identifier — membuat output lebih kecil |
|
|
202
|
+
| `jsx` | `boolean` | `false` | Aktifkan mode JSX untuk file `.flux` yang berisi JSX |
|
|
203
|
+
| `jsxTarget` | `"browser"\|"server"\|"react"` | `"browser"` | Target JSX transform |
|
|
204
|
+
| `ignore` | `string[]` | `[]` | Pola glob yang diabaikan oleh `flux test` |
|
|
205
|
+
| `scripts` | `object` | `{}` | Perintah yang bisa dijalankan dengan `flux run <nama>` |
|
|
206
|
+
| `dependencies` | `object` | `{}` | Dependensi runtime (kompatibel dengan npm) |
|
|
207
|
+
| `devDependencies` | `object` | `{}` | Dependensi pengembangan saja |
|
|
208
|
+
|
|
209
|
+
### Prioritas Konfigurasi
|
|
210
|
+
|
|
211
|
+
Nilai dari sumber yang lebih tinggi **selalu menimpa** yang lebih rendah:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
flux.json < flux.local.json < flag CLI
|
|
215
|
+
(terendah) (tertinggi)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Contoh: `flux bundle src/main.flux --mangle --sourcemap` akan mengaktifkan mangle dan sourcemap meski `flux.json` menyetel keduanya ke `false`.
|
|
219
|
+
|
|
220
|
+
### `flux.local.json` — Override Lokal
|
|
221
|
+
|
|
222
|
+
Buat `flux.local.json` (jangan di-commit ke git) untuk override lokal:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"sourcemap": true,
|
|
227
|
+
"jsxTarget": "server"
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Tambahkan ke `.gitignore`:
|
|
232
|
+
```
|
|
233
|
+
flux.local.json
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Dari Nol ke Production
|
|
239
|
+
|
|
240
|
+
Panduan lengkap membuat, mengembangkan, dan men-deploy proyek Flux.
|
|
241
|
+
|
|
242
|
+
### 1. Instalasi
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Install Flux secara global
|
|
246
|
+
npm install -g @xnoxs/flux-lang
|
|
247
|
+
|
|
248
|
+
# Verifikasi instalasi
|
|
249
|
+
flux version
|
|
250
|
+
# flux-lang v3.4.1
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 2. Buat Proyek Baru
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
flux init nama-proyek
|
|
257
|
+
cd nama-proyek
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Struktur yang dibuat:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
nama-proyek/
|
|
264
|
+
├── src/
|
|
265
|
+
│ ├── main.flux ← entry point utama
|
|
266
|
+
│ └── utils.flux ← fungsi utilitas (contoh ekspor modul)
|
|
267
|
+
├── tests/
|
|
268
|
+
│ └── main.test.flux ← suite test siap jalan
|
|
269
|
+
├── flux.json ← konfigurasi proyek
|
|
270
|
+
├── .gitignore
|
|
271
|
+
└── README.md
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 3. Jalankan Proyek
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Jalankan langsung (compile + execute sekaligus)
|
|
278
|
+
flux run src/main.flux
|
|
279
|
+
|
|
280
|
+
# Mode watch — auto-compile setiap ada perubahan file
|
|
281
|
+
flux watch src/main.flux
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### 4. Tulis Kode
|
|
285
|
+
|
|
286
|
+
Buka `src/main.flux` dan mulai menulis. Beberapa fitur yang bisa dipakai langsung:
|
|
287
|
+
|
|
288
|
+
```flux
|
|
289
|
+
// src/main.flux
|
|
290
|
+
|
|
291
|
+
// Variabel immutable dan mutable
|
|
292
|
+
val nama = "Flux"
|
|
293
|
+
var hitung = 0
|
|
294
|
+
|
|
295
|
+
// Fungsi dengan tipe
|
|
296
|
+
fn sapa(siapa: String) -> String:
|
|
297
|
+
return "Halo, {siapa}!"
|
|
298
|
+
|
|
299
|
+
// ADT + pattern matching
|
|
300
|
+
type Hasil = Ok(nilai) | Err(pesan)
|
|
301
|
+
|
|
302
|
+
fn bagi(a, b):
|
|
303
|
+
if b == 0: return Err("pembagian dengan nol")
|
|
304
|
+
return Ok(a / b)
|
|
305
|
+
|
|
306
|
+
match bagi(10, 3):
|
|
307
|
+
when Ok(v): print("Hasil: {v:.2f}")
|
|
308
|
+
when Err(e): print("Error: {e}")
|
|
309
|
+
|
|
310
|
+
// Pipe operator
|
|
311
|
+
val angka = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
312
|
+
val hasilAkhir = angka
|
|
313
|
+
|> filter(n -> n % 2 == 0) // [2, 4, 6, 8, 10]
|
|
314
|
+
|> map(n -> n * n) // [4, 16, 36, 64, 100]
|
|
315
|
+
|> sum // 220
|
|
316
|
+
|
|
317
|
+
print("Jumlah kuadrat genap: {hasilAkhir}")
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 5. Type Check & Lint
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# Cek tipe dan analisis statis
|
|
324
|
+
flux check src/main.flux
|
|
325
|
+
|
|
326
|
+
# Lint — cari masalah kode
|
|
327
|
+
flux lint src/main.flux
|
|
328
|
+
|
|
329
|
+
# Format kode ke gaya kanonik
|
|
330
|
+
flux fmt src/
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Contoh output `flux check`:
|
|
334
|
+
```
|
|
335
|
+
✓ src/main.flux — no errors (12 bindings checked)
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Contoh output `flux lint`:
|
|
339
|
+
```
|
|
340
|
+
src/main.flux:15 warn variabel 'x' dideklarasikan tapi tidak dipakai
|
|
341
|
+
src/main.flux:23 warn kode setelah 'return' tidak dapat dijangkau
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 6. Tulis dan Jalankan Test
|
|
345
|
+
|
|
346
|
+
File test menggunakan konvensi `fn test_nama()`:
|
|
347
|
+
|
|
348
|
+
```flux
|
|
349
|
+
// tests/main.test.flux
|
|
350
|
+
|
|
351
|
+
fn add(a, b): return a + b
|
|
352
|
+
|
|
353
|
+
fn test_add():
|
|
354
|
+
assert(add(1, 2) == 3, "1+2=3")
|
|
355
|
+
assert(add(-1, 1) == 0, "cancel out")
|
|
356
|
+
|
|
357
|
+
fn test_string():
|
|
358
|
+
val s = "Hello, Flux!"
|
|
359
|
+
assert(s.length == 12, "panjang string")
|
|
360
|
+
assert(s.startsWith("Hello"), "diawali Hello")
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Jalankan semua test di folder tests/
|
|
365
|
+
flux test tests/
|
|
366
|
+
|
|
367
|
+
# Jalankan file test tertentu
|
|
368
|
+
flux test tests/main.test.flux
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Output:
|
|
372
|
+
```
|
|
373
|
+
◈ main.test.flux
|
|
374
|
+
✓ add
|
|
375
|
+
✓ string
|
|
376
|
+
|
|
377
|
+
Results: 2 passed, 0 failed (2 total) in 14ms
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### 7. Bundle untuk Production
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Bundle semua import menjadi satu file
|
|
384
|
+
flux bundle src/main.flux -o dist/bundle.js
|
|
385
|
+
|
|
386
|
+
# Bundle dengan minifikasi (mangle + no sourcemap)
|
|
387
|
+
flux bundle src/main.flux -o dist/bundle.min.js --mangle
|
|
388
|
+
|
|
389
|
+
# Bundle dengan sourcemap (untuk debugging)
|
|
390
|
+
flux bundle src/main.flux -o dist/bundle.js --sourcemap
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
`dist/bundle.js` adalah file JavaScript murni — tidak butuh runtime khusus, langsung bisa dijalankan di Node.js atau browser.
|
|
394
|
+
|
|
395
|
+
### 8. Deploy ke Production
|
|
396
|
+
|
|
397
|
+
#### Deploy sebagai aplikasi Node.js
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
# Build
|
|
401
|
+
flux bundle src/server.flux -o dist/server.js --mangle
|
|
402
|
+
|
|
403
|
+
# Jalankan
|
|
404
|
+
node dist/server.js
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Contoh `src/server.flux`:
|
|
408
|
+
|
|
409
|
+
```flux
|
|
410
|
+
import http from 'http'
|
|
411
|
+
import { createServer } from 'http'
|
|
412
|
+
|
|
413
|
+
val PORT = process.env.PORT ?? 3000
|
|
414
|
+
|
|
415
|
+
type Route = { method: String, path: String, handler: Function }
|
|
416
|
+
|
|
417
|
+
fn handleRequest(req, res):
|
|
418
|
+
val url = req.url ?? "/"
|
|
419
|
+
val method = req.method ?? "GET"
|
|
420
|
+
|
|
421
|
+
if method == "GET" and url == "/":
|
|
422
|
+
res.writeHead(200, { "Content-Type": "text/plain" })
|
|
423
|
+
res.end("⚡ Flux App berjalan!\n")
|
|
424
|
+
return
|
|
425
|
+
|
|
426
|
+
if method == "GET" and url == "/health":
|
|
427
|
+
res.writeHead(200, { "Content-Type": "application/json" })
|
|
428
|
+
res.end(JSON.stringify({ status: "ok", version: "1.0.0" }))
|
|
429
|
+
return
|
|
430
|
+
|
|
431
|
+
res.writeHead(404, { "Content-Type": "text/plain" })
|
|
432
|
+
res.end("404 Not Found\n")
|
|
433
|
+
|
|
434
|
+
val server = http.createServer(handleRequest)
|
|
435
|
+
server.listen(PORT, fn():
|
|
436
|
+
print("Server berjalan di port {PORT}")
|
|
437
|
+
)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
#### Deploy ke Vercel / Railway / Render
|
|
441
|
+
|
|
442
|
+
Tambahkan ke `package.json` yang sudah ada, atau buat baru:
|
|
443
|
+
|
|
444
|
+
```json
|
|
445
|
+
{
|
|
446
|
+
"name": "nama-proyek",
|
|
447
|
+
"version": "1.0.0",
|
|
448
|
+
"scripts": {
|
|
449
|
+
"build": "flux bundle src/server.flux -o dist/server.js --mangle",
|
|
450
|
+
"start": "node dist/server.js"
|
|
451
|
+
},
|
|
452
|
+
"devDependencies": {
|
|
453
|
+
"@xnoxs/flux-lang": "^3.4.1"
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
# Vercel
|
|
460
|
+
vercel --prod
|
|
461
|
+
|
|
462
|
+
# Railway
|
|
463
|
+
railway up
|
|
464
|
+
|
|
465
|
+
# Render — set build command: npm run build
|
|
466
|
+
# set start command: npm start
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### Deploy ke Cloudflare Workers (browser bundle)
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
# Bundle target browser
|
|
473
|
+
flux bundle src/worker.flux -o dist/worker.js --mangle
|
|
474
|
+
|
|
475
|
+
# Deploy via Wrangler
|
|
476
|
+
wrangler deploy dist/worker.js
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### 9. Manajemen Dependensi
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# Tambah dependensi runtime
|
|
483
|
+
flux add express
|
|
484
|
+
flux add axios@1.6.0
|
|
485
|
+
|
|
486
|
+
# Tambah devDependency
|
|
487
|
+
flux add typescript --dev
|
|
488
|
+
|
|
489
|
+
# Install semua dari flux.json
|
|
490
|
+
flux install
|
|
491
|
+
|
|
492
|
+
# Lihat daftar dependensi terinstal
|
|
493
|
+
flux list
|
|
494
|
+
|
|
495
|
+
# Hapus dependensi
|
|
496
|
+
flux remove express
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
`flux.json` diperbarui otomatis:
|
|
500
|
+
|
|
501
|
+
```json
|
|
502
|
+
{
|
|
503
|
+
"dependencies": {
|
|
504
|
+
"express": "^4.18.0",
|
|
505
|
+
"axios": "1.6.0"
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### 10. Gunakan Dependensi npm di Flux
|
|
511
|
+
|
|
512
|
+
Dependensi npm bisa di-import langsung:
|
|
513
|
+
|
|
514
|
+
```flux
|
|
515
|
+
import express from 'express'
|
|
516
|
+
import { readFileSync } from 'fs'
|
|
517
|
+
import path from 'path'
|
|
518
|
+
|
|
519
|
+
val app = express()
|
|
520
|
+
app.use(express.json())
|
|
521
|
+
|
|
522
|
+
app.get("/", fn(req, res):
|
|
523
|
+
res.json({ status: "ok" })
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
app.listen(3000, fn():
|
|
527
|
+
print("Express + Flux berjalan di port 3000")
|
|
528
|
+
)
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Ringkasan Alur Kerja
|
|
532
|
+
|
|
533
|
+
```
|
|
534
|
+
flux init proyek ← buat proyek baru
|
|
535
|
+
↓
|
|
536
|
+
flux run src/main.flux ← kembangkan (tulis + jalankan)
|
|
537
|
+
↓
|
|
538
|
+
flux watch src/main.flux← mode watch untuk development aktif
|
|
539
|
+
↓
|
|
540
|
+
flux check src/ ← type check sebelum commit
|
|
541
|
+
flux lint src/ ← cari masalah kode
|
|
542
|
+
flux fmt src/ ← format kode
|
|
543
|
+
flux test tests/ ← jalankan test suite
|
|
544
|
+
↓
|
|
545
|
+
flux bundle src/main.flux -o dist/bundle.js --mangle ← build production
|
|
546
|
+
↓
|
|
547
|
+
node dist/bundle.js ← jalankan production build
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
94
552
|
## Quick Start
|
|
95
553
|
|
|
96
554
|
```flux
|