Commit Graph
26 Commits
Author SHA1 Message Date
Alex Gleason 1fd3d23d4f Support Tailwind CSS v4 in project builds
Detect the Tailwind major version from the project's package.json and
branch the build pipeline accordingly. v3 projects keep loading the Play
CDN runtime and a JS tailwind.config via the existing synthetic entry.
v4 projects instead pull in @tailwindcss/browser@4, which auto-scans the
document and reads theme config from CSS (@theme / @import 'tailwindcss')
so no config shim is required.
2026-04-26 19:56:25 -05:00
Alex Gleason 695a697e88 Support new Worker(new URL(..., import.meta.url)) and asset URLs
Shakespeare's esbuild-wasm pipeline now handles the Vite/webpack-compatible
patterns for module workers and static asset URLs, so projects using
  new Worker(new URL('./w.ts', import.meta.url), { type: 'module' })
  new SharedWorker(new URL('./w.ts', import.meta.url), { type: 'module' })
  new URL('./logo.svg', import.meta.url)
build correctly under Shakespeare instead of emitting a 404'ing URL
that pointed at the source-file path inside the main bundle.

Mechanics:
- A new detection pass (src/lib/build/workerPlugin.ts) is invoked from
  the fs plugin's onLoad for .ts/.tsx/.js/.jsx/.mjs files. It cheaply
  regex-prefilters on 'new URL(' so 99% of files pay zero overhead,
  then strips TS/JSX via esbuild.transform and parses with acorn +
  acorn-jsx for the handful of files that actually match. The string
  literal spec inside each matched new URL() call is replaced with a
  unique placeholder token, preserving the enclosing new URL(...,
  import.meta.url) shape so runtime resolution against the main
  bundle URL still works.
- bundle() now runs a per-worker sub-build (esbuild.build) with the
  same plugin stack, producing a hashed ESM chunk alongside the main
  output. The queue drains recursively so nested workers / assets
  discovered during a sub-build are handled in the same bundle call.
- Non-source assets are copied into the output with content-hashed
  filenames (SHA-256 when SubtleCrypto is available, FNV-1a fallback
  for test environments).
- After all sub-builds finish, placeholder tokens are string-replaced
  in every JS output with the corresponding './<emitted-filename>'.
- updateCSPForEsmSh gains an emittedWorkers option; when set it
  additionally ensures worker-src and child-src exist and extends
  them with the ESM CDN so module workers can import from esm.sh.

Errors (with file:line context) are raised for classic (non-module)
workers, dynamic specifiers, and unresolvable worker specs. Plain
new URL() pointing at a source file emits a console warning and is
left untransformed.

Tests: 16 new workerPlugin unit tests cover detection, errors,
dedup, and quote-style handling; 4 new CSP tests cover the
emittedWorkers path.
2026-04-25 17:32:14 -05:00
Alex Gleason b8a3571e10 Make NIP.md public if it exists 2026-02-05 23:46:25 -06:00
Alex Gleason 2bc5f45512 Bundle Cloudflare Worker before deploying 2026-01-21 21:36:06 -06:00
Alex Gleason 13ea7c192e Support file: URIs in package.json 2026-01-18 03:22:07 -06:00
Alex Gleason dea364c2a6 Use esbuild worker, emit wasm file in build 2025-11-13 18:50:46 -06:00
Alex Gleason d6dbefeb6d Make nym work 2025-10-18 01:56:51 -05:00
Chad Curtis aa82aaf02c init 2025-10-07 23:41:23 +00:00
Alex Gleason 00d4b9aaac Use tsconfig to resolve paths 2025-10-06 11:18:57 -05:00
Alex Gleason d0c039b37b Let esmPlugin accept a package.json, make packageLock optional 2025-10-06 09:02:41 -05:00
Alex Gleason 15214490af Experimental yarn.lock conversion 2025-10-05 22:06:40 -05:00
Alex Gleason cbf85313af Enable sourcemap, fix output filenames 2025-10-02 17:30:12 -05:00
Alex Gleason 225c90f556 Surgically add esm.sh to existing CSP of index.html 2025-10-02 15:43:27 -05:00
Alex Gleason c72170f19c Build by actually mimicking Vite's handling of index.html 2025-10-02 15:26:27 -05:00
Alex Gleason 93a636589d Fix Tailwind styles 2025-09-27 22:22:49 -05:00
Alex Gleason b064c9ff86 Mock "sonner" and "next-themes" when building 2025-09-27 20:20:04 -05:00
Alex Gleason d33fa36591 Refactor buildProject, copy public files 2025-09-12 13:35:52 -05:00
Alex Gleason 5f619c769a Fix esbuild target 2025-09-11 16:49:18 -05:00
Alex Gleason 4a9bf570f8 Correctly resolve transitive deps 2025-08-11 17:21:29 -07:00
Alex Gleason 4f608d2dd2 Load esbuild-wasm more efficiently, fix tests 2025-08-11 16:17:09 -07:00
Alex Gleason 7eaa3f583f Load Tailwind config 2025-08-11 15:32:29 -07:00
Alex Gleason 82daf4044b mkstack builds with esbuild 2025-08-11 13:15:08 -08:00
Alex Gleason cd3be1ae27 Fix Tailwind (bad) 2025-08-07 14:10:27 -05:00
Alex Gleason 8dfefdc7fd Resolve package.json versions 2025-08-06 22:09:52 -05:00
Alex Gleason d89555723b Parse index.html (fragile) 2025-08-06 21:37:31 -05:00
Alex Gleason 28ec6f98cf esbuild almost works! 2025-08-06 20:57:33 -05:00