Skip to content

Commit

Permalink
fix: Improved files loading from WA-JS (fix #1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Apr 29, 2023
1 parent 260c0d9 commit f94f695
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/webpack/index.ts
Expand Up @@ -105,8 +105,38 @@ export function injectLoader(): void {
return true;
});

const sortWeight: [RegExp, number][] = [
[/locale/, 99],
[/vendor.*main~/, 83],
[/vendor.*main/, 82],
[/main~/, 81],
[/main/, 80],
[/vendor.*lazy.*high/, 75],
[/lazy.*high.*~/, 74],
[/lazy.*high/, 73],
[/vendor.*lazy.*low/, 72],
[/lazy.*low.*~/, 71],
[/lazy.*low/, 70],
[/vendor/, 2],
[/lazy/, 1],
];

const sortValue = (id: string) => {
const filename = webpackRequire.u(id);

for (const w of sortWeight) {
if (w[0].test(filename)) {
return w[1];
}
}

return 0;
};

await Promise.all(
availablesRuntimes.reverse().map((v) => webpackRequire.e(v))
availablesRuntimes
.sort((a, b) => sortValue(b) - sortValue(a))
.map((v) => webpackRequire.e(v))
);

isReady = true;
Expand Down

0 comments on commit f94f695

Please sign in to comment.