add chadscript/* stdlib module resolution (router, argparse, http-utils)#79
Merged
add chadscript/* stdlib module resolution (router, argparse, http-utils)#79
Conversation
moves router.ts and http-utils.ts to lib/, symlinks lib/argparse.ts to src/argparse.ts. both js and native compilers resolve chadscript/* imports: js uses __libDir from import.meta.url, native uses registerStdlib/ChadScript.embedFile at startup.
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.
ChadScript stdlib module resolution
Summary
Adds
chadscript/*module namespace for accessing built-in stdlib modules. Moves router, argparse, and http-utils from scattered source locations into a cohesivelib/directory and implements module resolution in both JS and native compilers.Changes
Module Reorganization
lib/:router.ts,http-utils.ts(previously insrc/)lib/argparse.ts→src/argparse.ts(eliminates duplication, single source of truth)import { ... } from "chadscript/*"Compiler Support
JS compiler (
compiler.ts):chadscript/*imports using__libDirfromimport.meta.urlNative compiler (
src/chad-native.ts+native-compiler-lib.ts):registerStdlib()at startup to register embedded stdlib filesChadScript.embedFile()to load lib files-Wl,-sectcreateTypeScript Config
tsconfig.jsonpaths mapping for stdlib moduleschadscript/*importsFiles Modified
examples/cli-parser-demo.ts,examples/hackernews/app.ts,examples/http-server.ts,examples/string-search.ts,examples/websocket/app.ts,examples/word-count.tstests/fixtures/network/router-params.tslib/argparse.ts(symlink),lib/router.ts,lib/http-utils.tssrc/compiler.ts(module resolution)src/native-compiler-lib.ts(stdlib registration)src/chad-native.ts(startup registration)tsconfig.json(path mappings)Test Status
Run:
npm run verify(ornpm run verify:quick)Benefits
import { Router } from "chadscript/router"vs relative pathslib/