Skip to content

Commit

Permalink
pass default namespace to gerbundleassets inside cdn-map.js (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuverma authored Feb 2, 2021
1 parent fbba865 commit 9464aba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/subapp-web/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ module.exports = function setup(setupContext) {
});`;
}

const namespaceScriptJs = namespace ? `window.__default__namespace="${namespace}";` : "";

const scriptId = namespace ? namespace : "bundle";

const webSubAppJs = `<script id="${scriptId}Assets" type="application/json">
${JSON.stringify(bundleAssets)}
</script>
<script>/*LJ*/${loadJs}/*LJ*/
${webpackJsonpJS}
${namespaceScriptJs}
${clientJs}
${cdnJs}
${inlineRuntimeJS}
Expand Down
2 changes: 1 addition & 1 deletion packages/subapp-web/src/cdn-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@
};

// initialize bundle assets
xv1.getBundleAssets();
xv1.getBundleAssets(w.__default__namespace);
})(window);
2 changes: 2 additions & 0 deletions packages/subapp-web/test/spec/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe("init", function () {
expect(context.user.assets).to.be.ok;
expect(initJs).contains(`<script id="bundleAssets" type="application/json">`);
expect(initJs).contains(`<script>/*LJ*/`);
expect(initJs).not.contains(`window.__default__namespace="testNameSpace";`);
});

it("should return assets as JSON script and loadJs for a given namespace", () => {
Expand Down Expand Up @@ -67,6 +68,7 @@ describe("init", function () {
expect(context.user.assets).to.be.ok;
expect(initJs).contains(`<script id="testNameSpaceAssets" type="application/json">`);
expect(initJs).contains(`<script>/*LJ*/`);
expect(initJs).contains(`window.__default__namespace="testNameSpace";`);
});

it("it should load runtime.bundle.js inline and mark includedBundles.runtime to true", () => {
Expand Down

0 comments on commit 9464aba

Please sign in to comment.