Skip to content

Commit 9ba07b1

Browse files
fix(lynx): execute native lazy background chunks
1 parent e35a41c commit 9ba07b1

3 files changed

Lines changed: 32 additions & 19 deletions

File tree

apps/lynx-module-federation-demo/test/native-artifacts.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ for (const name of hostLazyBundles) {
113113
'string',
114114
name,
115115
);
116+
assert.ok(
117+
!lazyTemplate['custom-sections'].background.includes(
118+
"tt.define('/app-service.js'",
119+
),
120+
`${name} contains the app-service dispatcher instead of its executable chunk`,
121+
);
116122
}
117123

118124
const manifest = JSON.parse(manifestSource);
@@ -161,6 +167,12 @@ for (const exposed of manifest.exposes) {
161167
'string',
162168
`${lazyName} has no background section`,
163169
);
170+
assert.ok(
171+
!lazyTemplate['custom-sections'].background.includes(
172+
"tt.define('/app-service.js'",
173+
),
174+
`${lazyName} contains the app-service dispatcher instead of its executable chunk`,
175+
);
164176
assert.ok(
165177
lazyTemplate['custom-sections']?.['main-thread']?.length > 100,
166178
`${lazyName} has no main-thread snapshot section`,
@@ -177,9 +189,8 @@ const nestedTemplate = decodeTemplate(
177189
),
178190
);
179191
assert.equal(nestedTemplate['app-type'], 'DynamicComponent');
180-
const nestedBackgroundSource = nestedTemplate['background-thread-script']
181-
.map(({ content }) => content)
182-
.join('\n');
192+
const nestedBackgroundSource =
193+
nestedTemplate['custom-sections']?.background ?? '';
183194
assert.ok(
184195
nestedBackgroundSource.includes('Nested federated module ready'),
185196
`${nestedLazyBundle} does not contain the nested module`,

patches/@lynx-js__template-webpack-plugin@0.13.0.patch

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ index 0b6c07d7971129a5e0147e3f924dcb273d8dccd5..54654a6d9c52902596caf81eff48c9b7
142142
syncXElementRegistry: true,
143143
enableA11y,
144144
enableAccessibilityElement,
145-
@@ -608,9 +641,6 @@ class LynxTemplatePluginImpl {
145+
@@ -608,9 +641,10 @@ class LynxTemplatePluginImpl {
146146
const remainingManifest = {};
147147
let entryChunk;
148148
for (const [name, content] of Object.entries(manifest)) {
149149
- if (name === '/app-service.js') {
150-
- continue;
151-
- }
150+
+ if (name === '/app-service.js'
151+
+ && content.includes("tt.define('/app-service.js'")) {
152+
continue;
153+
}
152154
if (!entryChunk) {
153155
entryChunk = [name, content];
154156
continue;

pnpm-lock.yaml

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)