You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core): move report template out of core js output
Previously, core and report were tightly coupled at build time.
apps/report depends on @midscene/core because the report UI reuses core types, dump
structures, and helper logic. At the same time, the built core output needed
to inline the report HTML template.
This meant report had to build after core, but the final usable core output
still depended on report building first and writing HTML back into core dist.
The old flow scanned built core JS files, found magic strings such as
REPLACE_ME_WITH_REPORT_HTML, and replaced them with the full report HTML.
That flow was fragile and could repeatedly inject the template. Since report
HTML is large and apps/report may bundle an already-injected core dist, the
next report build could include the previous template inside the new template.
Writing that back into core again could cause recursive HTML growth.
This change separates responsibilities. apps/report now owns report template
generation and syncs apps/report/dist/index.html into core as a static asset:
packages/core/dist/report-template/index.html
@midscene/core no longer inlines the report template into its JS output and
no longer relies on magic string replacement. At runtime, core reads the
template from its own package asset when generating reports.
For bundled @midscene/core targets, static assets may not be included in the
final bundle. Those targets can inject the template through:
globalThis.__MIDSCENE_INTERNAL_REPORT_TEMPLATE_CONTENT__
Core reads this global first, before falling back to the local template file.
Internal bundle targets use a build plugin that replaces @midscene/core entries
with wrapper modules. The wrapper injects the report template first and then
re-exports the original core entry. This puts template injection into the
bundler module graph instead of rewriting final JS output.
// put back the report template to the core package
28
-
// this is a workaround for the circular dependency issue
29
-
// ERROR: This repository uses pkg in bundler mode. It is necessary to declare @midscene/report in the dependency; otherwise, it may cause packaging order issues and thus lead to the failure of report injection
0 commit comments