diff --git a/packages/subapp-web/lib/init.js b/packages/subapp-web/lib/init.js index dfaf1783d..223ed1144 100644 --- a/packages/subapp-web/lib/init.js +++ b/packages/subapp-web/lib/init.js @@ -47,6 +47,8 @@ module.exports = function setup(setupContext) { ? Fs.readFileSync(Path.join(__dirname, distDir, "webpack4-jsonp.js")).toString() : ""; + const namespace = _.get(setupContext, "routeOptions.namespace"); + let inlineRuntimeJS = ""; let runtimeEntryPoints = []; if (process.env.NODE_ENV === "production") { @@ -63,10 +65,14 @@ module.exports = function setup(setupContext) { .replace(/\/\/#\ssourceMappingURL=.*$/, "") + "/*rt*/"; - inlineRuntimeJS += `\nwindow.xarcV1.markBundlesLoaded(${JSON.stringify(runtimeEntryPoints)});`; + inlineRuntimeJS += `\nwindow.xarcV1.markBundlesLoaded(${JSON.stringify(runtimeEntryPoints)}${ + namespace ? ", " + JSON.stringify(namespace) : "" + });`; } - const webSubAppJs = ` + `); } if (preLoads.length > 0) { diff --git a/packages/subapp-web/src/index.js b/packages/subapp-web/src/index.js index 65749c93d..6ac1a888e 100644 --- a/packages/subapp-web/src/index.js +++ b/packages/subapp-web/src/index.js @@ -23,7 +23,7 @@ export function loadSubApp(info, renderStart, options) { // mark the subapp's webpack bundle as loaded if (!xarc.getBundle(name, ns)) { - xarc.setBundle(name, true, ns); + xarc.setBundle(name, 1, ns); } // subapp already loaded, do nothing and return the info diff --git a/packages/subapp-web/src/subapp-web.js b/packages/subapp-web/src/subapp-web.js index 4fb6141e7..6865e8228 100644 --- a/packages/subapp-web/src/subapp-web.js +++ b/packages/subapp-web/src/subapp-web.js @@ -1,6 +1,6 @@ // xarc subapp client side lib version 1 // load into window.xarcV1 as a global -(function(w) { +(function (w) { if (!w._wml) { w._wml = {}; } @@ -379,7 +379,7 @@ loadjs(new_assets, id, { success: () => { console.log(`loaded asset for ${name} (id: ${id}) - ${assets}`); - runtimeInfo.bundles[id]++; + xv1.setBundle(id, 1, namespace); afterLoad(); }, error: () => { diff --git a/packages/subapp-web/test/spec/index.spec.js b/packages/subapp-web/test/spec/index.spec.js index 5be7d4a8d..ea868e60d 100644 --- a/packages/subapp-web/test/spec/index.spec.js +++ b/packages/subapp-web/test/spec/index.spec.js @@ -11,7 +11,7 @@ const expect = chai.expect; let clock; -describe("subapp-web", function() { +describe("subapp-web", function () { beforeEach(() => { const dom = new JSDOM(""); clock = sinon.useFakeTimers(); @@ -161,7 +161,7 @@ describe("subapp-web", function() { expect(xarc.rt.bundles).to.deep.equal({ "test-namespace": { - testsubapp: true + testsubapp: 1 } }); expect(subApp._started).to.exist; diff --git a/packages/subapp-web/test/spec/init.spec.js b/packages/subapp-web/test/spec/init.spec.js index be9a22f41..93547f4c3 100644 --- a/packages/subapp-web/test/spec/init.spec.js +++ b/packages/subapp-web/test/spec/init.spec.js @@ -41,6 +41,34 @@ describe("init", function () { expect(initJs).contains(`