Skip to content

Conversation

@internettrans
Copy link

@internettrans internettrans commented Mar 17, 2020

Sharing this for feedback and informational purposes - not to have you merge it in.

new HtmlWebpackPlugin({
template: "./public/index.html"
})
new CopyPlugin([
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the copy plugin to ensure serve.json is in the dist directory (so that cors works)

"source": "**/*",
"headers": [
{
"key": "Access-Control-Allow-Origin",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cors is needed for dynamically injected scripts from systemjs

<script src="http://localhost:3003/remoteEntry.js"></script>
<script type="systemjs-importmap">
{
"imports": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import map

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need an org name here in the app names

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org names are a best practice but are not required.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just wondering

"start": "webpack --watch",
"build": "webpack --mode production",
"serve": "serve dist -p 3002"
"serve": "serve dist -p 3002 -s"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-s puts serve into single page app mode - always returns index.html

}),
new HtmlWebpackPlugin({
template: "./public/index.html",
chunks: ["main"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to inject any scripts into html file anymore

Copy link

@frehner frehner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, I think it would be valuable to add the import map to app2 and app3's HTML just so you can hit up any of those URLs directly and they still work.

but it looks good.

<div id="root"></div>
<script src="https://unpkg.com/systemjs/dist/system.js"></script>
<script>
System.import('app_one')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this one necessary? it seems to be importing the remoteEntry.js for app_one, but I didn't think that was necessary for the app that's running the main.js script to also run the remoteEntry script

I could be wrong though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - probably not. I’ll double check once I get a chance. I added it to mirror how the master branch script tags both the remote entry and the main js file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified it's unneeded - removed it.

new ModuleFederationPlugin({
name: "app_one",
library: { type: "var", name: "app_one" },
library: { type: "system" },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, silly me. removing the name removes the named portion of the module. that makes sense.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah haha I ran into the same problem with the named register but then found this way of removing the name

output: {
publicPath: "http://localhost:3001/"
publicPath: "http://localhost:3001/",
libraryTarget: "system"
Copy link

@bradydowling bradydowling Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxxjdedd
Copy link

fxxjdedd commented Dec 15, 2020

@joeldenning
great work! By the way, I am very curious what are the key benefits of using system in mf?

@internettrans
Copy link
Author

SystemJS allows you to control the download URL of microfrontends via import maps, which opens up tools like import-map-deployer and import-map-overrides for CI/CD and development workflows. SystemJS also has some nice features like live bindings for cross-microfrontend imports, a registry api for inspecting and deleting in-browser modules, etc.

@dipalikamble
Copy link

Hi, i am trying to add latest angular version i.e. angular 14 as parcel application, added multiple angular 5 applications as MFE which are working fine but how to access and run angular 14 as parcel app on click of button from angular 5, I tried this but getting error for angular 14 when try to access angular 14 application name as 'myapp' getting below error when trying to access -
"ERROR: application 'app14' died in status BOOTSTRAPPING: 'Try to load myapp/index.html', status :undefined => undefined"

How to resolve this? if i am running this myapp as MFE independently it is running fine but when try to load it as child application getting above error
image

}
},
{
parser: {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this section needed?

<body>
<div id="root"></div>
<script src="https://unpkg.com/systemjs/dist/system.js"></script>
<script>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you also need to call System.import('app_one')? How is the remoteEntry file being loaded?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants