-
-
Notifications
You must be signed in to change notification settings - Fork 376
Fix worker runtime chunk regressing web worker builds #4116
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
Open
ScriptedAlchemy
wants to merge
58
commits into
main
Choose a base branch
from
research/issue-4085
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
1b194ad
fix: preserve worker runtimes with shared runtime chunk
ScriptedAlchemy 8b328d9
fix: adjust runtime reassignment timing
ScriptedAlchemy decc21f
fix: retain runtime modules when reassigning chunks
ScriptedAlchemy 75762c8
fix: carry runtime modules when moving worker runtime
ScriptedAlchemy 16af11a
fix: copy runtime requirements to reassigned chunk
ScriptedAlchemy f137cb9
fix: guard remote runtime when bundler runtime missing
ScriptedAlchemy aa9c43a
fix: guard remotes helper when bundler runtime absent
ScriptedAlchemy 0fada87
fix: guard remote runtime indentation
ScriptedAlchemy 6b14527
fix: type guard runtime template indent
ScriptedAlchemy 53301e6
fix: retain shared runtime modules for async entries
ScriptedAlchemy ac8fc81
chore: add changeset for async runtime fix
ScriptedAlchemy a30e43c
test: cover worker runtime chunk clone
ScriptedAlchemy b00b06b
test: capture worker runtime duplication
ScriptedAlchemy 0cfff1b
test: cover compiler runtime hoisting
ScriptedAlchemy c5afda1
fix(module-federation): guard remote runtime chunk relocation
ScriptedAlchemy 874341d
test(enhanced): add worker test case for module federation
ScriptedAlchemy 1062bc9
fix(enhanced): prevent React version contamination in worker test
ScriptedAlchemy 66325ee
fix(enhanced): ensure federation runtime in worker chunks and prevent…
ScriptedAlchemy 49c44ab
chore(module-federation): scope root test script to packages (tag:typ…
ScriptedAlchemy e0226a0
Merge remote-tracking branch 'origin/main' into research/issue-4085
ScriptedAlchemy c9d39ff
chore(runtime-demo): add Worker wrapper demo mirroring gravity-ui pat…
ScriptedAlchemy 95cef3f
fix(runtime-demo): enable runtime chunk and use WorkerWrapper for wor…
ScriptedAlchemy e242212
fix: format code to pass CI checks
ScriptedAlchemy dac0e60
chore(tests,docs): restore removed fixtures and docs from main
ScriptedAlchemy 3e2713f
test(runtime-demo): skip WorkerWrapper in Cypress to avoid importScri…
ScriptedAlchemy 09a4ff2
test(enhanced): add react stub under container/worker test fixture to…
ScriptedAlchemy 730e00e
test(runtime-demo): skip WorkerDemo worker init under Cypress to avoi…
ScriptedAlchemy 8bf41de
test(e2e): account for Cypress skip by expecting n/a for worker result
ScriptedAlchemy afc8e68
fix(runtime-demo): load compiled worker via .js URL so importScripts …
ScriptedAlchemy a5511fd
fix(runtime-demo): emit dedicated worker entry as worker.js and point…
ScriptedAlchemy 8bdbc3d
fix(runtime-demo): force importScripts to load /worker.js from public…
ScriptedAlchemy a35626c
test(e2e): assert both native worker and worker-loader wrapper responses
ScriptedAlchemy 4d685d0
fix(runtime-demo): preload runtime.js in worker loader and use static…
ScriptedAlchemy 2779164
Merge branch 'main' into research/issue-4085
ScriptedAlchemy d0f805d
Merge remote-tracking branch 'origin/main' into research/issue-4085
ScriptedAlchemy c08e78e
test: add worker federation compiler integration
ScriptedAlchemy a98e9d1
refactor: use existing identifiers for async runtimes
ScriptedAlchemy bbb335f
fix: ensure runtime names are plain strings
ScriptedAlchemy 8188210
test: inspect share plugin internals via private fields
ScriptedAlchemy 6b5045a
refactor: switch runtime app to worker-loader
ScriptedAlchemy 952bec0
refactor: split worker demo into native and loader flows
ScriptedAlchemy db01b16
test: disable dts in worker async runtime test
ScriptedAlchemy 2177eac
chore: merge main into research issue 4085
ScriptedAlchemy 58c0cf0
fix: reattach runtime modules via hooks
ScriptedAlchemy a6bede7
test: harden compiler unit suites
ScriptedAlchemy 58b007c
chore: merge main
ScriptedAlchemy 3357428
chore: run full enhanced test suite
ScriptedAlchemy b4f0a90
test: extend worker integration timeout
ScriptedAlchemy 7cc4b1f
Merge branch 'main' into research/issue-4085
ScriptedAlchemy 39c8d3a
fix: guard manifest package detection
ScriptedAlchemy ae883fd
Merge branch 'main' into research/issue-4085
ScriptedAlchemy 8fd36a6
chore: disable nx tui and clean enhanced jest setup
ScriptedAlchemy da540ca
Merge remote-tracking branch 'origin/main' into research/issue-4085
ScriptedAlchemy a0e6864
fix(runtime): hoist federation runtime into worker child compilers
ScriptedAlchemy 1d5497a
fix(enhanced): inject federation runtime into worker chunks
ScriptedAlchemy becdf94
fix: ensure runtime logger available in worker
ScriptedAlchemy 0c9ddec
fix(enhanced): restore runtime plugin defaults
ScriptedAlchemy 073d591
feat: include federation runtime for worker blocks
ScriptedAlchemy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@module-federation/enhanced": patch | ||
--- | ||
|
||
Keep async entry runtime helpers available when cloning runtimes for web workers and other dynamic entrypoints. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
NX_DEAMON=false | ||
NX_DAEMON=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
apps/runtime-demo/3005-runtime-host/src/components/WorkerLoaderDemo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export function WorkerLoaderDemo() { | ||
const [result, setResult] = useState<string | null>(null); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
try { | ||
const worker = new Worker( | ||
new URL('../worker/loader-worker.js', import.meta.url), | ||
{ | ||
name: 'mf-loader-worker', | ||
}, | ||
); | ||
|
||
worker.onmessage = (event) => { | ||
setResult(event.data ?? null); | ||
}; | ||
|
||
worker.onerror = (event) => { | ||
setError((event as unknown as ErrorEvent).message ?? 'Worker error'); | ||
}; | ||
|
||
worker.postMessage({ value: 'foo' }); | ||
|
||
return () => { | ||
worker.terminate(); | ||
}; | ||
} catch (err) { | ||
setError((err as Error).message); | ||
} | ||
|
||
return undefined; | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div className="worker-expected">Expected worker response: 1</div> | ||
<pre className="worker-loader-result"> | ||
{result ? JSON.stringify(result, null, 2) : 'n/a'} | ||
</pre> | ||
{error ? <div className="worker-error">Worker error: {error}</div> : null} | ||
</div> | ||
); | ||
} | ||
|
||
export default WorkerLoaderDemo; |
46 changes: 46 additions & 0 deletions
46
apps/runtime-demo/3005-runtime-host/src/components/WorkerNativeDemo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export function WorkerNativeDemo() { | ||
const [result, setResult] = useState<any>(null); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
try { | ||
const worker = new Worker( | ||
new URL('../worker/native-worker.js', import.meta.url), | ||
{ | ||
name: 'mf-native-worker', | ||
}, | ||
); | ||
|
||
worker.onmessage = (event) => { | ||
setResult(event.data ?? null); | ||
}; | ||
|
||
worker.onerror = (event) => { | ||
setError((event as unknown as ErrorEvent).message ?? 'Worker error'); | ||
}; | ||
|
||
worker.postMessage({ value: 'foo' }); | ||
|
||
return () => { | ||
worker.terminate(); | ||
}; | ||
} catch (err) { | ||
setError((err as Error).message); | ||
} | ||
|
||
return undefined; | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<pre className="worker-native-result"> | ||
{result ? JSON.stringify(result, null, 2) : 'n/a'} | ||
</pre> | ||
{error ? <div className="worker-error">Worker error: {error}</div> : null} | ||
</div> | ||
); | ||
} | ||
|
||
export default WorkerNativeDemo; |
15 changes: 15 additions & 0 deletions
15
apps/runtime-demo/3005-runtime-host/src/worker/loader-worker.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env worker */ | ||
import { workerMap } from './map.js'; | ||
|
||
self.onmessage = (event) => { | ||
const value = event.data && event.data.value; | ||
const federation = | ||
typeof __webpack_require__ !== 'undefined' | ||
? __webpack_require__.federation || {} | ||
: {}; | ||
const federationKeys = Object.keys(federation); | ||
self.postMessage({ | ||
answer: workerMap[value] ?? null, | ||
federationKeys, | ||
}); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const workerMap = { | ||
foo: '1', | ||
bar: '2', | ||
}; |
15 changes: 15 additions & 0 deletions
15
apps/runtime-demo/3005-runtime-host/src/worker/native-worker.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env worker */ | ||
import { workerMap } from './map.js'; | ||
|
||
self.onmessage = (event) => { | ||
const value = event.data && event.data.value; | ||
const federation = | ||
typeof __webpack_require__ !== 'undefined' | ||
? __webpack_require__.federation || {} | ||
: {}; | ||
const federationKeys = Object.keys(federation); | ||
self.postMessage({ | ||
answer: workerMap[value] ?? null, | ||
federationKeys, | ||
}); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-env worker */ | ||
import { workerMap } from './map'; | ||
|
||
self.onmessage = (event) => { | ||
const value = event.data && event.data.value; | ||
self.postMessage({ | ||
answer: workerMap[value] ?? null, | ||
}); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is some debug code? Because in my project i got this problem, when federation is
undefined
(i was unable to reproduce it, but found another error, that i was reported in issue)