-
Notifications
You must be signed in to change notification settings - Fork 298
feat: cjs interop #720
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
hugs7
wants to merge
9
commits into
originjs:main
Choose a base branch
from
hugs7:feature/cjs-interop
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
feat: cjs interop #720
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bda3d12
docs: fix missing quote in readme
hugs7 4f503dd
feat: cjs interop initial commit
hugs7 9ab0ea1
fix: apply cjs interop after factory loaded
hugs7 91a7ee4
fix: applying esinterop
hugs7 d2a60b5
style: syntax formatting
hugs7 abcda9c
fix: load remote from via globalThis
hugs7 d304eb3
fix: remove commented code
hugs7 3464558
fix: remove console logs + unused code
hugs7 fad8803
refactor: restore inline ensure promise callback
hugs7 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
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 |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ const loadJS = async (url, fn) => { | |
| } | ||
| function get(name, ${REMOTE_FROM_PARAMETER}){ | ||
| return import(/* @vite-ignore */ name).then(module => ()=> { | ||
| if (${REMOTE_FROM_PARAMETER} === 'webpack') { | ||
| if ((globalThis.__federation_shared_remote_from__ ?? ${REMOTE_FROM_PARAMETER}) === 'webpack') { | ||
| return Object.prototype.toString.call(module).indexOf('Module') > -1 && module.default ? module.default : module | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as per my PR description, if you think it's better to rebind the share scope instead of taking |
||
| } | ||
| return module | ||
|
|
@@ -141,7 +141,7 @@ function __federation_method_wrapDefault(module ,need){ | |
| return module; | ||
| } | ||
|
|
||
| function __federation_method_getRemote(remoteName, componentName){ | ||
| function __federation_method_getRemote(remoteName, componentName) { | ||
| return __federation_method_ensure(remoteName).then((remote) => remote.get(componentName).then(factory => factory())); | ||
| } | ||
|
|
||
|
|
@@ -395,7 +395,9 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation | |
| const idx = moduleFilePath.indexOf(cwdPath) | ||
|
|
||
| const relativePath = | ||
| idx === 0 ? posix.join(base, moduleFilePath.slice(cwdPath.length)) : null | ||
| idx === 0 | ||
| ? posix.join(base, moduleFilePath.slice(cwdPath.length)) | ||
| : null | ||
|
|
||
| const sharedName = item[0] | ||
| const obj = item[1] | ||
|
|
@@ -406,7 +408,7 @@ export {__federation_method_ensure, __federation_method_getRemote , __federation | |
| const url = origin | ||
| ? `'${origin}${pathname}'` | ||
| : `window.location.origin+'${pathname}'` | ||
| str += `get:()=> get(${url}, ${REMOTE_FROM_PARAMETER})` | ||
| str += `get:() => get(${url}, ${REMOTE_FROM_PARAMETER})` | ||
| res.push(`'${sharedName}':{'${obj.version}':{${str}}}`) | ||
| } | ||
| } | ||
|
|
||
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
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.
I noticed a small typo here