add bundler stuff
This commit is contained in:
@@ -59,21 +59,25 @@ func bundleJSEntry(entry, outName string) (bundleStats, error) {
|
||||
drop = esbuild.DropDebugger
|
||||
}
|
||||
|
||||
vendorDir := filepath.Join(frontendDir, "vendor")
|
||||
vdirs := vendorDirs()
|
||||
|
||||
// Every bundled vendored package's entrypoint is declared in vendor.json rather
|
||||
// than discovered from each package's `exports` — those mis-resolve (e.g.
|
||||
// solid-js's bare core to its SSR build, dist/server.js, where createEffect/
|
||||
// onMount are no-ops, so the DOM renders but every effect is silently dead).
|
||||
entrypoints, err := loadVendorManifest(vendorDir)
|
||||
// Manifests from every vendor dir are merged (kjol runtime wins) so the shared
|
||||
// solid-js resolves to ONE copy across the app + kit trees.
|
||||
entrypoints, err := loadVendorManifest(vdirs)
|
||||
if err != nil {
|
||||
return bundleStats{}, fmt.Errorf("loading vendor manifest: %w", err)
|
||||
}
|
||||
|
||||
// The Go-native Solid compiler (Plugin) sits between the export shim and the
|
||||
// vendor resolvers so it compiles .tsx/.jsx before they're resolved.
|
||||
plugins := []esbuild.Plugin{defaultExportShimPlugin(), Plugin()}
|
||||
plugins = append(plugins, assetURLPlugin(), vendorManifestPlugin(vendorDir, entrypoints))
|
||||
// aliasPlugin resolves @ui/@kjol/@appgen into the kjol web tree (and the app's
|
||||
// generated dir) first. The Go-native Solid compiler (Plugin) sits between the
|
||||
// export shim and the vendor resolvers so it compiles .tsx/.jsx before they're
|
||||
// resolved.
|
||||
plugins := []esbuild.Plugin{aliasPlugin(), defaultExportShimPlugin(), Plugin()}
|
||||
plugins = append(plugins, assetURLPlugin(), vendorManifestPlugin(entrypoints, vdirs))
|
||||
|
||||
result := esbuild.Build(esbuild.BuildOptions{
|
||||
EntryPoints: []string{entry},
|
||||
@@ -84,7 +88,7 @@ func bundleJSEntry(entry, outName string) (bundleStats, error) {
|
||||
Target: esbuild.ES2022,
|
||||
Sourcemap: esbuild.SourceMapLinked,
|
||||
SourceRoot: "./",
|
||||
Outbase: "frontend",
|
||||
Outbase: frontendDir,
|
||||
SourcesContent: esbuild.SourcesContentInclude,
|
||||
MinifyWhitespace: true,
|
||||
MinifyIdentifiers: true,
|
||||
@@ -105,7 +109,7 @@ func bundleJSEntry(entry, outName string) (bundleStats, error) {
|
||||
// data-driven with no per-package list in this source.
|
||||
Platform: esbuild.PlatformBrowser,
|
||||
Conditions: []string{"development"},
|
||||
NodePaths: []string{vendorDir},
|
||||
NodePaths: vdirs,
|
||||
// Assets emitted by assetURLPlugin (e.g. the pdfjs worker, which can't be
|
||||
// inlined because it reads import.meta.url) land in wwwroot/vendor and are
|
||||
// referenced by a root-absolute URL.
|
||||
|
||||
Reference in New Issue
Block a user