Restore native boot scheduling without an extra core request

This commit is contained in:
Jonathan Sykes
2026-10-08 11:25:03 +08:00
parent 9408ee07e5
commit 4b1f5204f8
12 changed files with 136 additions and 97 deletions

View File

@@ -32,7 +32,7 @@ test('assets.json describes the complete existing shell exactly once with eager
const { groups } = JSON.parse(readFileSync(join(__dirname, 'assets.json'), 'utf8'));
const described = new Set();
for (const [name, group] of Object.entries(groups)) {
assert.equal(group.contract, 1, `${name} initial contract`);
assert.equal(group.contract, name === 'core' ? 2 : 1, `${name} contract (core boot packing changed)`);
assert.equal(typeof group.eager, 'boolean');
for (const asset of group.files) {
assert.ok(!described.has(asset), `${asset} has one group`);
@@ -100,12 +100,15 @@ test('classic first-visit style preload is discovered before the head loader wit
});
test('the eager cache bootstrap stays last and retains app.js in core and legacy shell',()=>{
test('the last core script owns boot without an extra request or unsafe stale packing',()=>{
const {groups}=JSON.parse(readFileSync(join(__dirname,'assets.json'),'utf8'));
assert.ok(groups.core.files.includes('/app-bootstrap.js'));
assert.equal(groups.core.contract,2,'old core packing cannot fall back without the loader');
assert.ok(groups.core.files.includes('/app.js'));
assert.ok(listed.has('/app-bootstrap.js')&&listed.has('/app.js'));
assert.ok(html.indexOf('src="app-bootstrap.js"')>html.indexOf('src="section-rail.js"'));
assert.ok(groups.core.files.includes('/section-rail.js'));
assert.equal(groups.core.files.includes('/app-bootstrap.js'),false);
assert.equal(listed.has('/app-bootstrap.js'),false);
const scripts=[...html.matchAll(/<script src="([^"]+)"/g)].map(m=>m[1]);
assert.equal(scripts.at(-1),'section-rail.js');
assert.ok(html.includes("'sha256-__APP_SCRIPT_HASH__'"));
assert.ok(readFileSync(join(__dirname,'lazy.js'),'utf8').includes("api.appResponse=(async()=>"));
assert.ok(readFileSync(join(__dirname,'section-rail.js'),'utf8').includes('root.AppBootstrap={ready}'));
});