From 22ca93fc9a102695ba5c630e98026c513da17533 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 28 Feb 2025 17:09:55 -0500 Subject: [PATCH] shuffle things around --- README.md | 51 +++------- {clean => browser_example}/bundle.js | 0 {clean => browser_example}/index.html | 2 +- clean/mod.js => mod.js | 0 jsapi.test.tsx => mod.test.tsx | 17 ++-- mod.ts | 133 ------------------------- introspect.ts => server/introspect.ts | 0 serve.tsx => server/serve.tsx | 2 +- {test => test_project}/app-dynamic.tsx | 0 {test => test_project}/app.tsx | 0 {test => test_project}/deep/deep.tsx | 0 {test => test_project}/deno.json | 0 {test => test_project}/index.html | 0 {test => test_project}/leaf.ts | 0 {test => test_project}/other.tsx | 0 what/entry.ts | 10 -- what/include_a.ts | 6 -- what/include_b.ts | 1 - what/index.ts | 20 ---- 19 files changed, 24 insertions(+), 218 deletions(-) rename {clean => browser_example}/bundle.js (100%) rename {clean => browser_example}/index.html (93%) rename clean/mod.js => mod.js (100%) rename jsapi.test.tsx => mod.test.tsx (56%) delete mode 100644 mod.ts rename introspect.ts => server/introspect.ts (100%) rename serve.tsx => server/serve.tsx (98%) rename {test => test_project}/app-dynamic.tsx (100%) rename {test => test_project}/app.tsx (100%) rename {test => test_project}/deep/deep.tsx (100%) rename {test => test_project}/deno.json (100%) rename {test => test_project}/index.html (100%) rename {test => test_project}/leaf.ts (100%) rename {test => test_project}/other.tsx (100%) delete mode 100644 what/entry.ts delete mode 100644 what/include_a.ts delete mode 100644 what/include_b.ts delete mode 100644 what/index.ts diff --git a/README.md b/README.md index 3dabe8d..95c9946 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,27 @@ # ESBuild Typescript Bunder -## Supports import maps and runs on Deno Deploy +## Supports import maps and runs on Deno Deploy and the browser Uses the WASM version of ESBuild for use on Deno Deploy and adds some plugins to allow for import maps. ***Unfortunately, `npm:*` and `jsr:*` specifiers are not supported currently***. ### Manual Bundle API -```typescript -import Bundle from "./mod.ts"; -Bundle( - // directory to work from - "./some_folder", +```javascript +import Bundle from "./mod.js"; - // ESBuild configuration (entry points are relative to "directory"): - {entry:["./app.tsx"]}, - - // import map (if omitted, will scan for a deno configuration within "directory" and use that) - {"imports": { +const {outputFiles} = await Bundle({ + fileSystem:import.meta.resolve('./test_project/'), + esBuild:{entryPoints:["entry"]}, + importMap:{"imports": { + "entry": "./app.tsx", "react": "https://esm.sh/preact@10.22.0/compat", "react/": "https://esm.sh/preact@10.22.0/compat/" }} -); -if(outputFiles){ - for(const item of outputFiles){ - // do something with the output... - console.log(item.text); - } +}); + + +for(const item of outputFiles){ + // do something with the output... + console.log(item.text.substring(0, 200)); } ``` -### Static bundle server - -#### API -```typescript -import Serve from "./serve.tsx"; -Serve({path:"./some_folder", html:"index.html", port:8080}); -``` - -#### CLI -``` -deno run -A /serve.tsx --path=./some_folder --html=index.html --port=8080 -``` - -Accepts three optional settings: -- `path` A directory to serve content from. Defaults to the current working directory. -- `html` A path to an html file or actual html string to *always use* when the server would serve up a non-file route. If `html` is a path, it is assumed to be relative to `path`. If not specified, routes that don't match files will 404. -- `port` Port number (default is 8000). - -When requests to typescript files are made to the server, it will treat that file as an entrypoint and return the corresponding plain javascript bundle. +(dev server is being reworked) \ No newline at end of file diff --git a/clean/bundle.js b/browser_example/bundle.js similarity index 100% rename from clean/bundle.js rename to browser_example/bundle.js diff --git a/clean/index.html b/browser_example/index.html similarity index 93% rename from clean/index.html rename to browser_example/index.html index ff8a38f..8c2ab52 100644 --- a/clean/index.html +++ b/browser_example/index.html @@ -14,7 +14,7 @@