add bundler stuff

This commit is contained in:
2026-07-08 16:59:00 -04:00
parent 2a5fbffaa2
commit ba3d87c27f
12 changed files with 425 additions and 70 deletions

View File

@@ -168,7 +168,16 @@ func bundleEntry(entrySource, projectRoot string, withMeta bool) (js, metafile s
if err != nil {
return "", "", fmt.Errorf("resolve project root: %w", err)
}
vendorDir := filepath.Join(absRoot, "frontend", "vendor")
// Absolute vendor roots (kjol runtime first, then app vendor) so SSR resolves
// the SAME solid-js the client bundle does.
var absVendorDirs []string
for _, d := range vendorDirs() {
if filepath.IsAbs(d) {
absVendorDirs = append(absVendorDirs, d)
} else {
absVendorDirs = append(absVendorDirs, filepath.Join(absRoot, d))
}
}
// vendor.json pins each vendored package's exact entrypoint file (see
// vendor_plugins.go) because a package's own `exports`/`main`/`module` fields
@@ -176,7 +185,8 @@ func bundleEntry(entrySource, projectRoot string, withMeta bool) (js, metafile s
// points at dist/server.js (the seroval-based SSR build), not the DOM dev
// build. The client bundle avoids that via vendorManifestPlugin; SSR needs the
// same pin for the solid-js family it resolves for real (see stubPlugin below).
vendorEntrypoints, err := loadVendorManifest(vendorDir)
// loadVendorManifest returns absolute entrypoint paths.
vendorEntrypoints, err := loadVendorManifest(absVendorDirs)
if err != nil {
return "", "", fmt.Errorf("loading vendor manifest: %w", err)
}
@@ -201,11 +211,7 @@ func bundleEntry(entrySource, projectRoot string, withMeta bool) (js, metafile s
}
if strings.HasPrefix(args.Path, "solid-js") {
if target, ok := vendorEntrypoints[args.Path]; ok {
abs, err := filepath.Abs(filepath.Join(vendorDir, filepath.FromSlash(target)))
if err != nil {
return esbuild.OnResolveResult{}, err
}
return esbuild.OnResolveResult{Path: filepath.ToSlash(abs)}, nil // pinned dev entrypoint
return esbuild.OnResolveResult{Path: target}, nil // pinned dev entrypoint (absolute)
}
return esbuild.OnResolveResult{}, nil // unpinned subpath -> real solid runtime via NodePaths
}
@@ -234,7 +240,7 @@ func bundleEntry(entrySource, projectRoot string, withMeta bool) (js, metafile s
Target: esbuild.ES2017,
Platform: esbuild.PlatformBrowser,
Conditions: []string{"development"},
NodePaths: []string{vendorDir},
NodePaths: absVendorDirs,
Plugins: plugins,
LogLevel: esbuild.LogLevelSilent,
Write: false,