feat: Node.js server target — compile Dart APIs to Node.js#17
Merged
flutterjs-dev merged 6 commits intomasterfrom Feb 17, 2026
Merged
feat: Node.js server target — compile Dart APIs to Node.js#17flutterjs-dev merged 6 commits intomasterfrom
flutterjs-dev merged 6 commits intomasterfrom
Conversation
Refactor package compiler to accept dependencyPaths and build a global symbol table from dependencies' exports.json (prefers explicit URIs, falls back to inferred package: URIs). Split file processing into _parseFile and _generateJS phases, populate local exports into the global table, and run JS generation with an updated importRewriter that preserves package: URIs (converts .dart -> .js). Add verbose/debug logging and diagnostics for symbol resolution and package scanning. Fix declaration extraction: propagate extension-type metadata, log debug info, and record generic typedefs. Also include many generated JS artifacts, source maps and package metadata updates (exports.json / package.json) across flutterjs_dart, foundation, services, widgets, engine, gen, runtime, tools and other packages.
…dec implementations
…, runtime, engine, and build artifacts.
… target - run_command.dart: add _ensureNodeModulesForNodeTarget() — creates node_modules/flutterjs_X junctions before launching node server so `import 'flutterjs_server'` resolves without requiring `flutterjs get` - code_pipleiline.dart: skip web-only @flutterjs packages (material, widgets, vdom, seo, etc.) from PackageRegistry when target is node, preventing symbol table pollution with browser-only widget names - runtime_package_manager.dart: when linking @flutterjs/X SDK packages also link under the Dart name (flutterjs_X) in root node_modules Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ge improvements Core compiler: - Add ImportExportTracker and ImportExportModel for accurate cross-file import analysis - Add EnumDecl IR node and EnumCodeGenerator for proper enum → JS object translation - Fix CascadeExpressionIR scanning in ImportAnalyzer and FileCodeGen - Fix null comparison semantics (== null uses loose equality to catch undefined) - Fix Map cast to use typeof check instead of instanceof Map - Remove hardcoded identifier hacks in ExpressionCodeGenerator Node.js server target: - Add flutterjs_server package (Dart API + JS runtime with HTTP server, router, middleware) - Add dart_api example: full REST API demo compiled from Dart to Node.js - PackageRegistry: filter web-only @flutterjs packages for node target builds - RuntimePackageManager: also link @flutterjs/X as flutterjs_X in root node_modules - RunCommand: auto-link node_modules before starting node server (_ensureNodeModulesForNodeTarget) Import generation: - GlobalSymbolTable wired to ModelToJSPipeline after package manifests load - PackageRegistry.buildGlobalSymbolTable() maps symbols to full package: URIs - Fix hardcoded material imports registered in symbolToPath to prevent duplicates Package updates: - flutterjs_foundation, flutterjs_gestures, flutterjs_material, flutterjs_services, flutterjs_widgets: updated exports.json, build.js, src/index.js - flutterjs_dart: add ui_web dist, pubspec.yaml - flutter_web_plugins: add JS package - Add tool/ scripts for build, check, fix-imports, reset Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a full Node.js server compilation target to FlutterJS, enabling developers to write Dart REST APIs and compile them directly to Node.js JavaScript. Includes the
flutterjs_serverpackage, a workingdart_apiexample, and all the compiler fixes needed to make server-side code generation reliable.🔗 Related Issue
Fixes # (none — new feature)
🏗️ Type of Change
What's New
flutterjs_serverPackageA new Dart package + JS runtime for writing HTTP servers in Dart:
FlutterjsServer— HTTP server with port configurationRouter— route registration (add,mount)Request/Response— request/response model withok,created,notFound,badRequest,noContentfactoriescors()/logger()/bearerAuth()— built-in middlewaredart_apiExampleA complete REST API demo compiled from Dart → Node.js:
GET /— welcome messageGET /health— health checkGET /users/GET /users/:id— list and get usersPOST /users— create userDELETE /users/:id— delete userCompiler Fixes
Import generation:
CascadeExpressionIRnow scanned inImportAnalyzerandFileCodeGen— cascade chains likeserver..use(cors())..use(logger())now correctly detect and importcors/loggerGlobalSymbolTablewired toModelToJSPipelineafter package manifests load (was empty before, causing missing imports)PackageRegistry.buildGlobalSymbolTable()maps symbols to fullpackage:URIs for correct path resolutionCode generation:
== null/!= nullnow generates loose JS== nullto catch bothnullandundefinedas Map<String, dynamic>cast usestypeof x === 'object' && !Array.isArray(x)instead of brokeninstanceof Mapthis.identifierhacks that broke local variablesEnumDeclIR node andEnumCodeGeneratorfor proper enum → JS object outputImportExportTrackerandImportExportModelfor accurate cross-file import analysisNode target pipeline:
PackageRegistry: skips web-only@flutterjspackages (material,widgets,vdom,seo,rendering, etc.) when--target nodeto prevent symbol table pollutionRuntimePackageManager: when linking@flutterjs/X, also links asflutterjs_Xin rootnode_modulesso generatedimport 'flutterjs_server'resolvesRunCommand: auto-createsnode_modulesjunctions before starting the node server — noflutterjs getrequired for basic use📋 Checklist
dart_apiexample compiles and all endpoints pass smoke tests🧪 How to Test
Expected: All endpoints return correct JSON with appropriate HTTP status codes (200, 201, 204, 404).