diff --git a/src/__tests__/fixtures/asset-tag/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/asset-tag/__snapshots__/webpack4/server--main.js index 96c99d8..96e99b1 100644 --- a/src/__tests__/fixtures/asset-tag/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/asset-tag/__snapshots__/webpack4/server--main.js @@ -199,12 +199,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "wUwFs+xe", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_wUwF", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_wUwF", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/asset-tag/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/asset-tag/__snapshots__/webpack5/server--main.js index 9db24f1..5dd6fc7 100644 --- a/src/__tests__/fixtures/asset-tag/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/asset-tag/__snapshots__/webpack5/server--main.js @@ -187,12 +187,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "wUwFs+xe", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_wUwF", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_wUwF", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack4/server--main.js index e708d99..ffb5faf 100644 --- a/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack4/server--main.js @@ -122,12 +122,41 @@ const _marko_componentType = "8XgZ/c27", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { out.global.runtimeId = "testruntime"; - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_8XgZ", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_8XgZ", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack5/server--main.js index e6c86c8..2a8fb54 100644 --- a/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/basic-template-plugin-custom-runtime-id/__snapshots__/webpack5/server--main.js @@ -108,12 +108,41 @@ const _marko_componentType = "8XgZ/c27", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { out.global.runtimeId = "testruntime"; - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_8XgZ", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_8XgZ", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack4/server--main.js index bfae6ef..a02ec0f 100644 --- a/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack4/server--main.js @@ -121,12 +121,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "r9oeuJMR", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_r9oe", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_r9oe", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack5/server--main.js index 465a02a..1f5e227 100644 --- a/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/basic-template-plugin/__snapshots__/webpack5/server--main.js @@ -107,12 +107,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "r9oeuJMR", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_r9oe", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_r9oe", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack4/server--main.js index 545199e..35dfd59 100644 --- a/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack4/server--main.js @@ -109,12 +109,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "qMMCl8/W", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("bar_qMMC", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("bar_qMMC", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_bar_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); @@ -266,12 +295,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "FRgaW2aC", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("foo_FRga", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("foo_FRga", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_foo_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); @@ -394,12 +452,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "vyXF8r3F", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("nested_vyXF", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("nested_vyXF", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_template_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack5/server--main.js index f9e7e3c..d7cb681 100644 --- a/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/multiple-entries-plugin/__snapshots__/webpack5/server--main.js @@ -114,12 +114,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "qMMCl8/W", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("bar_qMMC", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("bar_qMMC", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_bar_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); @@ -277,12 +306,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "FRgaW2aC", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("foo_FRga", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("foo_FRga", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_foo_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); @@ -409,12 +467,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "vyXF8r3F", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("nested_vyXF", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("nested_vyXF", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_template_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack4/server--main.js index 6f90eea..f47049f 100644 --- a/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack4/server--main.js @@ -161,12 +161,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "xbStr3Q2", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_xbSt", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_xbSt", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack5/server--main.js index 38b352b..e847056 100644 --- a/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/with-class-component-plugin-dynamic-bundle/__snapshots__/webpack5/server--main.js @@ -149,12 +149,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "xbStr3Q2", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_xbSt", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_xbSt", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack4/server--main.js index 9598e45..f9583f2 100644 --- a/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack4/server--main.js @@ -159,12 +159,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "ntnz89r6", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_ntnz", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_ntnz", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack5/server--main.js index fb8da93..aa61dfb 100644 --- a/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/with-class-component-plugin/__snapshots__/webpack5/server--main.js @@ -147,12 +147,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "ntnz89r6", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_ntnz", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_ntnz", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-public-path/__snapshots__/webpack4/server--main.js b/src/__tests__/fixtures/with-public-path/__snapshots__/webpack4/server--main.js index 8832f20..0d6faae 100644 --- a/src/__tests__/fixtures/with-public-path/__snapshots__/webpack4/server--main.js +++ b/src/__tests__/fixtures/with-public-path/__snapshots__/webpack4/server--main.js @@ -119,12 +119,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "xGHmCIBi", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_5___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_xGHm", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_1__["default"].getAssets("test_xGHm", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_2___default()(_test_marko__WEBPACK_IMPORTED_MODULE_0__["default"], input, out, _component, "0"); diff --git a/src/__tests__/fixtures/with-public-path/__snapshots__/webpack5/server--main.js b/src/__tests__/fixtures/with-public-path/__snapshots__/webpack5/server--main.js index 7c38e31..590b837 100644 --- a/src/__tests__/fixtures/with-public-path/__snapshots__/webpack5/server--main.js +++ b/src/__tests__/fixtures/with-public-path/__snapshots__/webpack5/server--main.js @@ -105,12 +105,41 @@ function outEndOverride(data, encoding, callback) { const _marko_componentType = "xGHmCIBi", _marko_component = {}; _marko_template._ = marko_dist_runtime_components_renderer__WEBPACK_IMPORTED_MODULE_6___default()(function (input, out, _component, component, state) { - out.___flush = out.flush; - out.___end = out.end; - out.___renderAssets = renderAssets; - out.___assets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_xGHm", out.global.buildName); - out.flush = outFlushOverride; - out.end = outEndOverride; + const curAssets = out.___assets; + const newAssets = _marko_webpack_loader_manifest__WEBPACK_IMPORTED_MODULE_2__.default.getAssets("test_xGHm", out.global.buildName); + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } marko_dist_runtime_helpers_render_tag__WEBPACK_IMPORTED_MODULE_3___default()(_test_marko__WEBPACK_IMPORTED_MODULE_1__.default, input, out, _component, "0"); diff --git a/src/loader/get-asset-code.ts b/src/loader/get-asset-code.ts index 7ef29f2..3f9c2f1 100644 --- a/src/loader/get-asset-code.ts +++ b/src/loader/get-asset-code.ts @@ -57,19 +57,50 @@ static function outEndOverride(data, encoding, callback) { this.end(data, encoding, callback); } -${ - runtimeId === undefined - ? "" - : `$ out.global.runtimeId = ${JSON.stringify(runtimeId)};` -} -$ out.___flush = out.flush; -$ out.___end = out.end; -$ out.___renderAssets = renderAssets; -$ out.___assets = manifest.getAssets(${JSON.stringify( +$ { + ${ + runtimeId === undefined + ? "" + : `out.global.runtimeId = ${JSON.stringify(runtimeId)};` + } + const curAssets = out.___assets; + const newAssets = manifest.getAssets(${JSON.stringify( moduleName(resourcePath) )}, out.global.buildName); -$ out.flush = outFlushOverride; -$ out.end = outEndOverride; + + if (curAssets) { + if (newAssets.js) { + if (curAssets.js) { + for (const js of newAssets.js) { + if (!curAssets.js.includes(js)) { + curAssets.js.push(js); + } + } + } else { + curAssets.js = newAssets.js; + } + } + + if (newAssets.css) { + if (curAssets.css) { + for (const css of newAssets.css) { + if (!curAssets.css.includes(css)) { + curAssets.css.push(css); + } + } + } else { + curAssets.css = newAssets.css; + } + } + } else { + out.___flush = out.flush; + out.___end = out.end; + out.___renderAssets = renderAssets; + out.___assets = newAssets; + out.flush = outFlushOverride; + out.end = outEndOverride; + } +} <\${template} ...input/>