diff --git a/.changeset/quick-onions-tie.md b/.changeset/quick-onions-tie.md new file mode 100644 index 0000000000..8d3c2255b2 --- /dev/null +++ b/.changeset/quick-onions-tie.md @@ -0,0 +1,5 @@ +--- +"marko": patch +--- + +Fix issue where implicit split components (those with no class/component that have event handlers) were not getting the client side render apis. diff --git a/packages/runtime-class/src/translator/index.js b/packages/runtime-class/src/translator/index.js index 647815b586..5410995b81 100644 --- a/packages/runtime-class/src/translator/index.js +++ b/packages/runtime-class/src/translator/index.js @@ -73,6 +73,7 @@ export const analyze = { ) { meta.component = file.opts.filename; } else if (meta.hasStringEventHandlers) { + meta.implicitSplitComponent = true; meta.component = componentFiles.componentBrowserFile = "marko/src/runtime/helpers/empty-component.js"; meta.hasComponentBrowser = true; @@ -388,7 +389,7 @@ export const translate = { componentTypeIdentifier, t.arrowFunctionExpression( [], - componentBrowserFile + componentBrowserFile && !meta.implicitSplitComponent ? importDefault( file, resolveRelativePath(file, componentBrowserFile), diff --git a/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdom-expected.js b/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdom-expected.js index 998e4f8779..32796233ff 100644 --- a/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdom-expected.js +++ b/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdom-expected.js @@ -6,8 +6,7 @@ import _customTag from "./components/custom-tag.marko"; import _marko_tag from "marko/src/runtime/helpers/render-tag.js"; import _marko_renderer from "marko/src/runtime/components/renderer.js"; import { r as _marko_registerComponent } from "marko/src/runtime/components/registry.js"; -import _marko_split_component from "marko/src/runtime/helpers/empty-component.js"; -_marko_registerComponent(_marko_componentType, () => _marko_split_component); +_marko_registerComponent(_marko_componentType, () => _marko_template); const _marko_component = {}; _marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { out.e("div", null, "0", _component, 0, 0, { diff --git a/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdomProduction-expected.js b/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdomProduction-expected.js index b26577bc74..148ce63e4e 100644 --- a/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdomProduction-expected.js +++ b/packages/runtime-class/test/translator/fixtures/event-handlers/snapshots/vdomProduction-expected.js @@ -6,8 +6,7 @@ import _customTag from "./components/custom-tag.marko"; import _marko_tag from "marko/dist/runtime/helpers/render-tag.js"; import _marko_renderer from "marko/dist/runtime/components/renderer.js"; import { r as _marko_registerComponent } from "marko/dist/runtime/components/registry.js"; -import _marko_split_component from "marko/dist/runtime/helpers/empty-component.js"; -_marko_registerComponent(_marko_componentType, () => _marko_split_component); +_marko_registerComponent(_marko_componentType, () => _marko_template); const _marko_component = {}; _marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { out.e("div", null, "0", _component, 0, 0, {