diff --git a/internal/mcpapp/mcpapp_test.go b/internal/mcpapp/mcpapp_test.go index 08d52dd6..b2569cdd 100644 --- a/internal/mcpapp/mcpapp_test.go +++ b/internal/mcpapp/mcpapp_test.go @@ -1,6 +1,8 @@ package mcpapp import ( + "regexp" + "sort" "strings" "testing" ) @@ -42,18 +44,118 @@ func TestMcpAppThemeCSSEmbedded(t *testing.T) { } } -// TestAppModuleJSEmbedded pins that each app's self-contained bundle is -// embedded and inlines into the served document. A missing/empty bundle (JS -// not built before Go) panics, so a passing test also proves `pnpm build` ran. +// fromSpecifierRe matches the module-specifier string in `import ... from +// "spec"`, side-effect `import "spec"`, and dynamic `import("spec")` forms. +// Minified bundles drop the space around the keyword/specifier, so both +// `from "x"` and `from"x"` (and `import"x"` / `import("x")`) must match. +var fromSpecifierRe = regexp.MustCompile(`from\s*["']([^"']+)["']|(?:^|[;)\]}])import\s*["']([^"']+)["']|(?:^|[;)\]}])import\s*\(\s*["']([^"']+)["']`) + +// bareModuleSpecifiers returns any module specifiers in an inline-ready bundle +// that the browser cannot resolve on its own: bare package specifiers (e.g. +// "@uppy/core") that do NOT start with ".", "/", or a URL scheme. The sandboxed +// ui:// iframe serves each app as a single inline