Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
179 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
# With Webpack module federation | ||
|
||
Usage of With Webpack module federation as host app and eager dependency |
This file contains 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 @@ | ||
// mock dependency | ||
require("lodash"); | ||
|
||
console.log("ok"); |
This file contains 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 @@ | ||
import("./bootstrap"); |
This file contains 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,17 @@ | ||
{ | ||
"name": "webpack-module-federaition-host", | ||
"description": "Ensure integrity works with webpack module federation as host app", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"private": true, | ||
"devDependencies": { | ||
"expect": "^26.6.2", | ||
"nyc": "*", | ||
"webpack": "^5.44.0", | ||
"webpack-cli": "4", | ||
"webpack-subresource-integrity": "*" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
examples/webpack-module-federaition-host/webpack.config.js
This file contains 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 @@ | ||
const { SubresourceIntegrityPlugin } = require("webpack-subresource-integrity"); | ||
const expect = require("expect"); | ||
const container = require("webpack").container; | ||
|
||
const { ModuleFederationPlugin } = container; | ||
|
||
module.exports = { | ||
entry: { | ||
index: "./index.js", | ||
}, | ||
output: { | ||
crossOriginLoading: "anonymous", | ||
}, | ||
plugins: [ | ||
new SubresourceIntegrityPlugin({ | ||
hashFuncNames: ["sha256"], | ||
enabled: true, | ||
}), | ||
new ModuleFederationPlugin({ | ||
name: "host", | ||
filename: "remoteEntry.js", | ||
remotes: { | ||
app1: "app1@http://localhost:3001/remoteEntry.js", | ||
}, | ||
exposes: { | ||
"./remote": "./bootstrap", | ||
}, | ||
shared: { | ||
lodash: { | ||
singleton: true, | ||
eager: true, | ||
}, | ||
}, | ||
}), | ||
{ | ||
apply: (compiler) => { | ||
compiler.hooks.done.tap("wsi-test", (stats) => { | ||
const assets = stats.toJson().assets; | ||
|
||
assets.forEach((asset) => { | ||
expect(asset).not.toContain("*-*-*-CHUNK-SRI-HASH-"); | ||
}); | ||
}); | ||
}, | ||
}, | ||
], | ||
}; |
This file contains 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,3 @@ | ||
# With Webpack module federation | ||
|
||
Usage of With Webpack module federation as remote app |
This file contains 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 @@ | ||
// mock dependency | ||
require("lodash"); | ||
|
||
console.log("ok"); |
This file contains 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 @@ | ||
import("./bootstrap"); |
This file contains 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,17 @@ | ||
{ | ||
"name": "webpack-module-federaition-remote", | ||
"description": "Ensure integrity works with webpack module federation as remote app", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"private": true, | ||
"devDependencies": { | ||
"expect": "^26.6.2", | ||
"nyc": "*", | ||
"webpack": "^5.44.0", | ||
"webpack-cli": "4", | ||
"webpack-subresource-integrity": "*" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
examples/webpack-module-federaition-remote/webpack.config.js
This file contains 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,43 @@ | ||
const { SubresourceIntegrityPlugin } = require("webpack-subresource-integrity"); | ||
const expect = require("expect"); | ||
const container = require("webpack").container; | ||
|
||
const { ModuleFederationPlugin } = container; | ||
|
||
module.exports = { | ||
entry: { | ||
index: "./index.js", | ||
}, | ||
output: { | ||
crossOriginLoading: "anonymous", | ||
}, | ||
plugins: [ | ||
new SubresourceIntegrityPlugin({ | ||
hashFuncNames: ["sha256"], | ||
enabled: true, | ||
}), | ||
new ModuleFederationPlugin({ | ||
name: "remote", | ||
filename: "remoteEntry.js", | ||
exposes: { | ||
"./remote": "./bootstrap", | ||
}, | ||
shared: { | ||
lodash: { | ||
singleton: true, | ||
}, | ||
}, | ||
}), | ||
{ | ||
apply: (compiler) => { | ||
compiler.hooks.done.tap("wsi-test", (stats) => { | ||
const assets = stats.toJson().assets; | ||
|
||
assets.forEach((asset) => { | ||
expect(asset).not.toContain("*-*-*-CHUNK-SRI-HASH-"); | ||
}); | ||
}); | ||
}, | ||
}, | ||
], | ||
}; |
This file contains 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 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 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