Skip to content

Commit cc4de21

Browse files
committed
feat(nf): add --base-href option
1 parent 655a658 commit cc4de21

File tree

8 files changed

+29
-18
lines changed

8 files changed

+29
-18
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@softarc/native-federation",
3-
"version": "2.0.9",
3+
"version": "2.0.10",
44
"type": "commonjs",
55
"license": "MIT",
66
"dependencies": {
77
"json5": "^2.2.0",
88
"npmlog": "^6.0.2",
9-
"@softarc/native-federation-runtime": "2.0.9"
9+
"@softarc/native-federation-runtime": "2.0.10"
1010
}
1111
}

libs/native-federation-core/src/lib/core/bundle-shared.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,11 @@ export async function bundleShared(
3939
// ? `${encName}-${encVersion}-dev.js`
4040
// : `${encName}-${encVersion}.js`;
4141

42-
const hashBase = pi.version + '_' + pi.entryPoint;
43-
const hash = crypto.createHash('sha256')
44-
.update(hashBase)
45-
.digest('base64')
46-
.replace(/\//g, '_')
47-
.replace(/\+/g, '-')
48-
.replace(/=/g, '')
49-
.substring(0,10);
50-
42+
const hash = calcFileHash(pi);
43+
5144
const outName = fedOptions.dev
52-
? `${encName}.${hash}-dev.js`
53-
: `${encName}.${hash}.js`;
45+
? `${encName}.${hash}-dev.js`
46+
: `${encName}.${hash}.js`;
5447

5548
return { fileName: pi.entryPoint, outName };
5649
});
@@ -145,6 +138,19 @@ export async function bundleShared(
145138
});
146139
}
147140

141+
function calcFileHash(pi: PackageInfo) {
142+
const hashBase = pi.version + '_' + pi.entryPoint;
143+
const hash = crypto
144+
.createHash('sha256')
145+
.update(hashBase)
146+
.digest('base64')
147+
.replace(/\//g, '_')
148+
.replace(/\+/g, '-')
149+
.replace(/=/g, '')
150+
.substring(0, 10);
151+
return hash;
152+
}
153+
148154
function copyFileIfExists(cachedFile: string, fullOutputPath: string) {
149155
fs.mkdirSync(path.dirname(fullOutputPath), { recursive: true });
150156

libs/native-federation-esbuild/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@softarc/native-federation-esbuild",
3-
"version": "2.0.9",
3+
"version": "2.0.10",
44
"type": "commonjs",
55
"dependencies": {
66
"@rollup/plugin-commonjs": "^22.0.2",

libs/native-federation-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@softarc/native-federation-runtime",
3-
"version": "2.0.9",
3+
"version": "2.0.10",
44
"peerDependencies": {},
55
"dependencies": {
66
"tslib": "^2.3.0"

libs/native-federation/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/native-federation",
3-
"version": "18.0.1",
3+
"version": "18.1.0",
44
"main": "src/index.js",
55
"generators": "./collection.json",
66
"builders": "./builders.json",
@@ -20,8 +20,8 @@
2020
},
2121
"dependencies": {
2222
"@babel/core": "^7.19.0",
23-
"@softarc/native-federation": "2.0.9",
24-
"@softarc/native-federation-runtime": "2.0.9",
23+
"@softarc/native-federation": "2.0.10",
24+
"@softarc/native-federation-runtime": "2.0.10",
2525
"@types/browser-sync": "^2.29.0",
2626
"browser-sync": "^3.0.2",
2727
"esbuild": "^0.19.5",

libs/native-federation/src/builders/build/builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export async function* runBuilder(
127127
const watch = !!runServer || nfOptions.watch;
128128

129129
options.watch = watch;
130+
options.baseHref = nfOptions.baseHref;
130131
const rebuildEvents = new RebuildHubs();
131132

132133
const adapter = createAngularBuildAdapter(options, context, rebuildEvents);

libs/native-federation/src/builders/build/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export interface NfBuilderSchema extends JsonObject {
1111
watch: boolean;
1212
skipHtmlTransform: boolean;
1313
esmsInitOptions: ESMSInitOptions;
14+
baseHref?: string;
1415
} // eslint-disable-line

libs/native-federation/src/builders/build/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
"type": "boolean",
4444
"default": false
4545
},
46+
"baseHref": {
47+
"type": "string"
48+
},
4649
"esmsInitOptions": {
4750
"type": "object",
4851
"description": "Options for esms-module-shims https://github.com/guybedford/es-module-shims?tab=readme-ov-file#init-options",

0 commit comments

Comments
 (0)