diff --git a/libs/native-federation-core/package.json b/libs/native-federation-core/package.json index fd618f6..c6a6ccb 100644 --- a/libs/native-federation-core/package.json +++ b/libs/native-federation-core/package.json @@ -1,11 +1,11 @@ { "name": "@softarc/native-federation", - "version": "2.0.9", + "version": "2.0.10", "type": "commonjs", "license": "MIT", "dependencies": { "json5": "^2.2.0", "npmlog": "^6.0.2", - "@softarc/native-federation-runtime": "2.0.9" + "@softarc/native-federation-runtime": "2.0.10" } } diff --git a/libs/native-federation-core/src/lib/core/bundle-shared.ts b/libs/native-federation-core/src/lib/core/bundle-shared.ts index 6d6cd5c..ce33a93 100644 --- a/libs/native-federation-core/src/lib/core/bundle-shared.ts +++ b/libs/native-federation-core/src/lib/core/bundle-shared.ts @@ -39,18 +39,11 @@ export async function bundleShared( // ? `${encName}-${encVersion}-dev.js` // : `${encName}-${encVersion}.js`; - const hashBase = pi.version + '_' + pi.entryPoint; - const hash = crypto.createHash('sha256') - .update(hashBase) - .digest('base64') - .replace(/\//g, '_') - .replace(/\+/g, '-') - .replace(/=/g, '') - .substring(0,10); - + const hash = calcFileHash(pi); + const outName = fedOptions.dev - ? `${encName}.${hash}-dev.js` - : `${encName}.${hash}.js`; + ? `${encName}.${hash}-dev.js` + : `${encName}.${hash}.js`; return { fileName: pi.entryPoint, outName }; }); @@ -145,6 +138,19 @@ export async function bundleShared( }); } +function calcFileHash(pi: PackageInfo) { + const hashBase = pi.version + '_' + pi.entryPoint; + const hash = crypto + .createHash('sha256') + .update(hashBase) + .digest('base64') + .replace(/\//g, '_') + .replace(/\+/g, '-') + .replace(/=/g, '') + .substring(0, 10); + return hash; +} + function copyFileIfExists(cachedFile: string, fullOutputPath: string) { fs.mkdirSync(path.dirname(fullOutputPath), { recursive: true }); diff --git a/libs/native-federation-esbuild/package.json b/libs/native-federation-esbuild/package.json index 7a2010e..cc47d77 100644 --- a/libs/native-federation-esbuild/package.json +++ b/libs/native-federation-esbuild/package.json @@ -1,6 +1,6 @@ { "name": "@softarc/native-federation-esbuild", - "version": "2.0.9", + "version": "2.0.10", "type": "commonjs", "dependencies": { "@rollup/plugin-commonjs": "^22.0.2", diff --git a/libs/native-federation-runtime/package.json b/libs/native-federation-runtime/package.json index 439317b..d9cf2d7 100644 --- a/libs/native-federation-runtime/package.json +++ b/libs/native-federation-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@softarc/native-federation-runtime", - "version": "2.0.9", + "version": "2.0.10", "peerDependencies": {}, "dependencies": { "tslib": "^2.3.0" diff --git a/libs/native-federation/package.json b/libs/native-federation/package.json index 4b6ddc7..84102be 100644 --- a/libs/native-federation/package.json +++ b/libs/native-federation/package.json @@ -1,6 +1,6 @@ { "name": "@angular-architects/native-federation", - "version": "18.0.1", + "version": "18.1.0", "main": "src/index.js", "generators": "./collection.json", "builders": "./builders.json", @@ -20,8 +20,8 @@ }, "dependencies": { "@babel/core": "^7.19.0", - "@softarc/native-federation": "2.0.9", - "@softarc/native-federation-runtime": "2.0.9", + "@softarc/native-federation": "2.0.10", + "@softarc/native-federation-runtime": "2.0.10", "@types/browser-sync": "^2.29.0", "browser-sync": "^3.0.2", "esbuild": "^0.19.5", diff --git a/libs/native-federation/src/builders/build/builder.ts b/libs/native-federation/src/builders/build/builder.ts index 1b9100e..5dbe00e 100644 --- a/libs/native-federation/src/builders/build/builder.ts +++ b/libs/native-federation/src/builders/build/builder.ts @@ -127,6 +127,7 @@ export async function* runBuilder( const watch = !!runServer || nfOptions.watch; options.watch = watch; + options.baseHref = nfOptions.baseHref; const rebuildEvents = new RebuildHubs(); const adapter = createAngularBuildAdapter(options, context, rebuildEvents); diff --git a/libs/native-federation/src/builders/build/schema.d.ts b/libs/native-federation/src/builders/build/schema.d.ts index 1980f78..3fae81c 100644 --- a/libs/native-federation/src/builders/build/schema.d.ts +++ b/libs/native-federation/src/builders/build/schema.d.ts @@ -11,4 +11,5 @@ export interface NfBuilderSchema extends JsonObject { watch: boolean; skipHtmlTransform: boolean; esmsInitOptions: ESMSInitOptions; + baseHref?: string; } // eslint-disable-line diff --git a/libs/native-federation/src/builders/build/schema.json b/libs/native-federation/src/builders/build/schema.json index aaaff75..811c6b2 100644 --- a/libs/native-federation/src/builders/build/schema.json +++ b/libs/native-federation/src/builders/build/schema.json @@ -43,6 +43,9 @@ "type": "boolean", "default": false }, + "baseHref": { + "type": "string" + }, "esmsInitOptions": { "type": "object", "description": "Options for esms-module-shims https://github.com/guybedford/es-module-shims?tab=readme-ov-file#init-options",