-
-
Notifications
You must be signed in to change notification settings - Fork 375
feat(runtime): add fetch hook #1761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3fb3987
chore: modify examples
zhoushaw ae24490
chore: modify project config
zhoushaw 89dd452
feat(runtime): the runtime adds a fetch hook and processes fetch-rela…
zhoushaw 7828868
chore: resolve format
zhoushaw ee6e0da
chore: merge main
zhoushaw 02368d5
chore(runtime): add fetch hook unit test
zhoushaw faf15d9
chore: modify test format
zhoushaw 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
3 changes: 2 additions & 1 deletion
3
apps/runtime-demo/host/package.json → ...ntime-demo/3005-runtime-host/package.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
apps/runtime-demo/remote/package.json → ...ime-demo/3006-runtime-remote/package.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,89 @@ | ||
const { registerPluginTSTranspiler } = require('nx/src/utils/nx-plugin.js'); | ||
registerPluginTSTranspiler(); | ||
|
||
const { composePlugins, withNx } = require('@nx/webpack'); | ||
const { withReact } = require('@nx/react'); | ||
|
||
const path = require('path'); | ||
const baseConfig = require('./module-federation.config'); | ||
// const { withModuleFederation } = require('@nx/react/module-federation'); | ||
const { ModuleFederationPlugin } = require('@module-federation/enhanced'); | ||
|
||
/** | ||
* @type {import('@nx/react/module-federation').ModuleFederationConfig} | ||
**/ | ||
const defaultConfig = { | ||
...baseConfig, | ||
}; | ||
|
||
module.exports = composePlugins( | ||
withNx(), | ||
withReact(), | ||
async (config, context) => { | ||
config.plugins.push( | ||
new ModuleFederationPlugin({ | ||
name: 'runtime_remote', | ||
// library: { type: 'var', name: 'runtime_remote' }, | ||
filename: 'remoteEntry.js', | ||
exposes: { | ||
'./Button': './src/Button.tsx', | ||
'./Button1': './src/Button1.tsx', | ||
}, | ||
}), | ||
); | ||
console.log( | ||
'config.optimization?.runtimeChunk', | ||
config.optimization?.runtimeChunk, | ||
); | ||
config.optimization.runtimeChunk = false; | ||
config.plugins.forEach((p) => { | ||
if (p.constructor.name === 'ModuleFederationPlugin') { | ||
//Temporary workaround - https://github.com/nrwl/nx/issues/16983 | ||
p._options.library = undefined; | ||
} | ||
}); | ||
|
||
//Temporary workaround - https://github.com/nrwl/nx/issues/16983 | ||
config.experiments = { outputModule: false }; | ||
|
||
// Update the webpack config as needed here. | ||
// e.g. `config.plugins.push(new MyPlugin())` | ||
config.output = { | ||
...config.output, | ||
scriptType: 'text/javascript', | ||
}; | ||
config.optimization = { | ||
runtimeChunk: false, | ||
minimize: false, | ||
}; | ||
// const mf = await withModuleFederation(defaultConfig); | ||
return config; | ||
/** @type {import('webpack').Configuration} */ | ||
// const parsedConfig = mf(config, context); | ||
|
||
// parsedConfig.plugins.forEach((p) => { | ||
// if (p.constructor.name === 'ModuleFederationPlugin') { | ||
// //Temporary workaround - https://github.com/nrwl/nx/issues/16983 | ||
// p._options.library = undefined; | ||
// } | ||
// }); | ||
|
||
// parsedConfig.devServer = { | ||
// ...(parsedConfig.devServer || {}), | ||
// //Needs to resolve static files from the dist folder (@mf-types) | ||
// static: path.resolve(__dirname, '../../dist/apps/runtime-demo/remote'), | ||
// }; | ||
|
||
// //Temporary workaround - https://github.com/nrwl/nx/issues/16983 | ||
// parsedConfig.experiments = { outputModule: false }; | ||
|
||
// // Update the webpack config as needed here. | ||
// // e.g. `config.plugins.push(new MyPlugin())` | ||
// parsedConfig.output = { | ||
// ...parsedConfig.output, | ||
// scriptType: 'text/javascript', | ||
// }; | ||
|
||
// return parsedConfig; | ||
}, | ||
); |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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.
we should include one of these apps at some point with single runtime chunk true, to make sure everything works with both build setups. I think there is some additional work needed to support single runtimr chunk automatically though. but in future :P