@squide/firefly-webpack-configs 5.1.2 → 5.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @squide/firefly-webpack-configs
2
2
 
3
+ ## 5.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#339](https://github.com/workleap/wl-squide/pull/339) [`de6b333`](https://github.com/workleap/wl-squide/commit/de6b3335f538252bac9545d82c8f1218612eb923) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped packages version.
8
+
9
+ ## 5.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#332](https://github.com/workleap/wl-squide/pull/332) [`eb933a7`](https://github.com/workleap/wl-squide/commit/eb933a72514ff3e01f5d3dafa17556e1a07471f6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumpbed dependencies
14
+
3
15
  ## 5.1.2
4
16
 
5
17
  ### Patch Changes
@@ -15,7 +15,7 @@ export interface Features {
15
15
  environmentVariables?: boolean;
16
16
  honeycomb?: boolean;
17
17
  }
18
- export interface RemoteDefinition {
18
+ export interface RemoteDefinition extends Record<string, unknown> {
19
19
  name: string;
20
20
  url: string;
21
21
  }
@@ -171,7 +171,7 @@ function createSetUniqueNameTransformer(uniqueName) {
171
171
  return transformer;
172
172
  }
173
173
  function resolveEntryFilePath(entryPaths) {
174
- for(const entryPath in entryPaths){
174
+ for (const entryPath of entryPaths){
175
175
  if (node_fs.existsSync(node_path.resolve(applicationDirectory, entryPath))) {
176
176
  return entryPath;
177
177
  }
@@ -1 +1 @@
1
- {"version":3,"file":"defineConfig.js","sources":["webpack://@squide/firefly-webpack-configs/./src/defineConfig.ts"],"sourcesContent":["import { ModuleFederationPlugin } from \"@module-federation/enhanced/webpack\";\nimport type { SwcConfig } from \"@workleap/swc-configs\";\nimport { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineDevConfig, defineDevHtmlWebpackPluginConfig, type DefineBuildConfigOptions, type DefineDevConfigOptions, type WebpackConfig, type WebpackConfigTransformer } from \"@workleap/webpack-configs\";\nimport merge from \"deepmerge\";\nimport type HtmlWebpackPlugin from \"html-webpack-plugin\";\nimport fs from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport url, { fileURLToPath } from \"node:url\";\nimport type webpack from \"webpack\";\nimport { HostApplicationName } from \"./shared.ts\";\n\n// Using import.meta.url instead of import.meta.dirname because Jest is throwing the following error:\n// SyntaxError: Cannot use 'import.meta' outside a module\nconst applicationDirectory = dirname(fileURLToPath(import.meta.url));\nconst packageDirectory = url.fileURLToPath(new URL(\".\", import.meta.url));\n\n// Must be similar to the module name defined in @workleap/module-federation.\nconst RemoteRegisterModuleName = \"./register\";\nconst RemoteEntryPoint = \"remoteEntry.js\";\n\n// Webpack doesn't export ModuleFederationPlugin typings.\nexport type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];\nexport type ModuleFederationRemotesOption = ModuleFederationPluginOptions[\"remotes\"];\n\nexport type ModuleFederationRuntimePlugins = NonNullable<ModuleFederationPluginOptions[\"runtimePlugins\"]>;\nexport type ModuleFederationShared = NonNullable<ModuleFederationPluginOptions[\"shared\"]>;\n\n// Generally, only the host application should have eager dependencies.\n// For more informations about shared dependencies refer to: https://github.com/patricklafrance/wmf-versioning\nfunction getDefaultSharedDependencies(features: Features, isHost: boolean): ModuleFederationShared {\n return {\n \"react\": {\n singleton: true,\n eager: isHost ? true : undefined,\n // Fixed the warning when `react-i18next` is imported in any remote modules.\n // For more information, refer to: https://github.com/i18next/react-i18next/issues/1697#issuecomment-1821748226.\n requiredVersion: features.i18next ? false : undefined\n },\n \"react-dom\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/core\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/module-federation\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nexport type Router = \"react-router\";\n\nexport interface Features {\n router?: Router;\n msw?: boolean;\n i18next?: boolean;\n environmentVariables?: boolean;\n honeycomb?: boolean;\n}\n\n// Generally, only the host application should have eager dependencies.\n// For more informations about shared dependencies refer to: https://github.com/patricklafrance/wmf-versioning\nfunction getReactRouterSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"react-router\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/react-router\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getMswSharedDependency(isHost: boolean): ModuleFederationShared {\n return {\n \"@squide/msw\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getI18nextSharedDependency(isHost: boolean): ModuleFederationShared {\n return {\n \"i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n // Not adding as a shared dependency for the moment because it causes the following error:\n // Uncaught (in promise) TypeError: i18next_browser_languagedetector__WEBPACK_IMPORTED_MODULE_3__ is not a constructor\n // \"i18next-browser-languagedetector\": {\n // singleton: true,\n // eager: isHost ? true : undefined\n // },\n \"react-i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getEnvironmentVariablesSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"@squide/env-vars\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getHoneycombSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"@honeycombio/opentelemetry-web\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@opentelemetry/api\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@opentelemetry/auto-instrumentations-web\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/firefly-honeycomb\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getFeaturesDependencies(features: Features, isHost: boolean) {\n const {\n router = \"react-router\",\n msw = true,\n i18next,\n environmentVariables,\n honeycomb\n } = features;\n\n return {\n ...(router === \"react-router\" ? getReactRouterSharedDependencies(isHost) : {}),\n ...(msw ? getMswSharedDependency(isHost) : {}),\n ...(i18next ? getI18nextSharedDependency(isHost) : {}),\n ...(environmentVariables ? getEnvironmentVariablesSharedDependencies(isHost) : {}),\n ...(honeycomb ? getHoneycombSharedDependencies(isHost) : {})\n };\n}\n\nfunction resolveDefaultSharedDependencies(features: Features, isHost: boolean) {\n return {\n ...getDefaultSharedDependencies(features, isHost),\n ...getFeaturesDependencies(features, isHost)\n };\n}\n\nconst forceNamedChunkIdsTransformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n config.optimization = {\n ...(config.optimization ?? {}),\n // Without named chunk ids, there are some Webpack features that do not work\n // when used with Module Federation. One of these feature is using a dynamic import in\n // a remote module.\n chunkIds: \"named\"\n };\n\n return config;\n};\n\nfunction createSetUniqueNameTransformer(uniqueName: string) {\n const transformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n config.output = {\n ...(config.output ?? {}),\n // Every host and remotes must have a \"uniqueName\" for React Refresh to work\n // with Module Federation.\n uniqueName\n };\n\n return config;\n };\n\n return transformer;\n}\n\nfunction resolveEntryFilePath(entryPaths: string[]) {\n for (const entryPath in entryPaths) {\n if (fs.existsSync(path.resolve(applicationDirectory, entryPath))) {\n return entryPath;\n }\n }\n\n return entryPaths[0];\n}\n\n//////////////////////////// Host /////////////////////////////\n\nexport interface RemoteDefinition {\n // The name of the remote module.\n name: string;\n // The URL of the remote, ex: http://localhost:8081.\n url: string;\n}\n\nconst HostEntryFilePaths = [\n \"./src/index.ts\",\n \"./src/index.tsx\"\n];\n\nexport interface DefineHostModuleFederationPluginOptions extends ModuleFederationPluginOptions {\n features?: Features;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineHostModuleFederationPluginOptions(remotes: RemoteDefinition[], options: DefineHostModuleFederationPluginOptions): ModuleFederationPluginOptions {\n const {\n features = {},\n shared = {},\n runtimePlugins = [],\n ...rest\n } = options;\n\n const defaultSharedDependencies = resolveDefaultSharedDependencies(features, true);\n\n return {\n name: HostApplicationName,\n // Since Squide modules are only exporting a register function with a standardized API\n // it doesn't requires any typing.\n dts: false,\n // Currently only supporting .js remotes.\n manifest: false,\n remotes: remotes.reduce((acc, x) => {\n // Object reduce are always a mess for typings.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n acc[x.name] = `${x.name}@${x.url}/${RemoteEntryPoint}`;\n\n return acc;\n }, {}) as ModuleFederationRemotesOption,\n // Deep merging the default shared dependencies with the provided shared dependencies\n // to allow the consumer to easily override a default option of a shared dependency\n // without extending the whole default shared dependencies object.\n shared: merge.all([\n defaultSharedDependencies,\n shared\n ]) as ModuleFederationShared,\n runtimePlugins: [\n path.resolve(packageDirectory, \"./sharedDependenciesResolutionPlugin.js\"),\n path.resolve(packageDirectory, \"./nonCacheableRemoteEntryPlugin.js\"),\n ...runtimePlugins\n ],\n // Commented because it doesn't seems to work, the runtime is still embedded into remotes.\n // experiments: {\n // // The runtime is 100kb minified.\n // federationRuntime: \"hoisted\"\n // },\n ...rest\n };\n}\n\n// Fixing HMR and page reloads when using `publicPath: auto` either in the host or remotes webpack configuration.\n// Otherwise, when a nested page that belongs to a remote module is reloaded, an \"Unexpected token\" error will be thrown.\nfunction trySetHtmlWebpackPluginPublicPath(options: HtmlWebpackPlugin.Options) {\n if (!options.publicPath) {\n options.publicPath = \"/\";\n }\n\n return options;\n}\n\nexport interface DefineDevHostConfigOptions extends Omit<DefineDevConfigOptions, \"htmlWebpackPlugin\" | \"port\"> {\n htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineDevHostConfig(swcConfig: SwcConfig, port: number, remotes: RemoteDefinition[], options: DefineDevHostConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(HostEntryFilePaths),\n publicPath = \"auto\",\n cache,\n plugins = [],\n htmlWebpackPluginOptions,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineHostModuleFederationPluginOptions(remotes, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineDevConfig(swcConfig, {\n entry,\n port,\n publicPath,\n cache,\n htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineBuildHtmlWebpackPluginConfig()),\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n ...webpackOptions,\n transformers: [\n createSetUniqueNameTransformer(HostApplicationName),\n ...transformers\n ]\n });\n}\n\nexport interface DefineBuildHostConfigOptions extends Omit<DefineBuildConfigOptions, \"htmlWebpackPlugin\"> {\n htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineBuildHostConfig(swcConfig: SwcConfig, remotes: RemoteDefinition[], options: DefineBuildHostConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(HostEntryFilePaths),\n publicPath = \"auto\",\n plugins = [],\n htmlWebpackPluginOptions,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineHostModuleFederationPluginOptions(remotes, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineBuildConfig(swcConfig, {\n entry,\n publicPath,\n htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineDevHtmlWebpackPluginConfig()),\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n forceNamedChunkIdsTransformer,\n createSetUniqueNameTransformer(HostApplicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n\n//////////////////////////// Remote /////////////////////////////\n\nconst RemoteEntryFilePaths = [\n \"./src/register.tsx\",\n \"./src/register.ts\"\n];\n\nexport interface DefineRemoteModuleFederationPluginOptions extends ModuleFederationPluginOptions {\n features?: Features;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineRemoteModuleFederationPluginOptions(applicationName: string, options: DefineRemoteModuleFederationPluginOptions): ModuleFederationPluginOptions {\n const {\n features = {},\n exposes = {},\n shared = {},\n runtimePlugins = [],\n ...rest\n } = options;\n\n const defaultSharedDependencies = resolveDefaultSharedDependencies(features, false);\n\n return {\n name: applicationName,\n // Since Squide modules are only exporting a register function with a standardized API\n // it doesn't requires any typing.\n dts: false,\n // Currently only supporting .js remotes.\n manifest: false,\n filename: RemoteEntryPoint,\n exposes: {\n [RemoteRegisterModuleName]: \"./src/register\",\n ...exposes\n },\n // Deep merging the default shared dependencies with the provided shared dependencies\n // to allow the consumer to easily override a default option of a shared dependency\n // without extending the whole default shared dependencies object.\n shared: merge.all([\n defaultSharedDependencies,\n shared\n ]) as ModuleFederationShared,\n runtimePlugins: [\n path.resolve(packageDirectory, \"./sharedDependenciesResolutionPlugin.js\"),\n path.resolve(packageDirectory, \"./nonCacheableRemoteEntryPlugin.js\"),\n ...runtimePlugins\n ],\n // Commented because it doesn't seems to work, the runtime is still embedded into remotes.\n // experiments: {\n // // The runtime is 100kb minified.\n // federationRuntime: \"hoisted\"\n // },\n ...rest\n };\n}\n\nconst devRemoteModuleTransformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n // \"config.devServer\" does exist but webpack types are a messed. It could probably be solved by importing \"webpack-dev-server\"\n // but I would prefer not adding it as a project dependency.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config.devServer.headers = {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n ...(config.devServer.headers ?? {}),\n // Otherwise hot reload in the host failed with a CORS error.\n \"Access-Control-Allow-Origin\": \"*\"\n };\n\n return config;\n};\n\nexport interface DefineDevRemoteModuleConfigOptions extends Omit<DefineDevConfigOptions, \"port\" | \"overlay\"> {\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineDevRemoteModuleConfig(swcConfig: SwcConfig, applicationName: string, port: number, options: DefineDevRemoteModuleConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(RemoteEntryFilePaths),\n publicPath = \"auto\",\n cache,\n plugins = [],\n htmlWebpackPlugin = false,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineRemoteModuleFederationPluginOptions(applicationName, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineDevConfig(swcConfig, {\n entry,\n port,\n publicPath,\n cache,\n htmlWebpackPlugin,\n // Disable the error overlay by default for remotes as otherwise every remote module's error overlay will be\n // stack on top of the host application's error overlay.\n overlay: false,\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n devRemoteModuleTransformer,\n createSetUniqueNameTransformer(applicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n\nexport interface DefineBuildRemoteModuleConfigOptions extends DefineBuildConfigOptions {\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineBuildRemoteModuleConfig(swcConfig: SwcConfig, applicationName: string, options: DefineBuildRemoteModuleConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(RemoteEntryFilePaths),\n publicPath = \"auto\",\n plugins = [],\n htmlWebpackPlugin = false,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineRemoteModuleFederationPluginOptions(applicationName, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineBuildConfig(swcConfig, {\n entry,\n publicPath,\n htmlWebpackPlugin,\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n forceNamedChunkIdsTransformer,\n createSetUniqueNameTransformer(applicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n"],"names":["ModuleFederationPlugin","defineBuildConfig","defineBuildHtmlWebpackPluginConfig","defineDevConfig","defineDevHtmlWebpackPluginConfig","merge","fs","path","dirname","url","fileURLToPath","HostApplicationName","applicationDirectory","packageDirectory","URL","RemoteRegisterModuleName","RemoteEntryPoint","getDefaultSharedDependencies","features","isHost","undefined","getReactRouterSharedDependencies","getMswSharedDependency","getI18nextSharedDependency","getEnvironmentVariablesSharedDependencies","getHoneycombSharedDependencies","getFeaturesDependencies","router","msw","i18next","environmentVariables","honeycomb","resolveDefaultSharedDependencies","forceNamedChunkIdsTransformer","config","createSetUniqueNameTransformer","uniqueName","transformer","resolveEntryFilePath","entryPaths","entryPath","HostEntryFilePaths","defineHostModuleFederationPluginOptions","remotes","options","shared","runtimePlugins","rest","defaultSharedDependencies","acc","x","trySetHtmlWebpackPluginPublicPath","defineDevHostConfig","swcConfig","port","entry","publicPath","cache","plugins","htmlWebpackPluginOptions","transformers","sharedDependencies","moduleFederationPluginOptions","webpackOptions","defineBuildHostConfig","RemoteEntryFilePaths","defineRemoteModuleFederationPluginOptions","applicationName","exposes","devRemoteModuleTransformer","defineDevRemoteModuleConfig","htmlWebpackPlugin","defineBuildRemoteModuleConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA6E;AAEuL;AACtO;AAEL;AACiB;AACI;AAEI;AAElD,qGAAqG;AACrG,yDAAyD;AACzD,MAAMY,uBAAuB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C,QAAQ,EACR2C,kBAAkB,EAClBf,cAAc,EACdgB,gCAAgCI,0CAA0CC,iBAAiB;QAAEjD;QAAU,QAAQ2C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAOzC,eAAeA,CAACkD,WAAW;QAC9BE;QACAD;QACAE;QACAC;QACAc;QACA,4GAA4G;QAC5G,wDAAwD;QACxD,SAAS;QACT,SAAS;eACFb;YACH,IAAI1D,sBAAsBA,CAAC8D;SAC9B;QACD,cAAc;YACVO;YACAlC,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ;AASA,2EAA2E;AACpE,SAASS,8BAA8BnB,SAAoB,EAAEc,eAAuB,EAAEvB,UAAgD,CAAC,CAAC;IAC3I,MAAM,EACFW,QAAQjB,qBAAqB2B,qBAAqB,EAClDT,aAAa,MAAM,EACnBE,UAAU,EAAE,EACZa,oBAAoB,KAAK,EACzBX,eAAe,EAAE,EACjB1C,QAAQ,EACR2C,kBAAkB,EAClBf,cAAc,EACdgB,gCAAgCI,0CAA0CC,iBAAiB;QAAEjD;QAAU,QAAQ2C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAO3C,iBAAiBA,CAACoD,WAAW;QAChCE;QACAC;QACAe;QACA,SAAS;eACFb;YACH,IAAI1D,sBAAsBA,CAAC8D;SAC9B;QACD,cAAc;YACV7B;YACAE,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ"}
1
+ {"version":3,"file":"defineConfig.js","sources":["../src/defineConfig.ts"],"sourcesContent":["import { ModuleFederationPlugin } from \"@module-federation/enhanced/webpack\";\nimport type { SwcConfig } from \"@workleap/swc-configs\";\nimport { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineDevConfig, defineDevHtmlWebpackPluginConfig, type DefineBuildConfigOptions, type DefineDevConfigOptions, type WebpackConfig, type WebpackConfigTransformer } from \"@workleap/webpack-configs\";\nimport merge from \"deepmerge\";\nimport type HtmlWebpackPlugin from \"html-webpack-plugin\";\nimport fs from \"node:fs\";\nimport path, { dirname } from \"node:path\";\nimport url, { fileURLToPath } from \"node:url\";\nimport type webpack from \"webpack\";\nimport { HostApplicationName } from \"./shared.ts\";\n\n// Using import.meta.url instead of import.meta.dirname because Jest is throwing the following error:\n// SyntaxError: Cannot use 'import.meta' outside a module\nconst applicationDirectory = dirname(fileURLToPath(import.meta.url));\nconst packageDirectory = url.fileURLToPath(new URL(\".\", import.meta.url));\n\n// Must be similar to the module name defined in @workleap/module-federation.\nconst RemoteRegisterModuleName = \"./register\";\nconst RemoteEntryPoint = \"remoteEntry.js\";\n\n// Webpack doesn't export ModuleFederationPlugin typings.\nexport type ModuleFederationPluginOptions = ConstructorParameters<typeof ModuleFederationPlugin>[0];\nexport type ModuleFederationRemotesOption = ModuleFederationPluginOptions[\"remotes\"];\n\nexport type ModuleFederationRuntimePlugins = NonNullable<ModuleFederationPluginOptions[\"runtimePlugins\"]>;\nexport type ModuleFederationShared = NonNullable<ModuleFederationPluginOptions[\"shared\"]>;\n\n// Generally, only the host application should have eager dependencies.\n// For more informations about shared dependencies refer to: https://github.com/patricklafrance/wmf-versioning\nfunction getDefaultSharedDependencies(features: Features, isHost: boolean): ModuleFederationShared {\n return {\n \"react\": {\n singleton: true,\n eager: isHost ? true : undefined,\n // Fixed the warning when `react-i18next` is imported in any remote modules.\n // For more information, refer to: https://github.com/i18next/react-i18next/issues/1697#issuecomment-1821748226.\n requiredVersion: features.i18next ? false : undefined\n },\n \"react-dom\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/core\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/module-federation\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nexport type Router = \"react-router\";\n\nexport interface Features {\n router?: Router;\n msw?: boolean;\n i18next?: boolean;\n environmentVariables?: boolean;\n honeycomb?: boolean;\n}\n\n// Generally, only the host application should have eager dependencies.\n// For more informations about shared dependencies refer to: https://github.com/patricklafrance/wmf-versioning\nfunction getReactRouterSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"react-router\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/react-router\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getMswSharedDependency(isHost: boolean): ModuleFederationShared {\n return {\n \"@squide/msw\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getI18nextSharedDependency(isHost: boolean): ModuleFederationShared {\n return {\n \"i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n // Not adding as a shared dependency for the moment because it causes the following error:\n // Uncaught (in promise) TypeError: i18next_browser_languagedetector__WEBPACK_IMPORTED_MODULE_3__ is not a constructor\n // \"i18next-browser-languagedetector\": {\n // singleton: true,\n // eager: isHost ? true : undefined\n // },\n \"react-i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/i18next\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getEnvironmentVariablesSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"@squide/env-vars\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getHoneycombSharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"@honeycombio/opentelemetry-web\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@opentelemetry/api\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@opentelemetry/auto-instrumentations-web\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"@squide/firefly-honeycomb\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getFeaturesDependencies(features: Features, isHost: boolean) {\n const {\n router = \"react-router\",\n msw = true,\n i18next,\n environmentVariables,\n honeycomb\n } = features;\n\n return {\n ...(router === \"react-router\" ? getReactRouterSharedDependencies(isHost) : {}),\n ...(msw ? getMswSharedDependency(isHost) : {}),\n ...(i18next ? getI18nextSharedDependency(isHost) : {}),\n ...(environmentVariables ? getEnvironmentVariablesSharedDependencies(isHost) : {}),\n ...(honeycomb ? getHoneycombSharedDependencies(isHost) : {})\n };\n}\n\nfunction resolveDefaultSharedDependencies(features: Features, isHost: boolean) {\n return {\n ...getDefaultSharedDependencies(features, isHost),\n ...getFeaturesDependencies(features, isHost)\n };\n}\n\nconst forceNamedChunkIdsTransformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n config.optimization = {\n ...(config.optimization ?? {}),\n // Without named chunk ids, there are some Webpack features that do not work\n // when used with Module Federation. One of these feature is using a dynamic import in\n // a remote module.\n chunkIds: \"named\"\n };\n\n return config;\n};\n\nfunction createSetUniqueNameTransformer(uniqueName: string) {\n const transformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n config.output = {\n ...(config.output ?? {}),\n // Every host and remotes must have a \"uniqueName\" for React Refresh to work\n // with Module Federation.\n uniqueName\n };\n\n return config;\n };\n\n return transformer;\n}\n\nfunction resolveEntryFilePath(entryPaths: string[]) {\n for (const entryPath of entryPaths) {\n if (fs.existsSync(path.resolve(applicationDirectory, entryPath))) {\n return entryPath;\n }\n }\n\n return entryPaths[0];\n}\n\n//////////////////////////// Host /////////////////////////////\n\nexport interface RemoteDefinition extends Record<string, unknown> {\n // The name of the remote module.\n name: string;\n // The URL of the remote, ex: http://localhost:8081.\n url: string;\n}\n\nconst HostEntryFilePaths = [\n \"./src/index.ts\",\n \"./src/index.tsx\"\n];\n\nexport interface DefineHostModuleFederationPluginOptions extends ModuleFederationPluginOptions {\n features?: Features;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineHostModuleFederationPluginOptions(remotes: RemoteDefinition[], options: DefineHostModuleFederationPluginOptions): ModuleFederationPluginOptions {\n const {\n features = {},\n shared = {},\n runtimePlugins = [],\n ...rest\n } = options;\n\n const defaultSharedDependencies = resolveDefaultSharedDependencies(features, true);\n\n return {\n name: HostApplicationName,\n // Since Squide modules are only exporting a register function with a standardized API\n // it doesn't requires any typing.\n dts: false,\n // Currently only supporting .js remotes.\n manifest: false,\n remotes: remotes.reduce((acc, x) => {\n // Object reduce are always a mess for typings.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n acc[x.name] = `${x.name}@${x.url}/${RemoteEntryPoint}`;\n\n return acc;\n }, {}) as ModuleFederationRemotesOption,\n // Deep merging the default shared dependencies with the provided shared dependencies\n // to allow the consumer to easily override a default option of a shared dependency\n // without extending the whole default shared dependencies object.\n shared: merge.all([\n defaultSharedDependencies,\n shared\n ]) as ModuleFederationShared,\n runtimePlugins: [\n path.resolve(packageDirectory, \"./sharedDependenciesResolutionPlugin.js\"),\n path.resolve(packageDirectory, \"./nonCacheableRemoteEntryPlugin.js\"),\n ...runtimePlugins\n ],\n // Commented because it doesn't seems to work, the runtime is still embedded into remotes.\n // experiments: {\n // // The runtime is 100kb minified.\n // federationRuntime: \"hoisted\"\n // },\n ...rest\n };\n}\n\n// Fixing HMR and page reloads when using `publicPath: auto` either in the host or remotes webpack configuration.\n// Otherwise, when a nested page that belongs to a remote module is reloaded, an \"Unexpected token\" error will be thrown.\nfunction trySetHtmlWebpackPluginPublicPath(options: HtmlWebpackPlugin.Options) {\n if (!options.publicPath) {\n options.publicPath = \"/\";\n }\n\n return options;\n}\n\nexport interface DefineDevHostConfigOptions extends Omit<DefineDevConfigOptions, \"htmlWebpackPlugin\" | \"port\"> {\n htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineDevHostConfig(swcConfig: SwcConfig, port: number, remotes: RemoteDefinition[], options: DefineDevHostConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(HostEntryFilePaths),\n publicPath = \"auto\",\n cache,\n plugins = [],\n htmlWebpackPluginOptions,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineHostModuleFederationPluginOptions(remotes, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineDevConfig(swcConfig, {\n entry,\n port,\n publicPath,\n cache,\n htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineBuildHtmlWebpackPluginConfig()),\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n ...webpackOptions,\n transformers: [\n createSetUniqueNameTransformer(HostApplicationName),\n ...transformers\n ]\n });\n}\n\nexport interface DefineBuildHostConfigOptions extends Omit<DefineBuildConfigOptions, \"htmlWebpackPlugin\"> {\n htmlWebpackPluginOptions?: HtmlWebpackPlugin.Options;\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineBuildHostConfig(swcConfig: SwcConfig, remotes: RemoteDefinition[], options: DefineBuildHostConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(HostEntryFilePaths),\n publicPath = \"auto\",\n plugins = [],\n htmlWebpackPluginOptions,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineHostModuleFederationPluginOptions(remotes, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineBuildConfig(swcConfig, {\n entry,\n publicPath,\n htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineDevHtmlWebpackPluginConfig()),\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n forceNamedChunkIdsTransformer,\n createSetUniqueNameTransformer(HostApplicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n\n//////////////////////////// Remote /////////////////////////////\n\nconst RemoteEntryFilePaths = [\n \"./src/register.tsx\",\n \"./src/register.ts\"\n];\n\nexport interface DefineRemoteModuleFederationPluginOptions extends ModuleFederationPluginOptions {\n features?: Features;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineRemoteModuleFederationPluginOptions(applicationName: string, options: DefineRemoteModuleFederationPluginOptions): ModuleFederationPluginOptions {\n const {\n features = {},\n exposes = {},\n shared = {},\n runtimePlugins = [],\n ...rest\n } = options;\n\n const defaultSharedDependencies = resolveDefaultSharedDependencies(features, false);\n\n return {\n name: applicationName,\n // Since Squide modules are only exporting a register function with a standardized API\n // it doesn't requires any typing.\n dts: false,\n // Currently only supporting .js remotes.\n manifest: false,\n filename: RemoteEntryPoint,\n exposes: {\n [RemoteRegisterModuleName]: \"./src/register\",\n ...exposes\n },\n // Deep merging the default shared dependencies with the provided shared dependencies\n // to allow the consumer to easily override a default option of a shared dependency\n // without extending the whole default shared dependencies object.\n shared: merge.all([\n defaultSharedDependencies,\n shared\n ]) as ModuleFederationShared,\n runtimePlugins: [\n path.resolve(packageDirectory, \"./sharedDependenciesResolutionPlugin.js\"),\n path.resolve(packageDirectory, \"./nonCacheableRemoteEntryPlugin.js\"),\n ...runtimePlugins\n ],\n // Commented because it doesn't seems to work, the runtime is still embedded into remotes.\n // experiments: {\n // // The runtime is 100kb minified.\n // federationRuntime: \"hoisted\"\n // },\n ...rest\n };\n}\n\nconst devRemoteModuleTransformer: WebpackConfigTransformer = (config: WebpackConfig) => {\n // \"config.devServer\" does exist but webpack types are a messed. It could probably be solved by importing \"webpack-dev-server\"\n // but I would prefer not adding it as a project dependency.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config.devServer.headers = {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n ...(config.devServer.headers ?? {}),\n // Otherwise hot reload in the host failed with a CORS error.\n \"Access-Control-Allow-Origin\": \"*\"\n };\n\n return config;\n};\n\nexport interface DefineDevRemoteModuleConfigOptions extends Omit<DefineDevConfigOptions, \"port\" | \"overlay\"> {\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineDevRemoteModuleConfig(swcConfig: SwcConfig, applicationName: string, port: number, options: DefineDevRemoteModuleConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(RemoteEntryFilePaths),\n publicPath = \"auto\",\n cache,\n plugins = [],\n htmlWebpackPlugin = false,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineRemoteModuleFederationPluginOptions(applicationName, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineDevConfig(swcConfig, {\n entry,\n port,\n publicPath,\n cache,\n htmlWebpackPlugin,\n // Disable the error overlay by default for remotes as otherwise every remote module's error overlay will be\n // stack on top of the host application's error overlay.\n overlay: false,\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n devRemoteModuleTransformer,\n createSetUniqueNameTransformer(applicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n\nexport interface DefineBuildRemoteModuleConfigOptions extends DefineBuildConfigOptions {\n features?: Features;\n sharedDependencies?: ModuleFederationShared;\n runtimePlugins?: ModuleFederationRuntimePlugins;\n moduleFederationPluginOptions?: ModuleFederationPluginOptions;\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function defineBuildRemoteModuleConfig(swcConfig: SwcConfig, applicationName: string, options: DefineBuildRemoteModuleConfigOptions = {}): webpack.Configuration {\n const {\n entry = resolveEntryFilePath(RemoteEntryFilePaths),\n publicPath = \"auto\",\n plugins = [],\n htmlWebpackPlugin = false,\n transformers = [],\n features,\n sharedDependencies,\n runtimePlugins,\n moduleFederationPluginOptions = defineRemoteModuleFederationPluginOptions(applicationName, { features, shared: sharedDependencies, runtimePlugins }),\n ...webpackOptions\n } = options;\n\n return defineBuildConfig(swcConfig, {\n entry,\n publicPath,\n htmlWebpackPlugin,\n plugins: [\n ...plugins,\n new ModuleFederationPlugin(moduleFederationPluginOptions)\n ],\n transformers: [\n forceNamedChunkIdsTransformer,\n createSetUniqueNameTransformer(applicationName),\n ...transformers\n ],\n ...webpackOptions\n });\n}\n"],"names":["ModuleFederationPlugin","defineBuildConfig","defineBuildHtmlWebpackPluginConfig","defineDevConfig","defineDevHtmlWebpackPluginConfig","merge","fs","path","dirname","url","fileURLToPath","HostApplicationName","applicationDirectory","packageDirectory","URL","RemoteRegisterModuleName","RemoteEntryPoint","getDefaultSharedDependencies","features","isHost","undefined","getReactRouterSharedDependencies","getMswSharedDependency","getI18nextSharedDependency","getEnvironmentVariablesSharedDependencies","getHoneycombSharedDependencies","getFeaturesDependencies","router","msw","i18next","environmentVariables","honeycomb","resolveDefaultSharedDependencies","forceNamedChunkIdsTransformer","config","createSetUniqueNameTransformer","uniqueName","transformer","resolveEntryFilePath","entryPaths","entryPath","HostEntryFilePaths","defineHostModuleFederationPluginOptions","remotes","options","shared","runtimePlugins","rest","defaultSharedDependencies","acc","x","trySetHtmlWebpackPluginPublicPath","defineDevHostConfig","swcConfig","port","entry","publicPath","cache","plugins","htmlWebpackPluginOptions","transformers","sharedDependencies","moduleFederationPluginOptions","webpackOptions","defineBuildHostConfig","RemoteEntryFilePaths","defineRemoteModuleFederationPluginOptions","applicationName","exposes","devRemoteModuleTransformer","defineDevRemoteModuleConfig","htmlWebpackPlugin","defineBuildRemoteModuleConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA6E;AAEuL;AACtO;AAEL;AACiB;AACI;AAEI;AAElD,qGAAqG;AACrG,yDAAyD;AACzD,MAAMY,uBAAuBJ,OAAOA,CAACE,aAAaA,CAAC,YAAY,GAAG;AAClE,MAAMG,mBAAmBJ,s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AAiB;QAAEjD;QAAU,QAAQ2C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAOzC,eAAeA,CAACkD,WAAW;QAC9BE;QACAD;QACAE;QACAC;QACAc;QACA,4GAA4G;QAC5G,wDAAwD;QACxD,SAAS;QACT,SAAS;eACFb;YACH,IAAI1D,sBAAsBA,CAAC8D;SAC9B;QACD,cAAc;YACVO;YACAlC,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ;AASA,2EAA2E;AACpE,SAASS,8BAA8BnB,SAAoB,EAAEc,eAAuB,EAAEvB,UAAgD,CAAC,CAAC;IAC3I,MAAM,EACFW,QAAQjB,qBAAqB2B,qBAAqB,EAClDT,aAAa,MAAM,EACnBE,UAAU,EAAE,EACZa,oBAAoB,KAAK,EACzBX,eAAe,EAAE,EACjB1C,QAAQ,EACR2C,kBAAkB,EAClBf,cAAc,EACdgB,gCAAgCI,0CAA0CC,iBAAiB;QAAEjD;QAAU,QAAQ2C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAO3C,iBAAiBA,CAACoD,WAAW;QAChCE;QACAC;QACAe;QACA,SAAS;eACFb;YACH,IAAI1D,sBAAsBA,CAAC8D;SAC9B;QACD,cAAc;YACV7B;YACAE,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from "@workleap/webpack-configs";
2
- export * from "./defineConfig.ts";
2
+ export { defineBuildHostConfig, defineBuildRemoteModuleConfig, defineDevHostConfig, defineDevRemoteModuleConfig, defineHostModuleFederationPluginOptions, defineRemoteModuleFederationPluginOptions, type DefineBuildHostConfigOptions, type DefineBuildRemoteModuleConfigOptions, type DefineDevHostConfigOptions, type DefineDevRemoteModuleConfigOptions, type DefineHostModuleFederationPluginOptions, type DefineRemoteModuleFederationPluginOptions, type Features, type ModuleFederationPluginOptions, type ModuleFederationRemotesOption, type ModuleFederationRuntimePlugins, type ModuleFederationShared, type RemoteDefinition, type Router } from "./defineConfig.ts";
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
+ import { defineBuildHostConfig, defineBuildRemoteModuleConfig, defineDevHostConfig, defineDevRemoteModuleConfig, defineHostModuleFederationPluginOptions, defineRemoteModuleFederationPluginOptions } from "./defineConfig.js";
1
2
  export * from "@workleap/webpack-configs";
2
- export * from "./defineConfig.js";
3
+
4
+ ;// CONCATENATED MODULE: external "./defineConfig.js"
3
5
 
4
6
  ;// CONCATENATED MODULE: ./src/index.ts
5
7
 
6
8
 
7
9
 
10
+ export { defineBuildHostConfig, defineBuildRemoteModuleConfig, defineDevHostConfig, defineDevRemoteModuleConfig, defineHostModuleFederationPluginOptions, defineRemoteModuleFederationPluginOptions };
8
11
 
9
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["webpack://@squide/firefly-webpack-configs/./src/index.ts"],"sourcesContent":["export * from \"@workleap/webpack-configs\";\nexport * from \"./defineConfig.ts\";\n\n"],"names":[],"mappings":";;;;AAA0C;AACR"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"@workleap/webpack-configs\";\nexport {\n defineBuildHostConfig,\n defineBuildRemoteModuleConfig,\n defineDevHostConfig,\n defineDevRemoteModuleConfig,\n defineHostModuleFederationPluginOptions,\n defineRemoteModuleFederationPluginOptions,\n type DefineBuildHostConfigOptions,\n type DefineBuildRemoteModuleConfigOptions,\n type DefineDevHostConfigOptions,\n type DefineDevRemoteModuleConfigOptions,\n type DefineHostModuleFederationPluginOptions,\n type DefineRemoteModuleFederationPluginOptions,\n type Features,\n type ModuleFederationPluginOptions,\n type ModuleFederationRemotesOption,\n type ModuleFederationRuntimePlugins,\n type ModuleFederationShared,\n type RemoteDefinition,\n type Router\n} from \"./defineConfig.ts\";\n\n"],"names":["defineBuildHostConfig","defineBuildRemoteModuleConfig","defineDevHostConfig","defineDevRemoteModuleConfig","defineHostModuleFederationPluginOptions","defineRemoteModuleFederationPluginOptions"],"mappings":";;;;;;AAA0C;AAqBf"}
@@ -14,7 +14,7 @@ const nonCacheableRemoteEntryPlugin_plugin = ()=>{
14
14
  }
15
15
  };
16
16
  };
17
- /* ESM default export */ const nonCacheableRemoteEntryPlugin = (nonCacheableRemoteEntryPlugin_plugin);
17
+ /* export default */ const nonCacheableRemoteEntryPlugin = (nonCacheableRemoteEntryPlugin_plugin);
18
18
 
19
19
  export { nonCacheableRemoteEntryPlugin as default };
20
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"nonCacheableRemoteEntryPlugin.js","sources":["webpack://@squide/firefly-webpack-configs/./src/nonCacheableRemoteEntryPlugin.ts"],"sourcesContent":["import type { FederationRuntimePlugin } from \"@module-federation/enhanced/runtime\";\n\nconst plugin: () => FederationRuntimePlugin = () => {\n return {\n name: \"non-cacheable-remote-entry-plugin\",\n createScript: function({ url }) {\n const element = document.createElement(\"script\");\n\n // Adding a timestamp to make sure the remote entry points are never cached.\n // View: https://github.com/module-federation/module-federation-examples/issues/566.\n element.src = `${url}?t=${Date.now()}`;\n element.type = \"text/javascript\";\n element.async = true;\n\n return element;\n }\n };\n};\n\nexport default plugin;\n"],"names":["plugin","url","element","document","Date"],"mappings":";;AAEA,MAAMA,oCAAMA,GAAkC;IAC1C,OAAO;QACH,MAAM;QACN,cAAc,SAAS,EAAEC,GAAG,EAAE;YAC1B,MAAMC,UAAUC,SAAS,aAAa,CAAC;YAEvC,4EAA4E;YAC5E,oFAAoF;YACpFD,QAAQ,GAAG,GAAG,GAAGD,IAAI,GAAG,EAAEG,KAAK,GAAG,IAAI;YACtCF,QAAQ,IAAI,GAAG;YACfA,QAAQ,KAAK,GAAG;YAEhB,OAAOA;QACX;IACJ;AACJ;AAEA,gEAAeF,oCAAMA,EAAC"}
1
+ {"version":3,"file":"nonCacheableRemoteEntryPlugin.js","sources":["../src/nonCacheableRemoteEntryPlugin.ts"],"sourcesContent":["import type { FederationRuntimePlugin } from \"@module-federation/enhanced/runtime\";\n\nconst plugin: () => FederationRuntimePlugin = () => {\n return {\n name: \"non-cacheable-remote-entry-plugin\",\n createScript: function({ url }) {\n const element = document.createElement(\"script\");\n\n // Adding a timestamp to make sure the remote entry points are never cached.\n // View: https://github.com/module-federation/module-federation-examples/issues/566.\n element.src = `${url}?t=${Date.now()}`;\n element.type = \"text/javascript\";\n element.async = true;\n\n return element;\n }\n };\n};\n\nexport default plugin;\n"],"names":["plugin","url","element","document","Date"],"mappings":";;AAEA,MAAMA,oCAAMA,GAAkC;IAC1C,OAAO;QACH,MAAM;QACN,cAAc,SAAS,EAAEC,GAAG,EAAE;YAC1B,MAAMC,UAAUC,SAAS,aAAa,CAAC;YAEvC,4EAA4E;YAC5E,oFAAoF;YACpFD,QAAQ,GAAG,GAAG,GAAGD,IAAI,GAAG,EAAEG,KAAK,GAAG,IAAI;YACtCF,QAAQ,IAAI,GAAG;YACfA,QAAQ,KAAK,GAAG;YAEhB,OAAOA;QACX;IACJ;AACJ;AAEA,4DAAeF,oCAAMA,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sources":["webpack://@squide/firefly-webpack-configs/./src/shared.ts"],"sourcesContent":["// Hardcoded to \"host\" because of the \"sharedDependenciesResolutionPlugin\" plugin.\nexport const HostApplicationName = \"host\";\n"],"names":["HostApplicationName"],"mappings":";;AAAA,kFAAkF;AAC3E,MAAMA,sBAAsB,OAAO"}
1
+ {"version":3,"file":"shared.js","sources":["../src/shared.ts"],"sourcesContent":["// Hardcoded to \"host\" because of the \"sharedDependenciesResolutionPlugin\" plugin.\nexport const HostApplicationName = \"host\";\n"],"names":["HostApplicationName"],"mappings":";;AAAA,kFAAkF;AAC3E,MAAMA,sBAAsB,OAAO"}
@@ -104,7 +104,7 @@ const sharedDependenciesResolutionPlugin_plugin = ()=>{
104
104
  return(// Temporary check until all the remotes on Webpack Module Federation has been updated to Module Federation 2.0.
105
105
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
106
106
  // @ts-ignore
107
- x.singleton || x.shareConfig && x.shareConfig.singleton);
107
+ x.singleton || x.shareConfig?.singleton);
108
108
  });
109
109
  // Not a singleton dependency.
110
110
  if (entries.length === 0) {
@@ -121,7 +121,6 @@ const sharedDependenciesResolutionPlugin_plugin = ()=>{
121
121
  log(`[squide] There's %cmore than one requested version%c for ${pkgName}:`, "color: black; background-color: pink;", "", entries.length, shareScopeMap[scope][pkgName]);
122
122
  const { resolvedEntry, highestVersionEntry } = resolveSharedDependency(pkgName, entries, log);
123
123
  if (resolvedEntry.version !== highestVersionEntry.version) {
124
- // eslint-disable-next-line max-len
125
124
  console.log(`%c[squide] "${highestVersionEntry.from}" requested version "${highestVersionEntry.version}" of "${pkgName}". This version is higher than the major number of the version requested by the host for this dependency (${resolvedEntry.version}). The version for "${pkgName}" has been forced to "${resolvedEntry.version}".`, "color: white; background-color: red;");
126
125
  }
127
126
  return resolvedEntry;
@@ -130,7 +129,7 @@ const sharedDependenciesResolutionPlugin_plugin = ()=>{
130
129
  }
131
130
  };
132
131
  };
133
- /* ESM default export */ const sharedDependenciesResolutionPlugin = (sharedDependenciesResolutionPlugin_plugin);
132
+ /* export default */ const sharedDependenciesResolutionPlugin = (sharedDependenciesResolutionPlugin_plugin);
134
133
 
135
134
  export { sharedDependenciesResolutionPlugin as default, resolveSharedDependency };
136
135
 
@@ -1 +1 @@
1
- {"version":3,"file":"sharedDependenciesResolutionPlugin.js","sources":["webpack://@squide/firefly-webpack-configs/./src/sharedDependenciesResolutionPlugin.ts"],"sourcesContent":["/*\nThis custom share dependency resolution strategy ensure that only the host app can ask for a new major version of a library.\nOtherwise, any remote can request for an higher non-major version.\n\nExamples:\n\nhost: 2.0\nremote-1: 2.1 <-----\nremote-2: 2.0\n\nhost: 2.0 <-----\nremote-1: 3.1\nremote-2: 2.0\n\nhost: 2.0\nremote-1: 3.1\nremote-2: 2.1 <-----\n\nhost: >2.0\nremote-1: 3.1\nremote-2: 2.1 <-----\n*/\n\nimport type { FederationHost, FederationRuntimePlugin } from \"@module-federation/enhanced/runtime\";\nimport { minVersion, parse, rcompare, type SemVer } from \"semver\";\nimport { HostApplicationName } from \"./shared.ts\";\n\ntype Shared = FederationHost[\"shareScopeMap\"][string][string][string];\n\n// Toggle to \"true\" to facilitate the debugging of this plugin.\nconst isDebug = false;\n\nfunction log(...args: unknown[]) {\n if (isDebug) {\n console.log(...args);\n }\n}\n\nfunction findHighestVersionForMajor(entries: Shared[], major: number) {\n return entries.find(x => {\n return parse(x.version)!.major === major;\n }) as Shared;\n}\n\ninterface ResolveSharedDependencyResult {\n resolvedEntry: Shared;\n highestVersionEntry: Shared;\n}\n\n// The return type is required otherwise we get the following error: error TS2742: The inferred type of 'resolveSharedDependency' cannot be named without a reference to.\nexport function resolveSharedDependency(pkgName: string, entries: Shared[], logFct: (...rest: unknown[]) => void = () => {}): ResolveSharedDependencyResult {\n const cleanedEntries = entries.map(x => ({\n ...x,\n // Removing any special characters like >,>=,^,~ etc...\n version: minVersion(x.version)!.version\n }));\n\n // From higher to lower versions.\n const sortedEntries = cleanedEntries.sort((x, y) => rcompare(x.version, y.version));\n\n logFct(\"[squide] Sorted the entries by version from higher to lower\", sortedEntries);\n\n const highestVersionEntry = sortedEntries[0];\n\n logFct(`[squide] ${pkgName} highest requested version is`, highestVersionEntry.version, highestVersionEntry);\n\n // The host is always right!\n if (highestVersionEntry.from === HostApplicationName) {\n logFct(\"[squide] %cThis is the host version%c, great, resolving to:\", \"color: black; background-color: pink;\", \"\", highestVersionEntry.version, highestVersionEntry);\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(`[squide] ${pkgName} Highest requested version is not from the host.`);\n\n const hostEntry = sortedEntries.find(x => x.from === HostApplicationName);\n\n // Found nothing, that's odd but let's not break the app for this.\n if (!hostEntry) {\n logFct(`[squide] The host is not requesting any version of ${pkgName}, %caborting%c.`, \"color: black; background-color: pink;\", \"\");\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(`[squide] ${pkgName} version requested by the host is:`, hostEntry.version, hostEntry);\n\n const parsedHighestVersion = parse(highestVersionEntry.version) as SemVer;\n const parsedHostVersion = parse(hostEntry.version) as SemVer;\n\n // Major versions should always be introduced by the host application.\n if (parsedHighestVersion.major === parsedHostVersion.major) {\n logFct(`[squide] Resolving to %c${parsedHighestVersion.major}%c.`, \"color: black; background-color: pink;\", \"\");\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(\"[squide] The major number of the highest requested version is higher than the major number of the version requested by the host, looking for another version to resolve to.\");\n\n // Start at the second entry since the first entry is the current higher version entry.\n // The result could either be the actual host entry or any other entry that is higher than the version requested\n // by the host, but match the host entry major version number.\n const fallbackEntry = findHighestVersionForMajor(sortedEntries.splice(1), parsedHostVersion.major);\n\n logFct(`[squide] The %chighest requested version%c for ${pkgName} that is in-range with the requested host major version number is:`, \"color: black; background-color: pink;\", \"\", fallbackEntry.version, fallbackEntry);\n\n return {\n resolvedEntry: fallbackEntry,\n highestVersionEntry: highestVersionEntry\n };\n}\n\nconst plugin: () => FederationRuntimePlugin = () => {\n return {\n name: \"shared-dependencies-resolution-plugin\",\n resolveShare: function(args) {\n const { shareScopeMap, scope, pkgName } = args;\n\n log(`[squide] Resolving ${pkgName}:`, args);\n\n // This custom strategy only applies to singleton shared dependencies.\n const entries = Object.values(shareScopeMap[scope][pkgName]).filter(x => {\n return (\n // Temporary check until all the remotes on Webpack Module Federation has been updated to Module Federation 2.0.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n x.singleton ||\n (x.shareConfig && x.shareConfig.singleton)\n );\n });\n\n // Not a singleton dependency.\n if (entries.length === 0) {\n log(`[squide] ${pkgName} is not a singleton dependency, aborting.`);\n\n return args;\n }\n\n // If there's only one version entry, then it means that everyone is requesting the same version\n // of the dependency.\n if (entries.length <= 1) {\n log(`[squide] There's only one version requested for ${pkgName}, resolving to:`, entries[0].version, entries[0]);\n\n return args;\n }\n\n args.resolver = () => {\n log(`[squide] There's %cmore than one requested version%c for ${pkgName}:`, \"color: black; background-color: pink;\", \"\", entries.length, shareScopeMap[scope][pkgName]);\n\n const { resolvedEntry, highestVersionEntry } = resolveSharedDependency(pkgName, entries, log);\n\n if (resolvedEntry.version !== highestVersionEntry.version) {\n // eslint-disable-next-line max-len\n console.log(`%c[squide] \"${highestVersionEntry.from}\" requested version \"${highestVersionEntry.version}\" of \"${pkgName}\". This version is higher than the major number of the version requested by the host for this dependency (${resolvedEntry.version}). The version for \"${pkgName}\" has been forced to \"${resolvedEntry.version}\".`, \"color: white; background-color: red;\");\n }\n\n return resolvedEntry;\n };\n\n return args;\n }\n };\n};\n\nexport default plugin;\n"],"names":["minVersion","parse","rcompare","HostApplicationName","isDebug","log","args","console","findHighestVersionForMajor","entries","major","x","resolveSharedDependency","pkgName","logFct","cleanedEntries","sortedEntries","y","highestVersionEntry","hostEntry","parsedHighestVersion","parsedHostVersion","fallbackEntry","plugin","shareScopeMap","scope","Object","resolvedEntry"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,GAGkE;AAChB;AAIlD,+DAA+D;AAC/D,MAAMI,UAAU;AAEhB,SAASC,IAAI,GAAGC,IAAe;IAC3B,IAAIF,SAAS;QACTG,QAAQ,GAAG,IAAID;IACnB;AACJ;AAEA,SAASE,2BAA2BC,OAAiB,EAAEC,KAAa;IAChE,OAAOD,QAAQ,IAAI,CAACE,CAAAA;QAChB,OAAOV,KAAKA,CAACU,EAAE,OAAO,EAAG,KAAK,KAAKD;IACvC;AACJ;AAOA,yKAAyK;AAClK,SAASE,wBAAwBC,OAAe,EAAEJ,OAAiB,EAAEK,SAAuC,KAAO,CAAC;IACvH,MAAMC,iBAAiBN,QAAQ,GAAG,CAACE,CAA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AEtK,MAAM,EAAEc,aAAa,EAAET,mBAAmB,EAAE,GAAGN,wBAAwBC,SAASJ,SAASJ;gBAEzF,IAAIsB,cAAc,OAAO,KAAKT,oBAAoB,OAAO,EAAE;oBACvD,mCAAmC;oBACnCX,QAAQ,GAAG,CAAC,CAAC,YAAY,EAAEW,oBAAoB,IAAI,CAAC,qBAAqB,EAAEA,oBAAoB,OAAO,CAAC,MAAM,EAAEL,QAAQ,0GAA0G,EAAEc,cAAc,OAAO,CAAC,oBAAoB,EAAEd,QAAQ,sBAAsB,EAAEc,cAAc,OAAO,CAAC,EAAE,CAAC,EAAE;gBAC9U;gBAEA,OAAOA;YACX;YAEA,OAAOrB;QACX;IACJ;AACJ;AAEA,qEAAeiB,yCAAMA,EAAC"}
1
+ {"version":3,"file":"sharedDependenciesResolutionPlugin.js","sources":["../src/sharedDependenciesResolutionPlugin.ts"],"sourcesContent":["/*\nThis custom share dependency resolution strategy ensure that only the host app can ask for a new major version of a library.\nOtherwise, any remote can request for an higher non-major version.\n\nExamples:\n\nhost: 2.0\nremote-1: 2.1 <-----\nremote-2: 2.0\n\nhost: 2.0 <-----\nremote-1: 3.1\nremote-2: 2.0\n\nhost: 2.0\nremote-1: 3.1\nremote-2: 2.1 <-----\n\nhost: >2.0\nremote-1: 3.1\nremote-2: 2.1 <-----\n*/\n\nimport type { FederationHost, FederationRuntimePlugin } from \"@module-federation/enhanced/runtime\";\nimport { minVersion, parse, rcompare } from \"semver\";\nimport { HostApplicationName } from \"./shared.ts\";\n\ntype Shared = FederationHost[\"shareScopeMap\"][string][string][string];\n\n// Toggle to \"true\" to facilitate the debugging of this plugin.\nconst isDebug = false;\n\nfunction log(...args: unknown[]) {\n if (isDebug) {\n console.log(...args);\n }\n}\n\nfunction findHighestVersionForMajor(entries: Shared[], major: number) {\n return entries.find(x => {\n return parse(x.version)!.major === major;\n })!;\n}\n\ninterface ResolveSharedDependencyResult {\n resolvedEntry: Shared;\n highestVersionEntry: Shared;\n}\n\n// The return type is required otherwise we get the following error: error TS2742: The inferred type of 'resolveSharedDependency' cannot be named without a reference to.\nexport function resolveSharedDependency(pkgName: string, entries: Shared[], logFct: (...rest: unknown[]) => void = () => {}): ResolveSharedDependencyResult {\n const cleanedEntries = entries.map(x => ({\n ...x,\n // Removing any special characters like >,>=,^,~ etc...\n version: minVersion(x.version)!.version\n }));\n\n // From higher to lower versions.\n const sortedEntries = cleanedEntries.sort((x, y) => rcompare(x.version, y.version));\n\n logFct(\"[squide] Sorted the entries by version from higher to lower\", sortedEntries);\n\n const highestVersionEntry = sortedEntries[0];\n\n logFct(`[squide] ${pkgName} highest requested version is`, highestVersionEntry.version, highestVersionEntry);\n\n // The host is always right!\n if (highestVersionEntry.from === HostApplicationName) {\n logFct(\"[squide] %cThis is the host version%c, great, resolving to:\", \"color: black; background-color: pink;\", \"\", highestVersionEntry.version, highestVersionEntry);\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(`[squide] ${pkgName} Highest requested version is not from the host.`);\n\n const hostEntry = sortedEntries.find(x => x.from === HostApplicationName);\n\n // Found nothing, that's odd but let's not break the app for this.\n if (!hostEntry) {\n logFct(`[squide] The host is not requesting any version of ${pkgName}, %caborting%c.`, \"color: black; background-color: pink;\", \"\");\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(`[squide] ${pkgName} version requested by the host is:`, hostEntry.version, hostEntry);\n\n const parsedHighestVersion = parse(highestVersionEntry.version)!;\n const parsedHostVersion = parse(hostEntry.version)!;\n\n // Major versions should always be introduced by the host application.\n if (parsedHighestVersion.major === parsedHostVersion.major) {\n logFct(`[squide] Resolving to %c${parsedHighestVersion.major}%c.`, \"color: black; background-color: pink;\", \"\");\n\n return {\n resolvedEntry: highestVersionEntry,\n highestVersionEntry: highestVersionEntry\n };\n }\n\n logFct(\"[squide] The major number of the highest requested version is higher than the major number of the version requested by the host, looking for another version to resolve to.\");\n\n // Start at the second entry since the first entry is the current higher version entry.\n // The result could either be the actual host entry or any other entry that is higher than the version requested\n // by the host, but match the host entry major version number.\n const fallbackEntry = findHighestVersionForMajor(sortedEntries.splice(1), parsedHostVersion.major);\n\n logFct(`[squide] The %chighest requested version%c for ${pkgName} that is in-range with the requested host major version number is:`, \"color: black; background-color: pink;\", \"\", fallbackEntry.version, fallbackEntry);\n\n return {\n resolvedEntry: fallbackEntry,\n highestVersionEntry: highestVersionEntry\n };\n}\n\nconst plugin: () => FederationRuntimePlugin = () => {\n return {\n name: \"shared-dependencies-resolution-plugin\",\n resolveShare: function(args) {\n const { shareScopeMap, scope, pkgName } = args;\n\n log(`[squide] Resolving ${pkgName}:`, args);\n\n // This custom strategy only applies to singleton shared dependencies.\n const entries = Object.values(shareScopeMap[scope][pkgName]).filter(x => {\n return (\n // Temporary check until all the remotes on Webpack Module Federation has been updated to Module Federation 2.0.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n x.singleton ||\n (x.shareConfig?.singleton)\n );\n });\n\n // Not a singleton dependency.\n if (entries.length === 0) {\n log(`[squide] ${pkgName} is not a singleton dependency, aborting.`);\n\n return args;\n }\n\n // If there's only one version entry, then it means that everyone is requesting the same version\n // of the dependency.\n if (entries.length <= 1) {\n log(`[squide] There's only one version requested for ${pkgName}, resolving to:`, entries[0].version, entries[0]);\n\n return args;\n }\n\n args.resolver = () => {\n log(`[squide] There's %cmore than one requested version%c for ${pkgName}:`, \"color: black; background-color: pink;\", \"\", entries.length, shareScopeMap[scope][pkgName]);\n\n const { resolvedEntry, highestVersionEntry } = resolveSharedDependency(pkgName, entries, log);\n\n if (resolvedEntry.version !== highestVersionEntry.version) {\n console.log(`%c[squide] \"${highestVersionEntry.from}\" requested version \"${highestVersionEntry.version}\" of \"${pkgName}\". This version is higher than the major number of the version requested by the host for this dependency (${resolvedEntry.version}). The version for \"${pkgName}\" has been forced to \"${resolvedEntry.version}\".`, \"color: white; background-color: red;\");\n }\n\n return resolvedEntry;\n };\n\n return args;\n }\n };\n};\n\nexport default plugin;\n"],"names":["minVersion","parse","rcompare","HostApplicationName","isDebug","log","args","console","findHighestVersionForMajor","entries","major","x","resolveSharedDependency","pkgName","logFct","cleanedEntries","sortedEntries","y","highestVersionEntry","hostEntry","parsedHighestVersion","parsedHostVersion","fallbackEntry","plugin","shareScopeMap","scope","Object","resolvedEntry"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,GAGqD;AACH;AAIlD,+DAA+D;AAC/D,MAAMI,UAAU;AAEhB,SAASC,IAAI,GAAGC,IAAe;IAC3B,IAAIF,SAAS;QACTG,QAAQ,GAAG,IAAID;IACnB;AACJ;AAEA,SAASE,2BAA2BC,OAAiB,EAAEC,KAAa;IAChE,OAAOD,QAAQ,IAAI,CAACE,CAAAA;QAChB,OAAOV,KAAKA,CAACU,EAAE,OAAO,EAAG,KAAK,KAAKD;IACvC;AACJ;AAOA,yKAAyK;AAClK,SAASE,wBAAwBC,OAAe,EAAEJ,OAAiB,EAAEK,SAAuC,KAAO,CAAC;IACvH,MAAMC,iBAAiBN,QAAQ,GAAG,CAACE,CAAAA,IAAM;YACrC,GAAGA,CAAC;YACJ,uDAAuD;YACvD,SAASX,UAAUA,CAACW,EAAE,OAAO,EAAG,OAAO;QAC3C;IAEA,iCAAiC;IACjC,MAAMK,gBAAgBD,eAAe,IAAI,CAAC,CAACJ,GAAGM,IAAMf,QAAQA,CAACS,EAAE,OAAO,EAAEM,EAAE,OAAO;IAEjFH,OAAO,+DAA+DE;IAEtE,MAAME,sBAAsBF,aAAa,CAAC,EAAE;IAE5CF,OAAO,CAAC,SAAS,EAAED,QAAQ,6BAA6B,CAAC,EAAEK,oBAAoB,OAAO,EAAEA;IAExF,4BAA4B;IAC5B,IAAIA,oBAAoB,IAAI,KAAKf,mBAAmBA,EAAE;QAClDW,OAAO,+DAA+D,yCAAyC,IAAII,oBAAoB,OAAO,EAAEA;QAEhJ,OAAO;YACH,eAAe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",
4
- "version": "5.1.2",
4
+ "version": "5.1.4",
5
5
  "description": "Webpack configuration helpers for the Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -24,47 +24,45 @@
24
24
  "files": [
25
25
  "src",
26
26
  "dist",
27
- "CHANGELOG.md",
28
- "README.md"
27
+ "CHANGELOG.md"
29
28
  ],
30
29
  "peerDependencies": {
31
- "@swc/core": "^1.13.5",
30
+ "@swc/core": "^1.15.2",
32
31
  "@swc/helpers": "^0.5.17",
33
- "@workleap/swc-configs": "^2.3.0",
34
- "browserslist": "^4.26.3",
32
+ "@workleap/swc-configs": "^2.3.3",
33
+ "browserslist": "^4.28.0",
35
34
  "postcss": "^8.5.3",
36
- "webpack": "^5.102.1",
35
+ "webpack": "^5.103.0",
37
36
  "webpack-dev-server": "^5.2.2"
38
37
  },
39
38
  "dependencies": {
40
39
  "@module-federation/enhanced": "0.11.4",
41
- "@workleap/webpack-configs": "^1.6.0",
40
+ "@workleap/webpack-configs": "^1.6.3",
42
41
  "deepmerge": "^4.3.1",
43
- "html-webpack-plugin": "^5.6.4",
42
+ "html-webpack-plugin": "^5.6.5",
44
43
  "semver": "^7.7.3"
45
44
  },
46
45
  "devDependencies": {
47
- "@rsbuild/core": "1.5.13",
48
- "@rslib/core": "0.15.0",
49
- "@types/node": "24.7.0",
46
+ "@eslint/js": "9.39.1",
47
+ "@rsbuild/core": "1.6.7",
48
+ "@rslib/core": "0.18.0",
49
+ "@types/node": "24.10.1",
50
50
  "@types/semver": "7.7.1",
51
- "@typescript-eslint/parser": "8.46.0",
52
- "@workleap/eslint-plugin": "3.5.0",
53
- "@workleap/rslib-configs": "1.1.0",
54
- "@workleap/typescript-configs": "3.0.4",
55
- "eslint": "8.57.0",
51
+ "@typescript-eslint/parser": "8.47.0",
52
+ "@workleap/eslint-configs": "1.1.5",
53
+ "@workleap/rslib-configs": "1.1.3",
54
+ "@workleap/typescript-configs": "3.0.7",
55
+ "eslint": "9.39.1",
56
56
  "typescript": "5.9.3",
57
- "vitest": "3.2.4",
58
- "webpack": "5.102.1",
57
+ "typescript-eslint": "8.47.0",
58
+ "vitest": "4.0.10",
59
+ "webpack": "5.103.0",
59
60
  "webpack-dev-server": "5.2.2"
60
61
  },
61
- "engines": {
62
- "node": ">=21.1.0"
63
- },
64
62
  "scripts": {
65
63
  "dev": "rslib build --watch --config ./rslib.dev.ts",
66
64
  "build": "rslib build --config ./rslib.build.ts",
67
- "eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
65
+ "eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
68
66
  "typecheck": "tsc",
69
67
  "test": "vitest --config vitest.config.ts --no-watch"
70
68
  }
@@ -191,7 +191,7 @@ function createSetUniqueNameTransformer(uniqueName: string) {
191
191
  }
192
192
 
193
193
  function resolveEntryFilePath(entryPaths: string[]) {
194
- for (const entryPath in entryPaths) {
194
+ for (const entryPath of entryPaths) {
195
195
  if (fs.existsSync(path.resolve(applicationDirectory, entryPath))) {
196
196
  return entryPath;
197
197
  }
@@ -202,7 +202,7 @@ function resolveEntryFilePath(entryPaths: string[]) {
202
202
 
203
203
  //////////////////////////// Host /////////////////////////////
204
204
 
205
- export interface RemoteDefinition {
205
+ export interface RemoteDefinition extends Record<string, unknown> {
206
206
  // The name of the remote module.
207
207
  name: string;
208
208
  // The URL of the remote, ex: http://localhost:8081.
package/src/index.ts CHANGED
@@ -1,3 +1,23 @@
1
1
  export * from "@workleap/webpack-configs";
2
- export * from "./defineConfig.ts";
2
+ export {
3
+ defineBuildHostConfig,
4
+ defineBuildRemoteModuleConfig,
5
+ defineDevHostConfig,
6
+ defineDevRemoteModuleConfig,
7
+ defineHostModuleFederationPluginOptions,
8
+ defineRemoteModuleFederationPluginOptions,
9
+ type DefineBuildHostConfigOptions,
10
+ type DefineBuildRemoteModuleConfigOptions,
11
+ type DefineDevHostConfigOptions,
12
+ type DefineDevRemoteModuleConfigOptions,
13
+ type DefineHostModuleFederationPluginOptions,
14
+ type DefineRemoteModuleFederationPluginOptions,
15
+ type Features,
16
+ type ModuleFederationPluginOptions,
17
+ type ModuleFederationRemotesOption,
18
+ type ModuleFederationRuntimePlugins,
19
+ type ModuleFederationShared,
20
+ type RemoteDefinition,
21
+ type Router
22
+ } from "./defineConfig.ts";
3
23
 
@@ -22,7 +22,7 @@ remote-2: 2.1 <-----
22
22
  */
23
23
 
24
24
  import type { FederationHost, FederationRuntimePlugin } from "@module-federation/enhanced/runtime";
25
- import { minVersion, parse, rcompare, type SemVer } from "semver";
25
+ import { minVersion, parse, rcompare } from "semver";
26
26
  import { HostApplicationName } from "./shared.ts";
27
27
 
28
28
  type Shared = FederationHost["shareScopeMap"][string][string][string];
@@ -39,7 +39,7 @@ function log(...args: unknown[]) {
39
39
  function findHighestVersionForMajor(entries: Shared[], major: number) {
40
40
  return entries.find(x => {
41
41
  return parse(x.version)!.major === major;
42
- }) as Shared;
42
+ })!;
43
43
  }
44
44
 
45
45
  interface ResolveSharedDependencyResult {
@@ -90,8 +90,8 @@ export function resolveSharedDependency(pkgName: string, entries: Shared[], logF
90
90
 
91
91
  logFct(`[squide] ${pkgName} version requested by the host is:`, hostEntry.version, hostEntry);
92
92
 
93
- const parsedHighestVersion = parse(highestVersionEntry.version) as SemVer;
94
- const parsedHostVersion = parse(hostEntry.version) as SemVer;
93
+ const parsedHighestVersion = parse(highestVersionEntry.version)!;
94
+ const parsedHostVersion = parse(hostEntry.version)!;
95
95
 
96
96
  // Major versions should always be introduced by the host application.
97
97
  if (parsedHighestVersion.major === parsedHostVersion.major) {
@@ -133,7 +133,7 @@ const plugin: () => FederationRuntimePlugin = () => {
133
133
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
134
134
  // @ts-ignore
135
135
  x.singleton ||
136
- (x.shareConfig && x.shareConfig.singleton)
136
+ (x.shareConfig?.singleton)
137
137
  );
138
138
  });
139
139
 
@@ -158,7 +158,6 @@ const plugin: () => FederationRuntimePlugin = () => {
158
158
  const { resolvedEntry, highestVersionEntry } = resolveSharedDependency(pkgName, entries, log);
159
159
 
160
160
  if (resolvedEntry.version !== highestVersionEntry.version) {
161
- // eslint-disable-next-line max-len
162
161
  console.log(`%c[squide] "${highestVersionEntry.from}" requested version "${highestVersionEntry.version}" of "${pkgName}". This version is higher than the major number of the version requested by the host for this dependency (${resolvedEntry.version}). The version for "${pkgName}" has been forced to "${resolvedEntry.version}".`, "color: white; background-color: red;");
163
162
  }
164
163