Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues related to hmr, isomorphic loading, error reporting #1915

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/subapp-web/lib/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Response: ${err || body}`
// if we have to inline the subapp's JS bundle, we load it for production mode
const src = Fs.readFileSync(Path.resolve("dist/js", bundleAsset.name)).toString();
const ext = Path.extname(bundleAsset.name);
if (ext === ".js") {
if (ext === ".js" && !src.endsWith(".hot-update.js")) {
inlineSubAppJs = `<script>/*${name}*/${src}</script>`;
} else if (ext === ".css") {
inlineSubAppJs = `<style id="${name}">${src}</style>`;
Expand Down Expand Up @@ -156,11 +156,11 @@ Response: ${err || body}`
.concat(cdnJsBundles[ep])
.reduce((a, jsBundle) => {
const ext = Path.extname(jsBundle);
if (ext === ".js") {
if (ext === ".js" && !jsBundle.endsWith(".hot-update.js")) {
if (context.user.headEntries) {
headSplits.push(`<link rel="preload" href="${jsBundle}" as="script">`);
}
a.push(`<script src="${jsBundle}" async></script>`);
a.push(`<script src="${jsBundle}" async crossorigin="anonymous"></script>`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ashuverma Thanks for changes.
Looks like this change is causing a test failure for should load bundles for the subapp - Error: Timeout of 2000ms exceeded. . Do you know what is going wrong ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any examples where I can see this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ashuverma I just ran fun test in the root folder after merging master with this branch
Screen Shot 2022-12-13 at 10 12 12 PM

} else if (ext === ".css") {
if (context.user.headEntries) {
headSplits.push(`<link rel="stylesheet" href="${jsBundle}">`);
Expand Down
9 changes: 6 additions & 3 deletions packages/xarc-app-dev/src/lib/app-dev-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export class AppDevMiddleware {
const { refreshed, failed } = data.refreshModules.reduce(
(agg, moduleName) => {
moduleName = moduleName.split("|")[0];
if (!moduleName.startsWith("webpack/runtime")) {
if (
!moduleName.startsWith("webpack/runtime") &&
!moduleName.startsWith("container entry (default)")
) {
try {
const xarcOptions = loadXarcOptions();
const xarcCwd = xarcOptions.cwd;
Expand Down Expand Up @@ -85,8 +88,6 @@ export class AppDevMiddleware {
}
}

initialLoad = false;

// activate extend require for isomorphic assets
getXRequire().activate();

Expand All @@ -106,6 +107,8 @@ export class AppDevMiddleware {
break;
case WEBPACK_EVENT_ISOMORPHIC_CONFIG:
getXRequire().initialize(data.config);
// Only mark initial load to be completed when isomorphic init is done.
initialLoad = false;
break;
case WEBPACK_EVENT_STATS:
break;
Expand Down
5 changes: 5 additions & 0 deletions samples/poc-subapp/xclap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@ loadDevTasks(xrun, {
subAppsToExpose: ["Deal", "Extras"],
shared: {
react: {
eager: true,
requiredVersion: deps.react,
import: "react",
shareKey: "react",
shareScope: "default",
singleton: true
},
"react-dom": {
eager: true,
requiredVersion: deps["react-dom"],
singleton: true
},
history: {
eager: true,
requiredVersion: deps["history"],
singleton: true
},
"subapp-web": {
eager: true,
requiredVersion: deps["subapp-web"],
singleton: true
},
"@babel/runtime": {
eager: true,
requiredVersion: deps["@babel/runtime"],
singleton: true
}
Expand Down