@squide/firefly-webpack-configs 5.0.4 → 5.1.0

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.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#296](https://github.com/workleap/wl-squide/pull/296) [`a143988`](https://github.com/workleap/wl-squide/commit/a1439886931f773ff8e71fa8dd8b429108525717) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated dependencies.
8
+
9
+ ## 5.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#289](https://github.com/workleap/wl-squide/pull/289) [`ee6f7d5`](https://github.com/workleap/wl-squide/commit/ee6f7d52ff6afa8ac757770c89b39978c40a70bc) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fixed Honeycomb telemetry traces when data fetching fails and bumped dependencies versions.
14
+
3
15
  ## 5.0.4
4
16
 
5
17
  ### Patch Changes
@@ -1,10 +1,10 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__module_federation_enhanced_webpack_5184ba07__ from "@module-federation/enhanced/webpack";
2
- import * as __WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__ from "@workleap/webpack-configs";
3
- import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
4
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
- import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
7
- import * as __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__ from "./shared.js";
1
+ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
2
+ import { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineDevConfig, defineDevHtmlWebpackPluginConfig } from "@workleap/webpack-configs";
3
+ import deepmerge from "deepmerge";
4
+ import node_fs from "node:fs";
5
+ import node_path, { dirname } from "node:path";
6
+ import node_url, { fileURLToPath } from "node:url";
7
+ import { HostApplicationName } from "./shared.js";
8
8
 
9
9
  ;// CONCATENATED MODULE: external "@module-federation/enhanced/webpack"
10
10
 
@@ -30,8 +30,8 @@ import * as __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__ from "./shared.js";
30
30
 
31
31
  // Using import.meta.url instead of import.meta.dirname because Jest is throwing the following error:
32
32
  // SyntaxError: Cannot use 'import.meta' outside a module
33
- const applicationDirectory = (0,__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)((0,__WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url));
34
- const packageDirectory = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__["default"].fileURLToPath(new URL(".", import.meta.url));
33
+ const applicationDirectory = dirname(fileURLToPath(import.meta.url));
34
+ const packageDirectory = node_url.fileURLToPath(new URL(".", import.meta.url));
35
35
  // Must be similar to the module name defined in @workleap/module-federation.
36
36
  const RemoteRegisterModuleName = "./register";
37
37
  const RemoteEntryPoint = "remoteEntry.js";
@@ -172,7 +172,7 @@ function createSetUniqueNameTransformer(uniqueName) {
172
172
  }
173
173
  function resolveEntryFilePath(entryPaths) {
174
174
  for(const entryPath in entryPaths){
175
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(applicationDirectory, entryPath))) {
175
+ if (node_fs.existsSync(node_path.resolve(applicationDirectory, entryPath))) {
176
176
  return entryPath;
177
177
  }
178
178
  }
@@ -187,7 +187,7 @@ function defineHostModuleFederationPluginOptions(remotes, options) {
187
187
  const { features = {}, shared = {}, runtimePlugins = [], ...rest } = options;
188
188
  const defaultSharedDependencies = resolveDefaultSharedDependencies(features, true);
189
189
  return {
190
- name: __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__.HostApplicationName,
190
+ name: HostApplicationName,
191
191
  // Since Squide modules are only exporting a register function with a standardized API
192
192
  // it doesn't requires any typing.
193
193
  dts: false,
@@ -203,13 +203,13 @@ function defineHostModuleFederationPluginOptions(remotes, options) {
203
203
  // Deep merging the default shared dependencies with the provided shared dependencies
204
204
  // to allow the consumer to easily override a default option of a shared dependency
205
205
  // without extending the whole default shared dependencies object.
206
- shared: __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"].all([
206
+ shared: deepmerge.all([
207
207
  defaultSharedDependencies,
208
208
  shared
209
209
  ]),
210
210
  runtimePlugins: [
211
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(packageDirectory, "./sharedDependenciesResolutionPlugin.js"),
212
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(packageDirectory, "./nonCacheableRemoteEntryPlugin.js"),
211
+ node_path.resolve(packageDirectory, "./sharedDependenciesResolutionPlugin.js"),
212
+ node_path.resolve(packageDirectory, "./nonCacheableRemoteEntryPlugin.js"),
213
213
  ...runtimePlugins
214
214
  ],
215
215
  // Commented because it doesn't seems to work, the runtime is still embedded into remotes.
@@ -235,19 +235,19 @@ function defineDevHostConfig(swcConfig, port, remotes, options = {}) {
235
235
  shared: sharedDependencies,
236
236
  runtimePlugins
237
237
  }), ...webpackOptions } = options;
238
- return (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineDevConfig)(swcConfig, {
238
+ return defineDevConfig(swcConfig, {
239
239
  entry,
240
240
  port,
241
241
  publicPath,
242
242
  cache,
243
- htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineBuildHtmlWebpackPluginConfig)()),
243
+ htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineBuildHtmlWebpackPluginConfig()),
244
244
  plugins: [
245
245
  ...plugins,
246
- new __WEBPACK_EXTERNAL_MODULE__module_federation_enhanced_webpack_5184ba07__.ModuleFederationPlugin(moduleFederationPluginOptions)
246
+ new ModuleFederationPlugin(moduleFederationPluginOptions)
247
247
  ],
248
248
  ...webpackOptions,
249
249
  transformers: [
250
- createSetUniqueNameTransformer(__WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__.HostApplicationName),
250
+ createSetUniqueNameTransformer(HostApplicationName),
251
251
  ...transformers
252
252
  ]
253
253
  });
@@ -259,17 +259,17 @@ function defineBuildHostConfig(swcConfig, remotes, options = {}) {
259
259
  shared: sharedDependencies,
260
260
  runtimePlugins
261
261
  }), ...webpackOptions } = options;
262
- return (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineBuildConfig)(swcConfig, {
262
+ return defineBuildConfig(swcConfig, {
263
263
  entry,
264
264
  publicPath,
265
- htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineDevHtmlWebpackPluginConfig)()),
265
+ htmlWebpackPlugin: trySetHtmlWebpackPluginPublicPath(htmlWebpackPluginOptions ?? defineDevHtmlWebpackPluginConfig()),
266
266
  plugins: [
267
267
  ...plugins,
268
- new __WEBPACK_EXTERNAL_MODULE__module_federation_enhanced_webpack_5184ba07__.ModuleFederationPlugin(moduleFederationPluginOptions)
268
+ new ModuleFederationPlugin(moduleFederationPluginOptions)
269
269
  ],
270
270
  transformers: [
271
271
  forceNamedChunkIdsTransformer,
272
- createSetUniqueNameTransformer(__WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__.HostApplicationName),
272
+ createSetUniqueNameTransformer(HostApplicationName),
273
273
  ...transformers
274
274
  ],
275
275
  ...webpackOptions
@@ -299,13 +299,13 @@ function defineRemoteModuleFederationPluginOptions(applicationName, options) {
299
299
  // Deep merging the default shared dependencies with the provided shared dependencies
300
300
  // to allow the consumer to easily override a default option of a shared dependency
301
301
  // without extending the whole default shared dependencies object.
302
- shared: __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"].all([
302
+ shared: deepmerge.all([
303
303
  defaultSharedDependencies,
304
304
  shared
305
305
  ]),
306
306
  runtimePlugins: [
307
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(packageDirectory, "./sharedDependenciesResolutionPlugin.js"),
308
- __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(packageDirectory, "./nonCacheableRemoteEntryPlugin.js"),
307
+ node_path.resolve(packageDirectory, "./sharedDependenciesResolutionPlugin.js"),
308
+ node_path.resolve(packageDirectory, "./nonCacheableRemoteEntryPlugin.js"),
309
309
  ...runtimePlugins
310
310
  ],
311
311
  // Commented because it doesn't seems to work, the runtime is still embedded into remotes.
@@ -337,7 +337,7 @@ function defineDevRemoteModuleConfig(swcConfig, applicationName, port, options =
337
337
  shared: sharedDependencies,
338
338
  runtimePlugins
339
339
  }), ...webpackOptions } = options;
340
- return (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineDevConfig)(swcConfig, {
340
+ return defineDevConfig(swcConfig, {
341
341
  entry,
342
342
  port,
343
343
  publicPath,
@@ -348,7 +348,7 @@ function defineDevRemoteModuleConfig(swcConfig, applicationName, port, options =
348
348
  overlay: false,
349
349
  plugins: [
350
350
  ...plugins,
351
- new __WEBPACK_EXTERNAL_MODULE__module_federation_enhanced_webpack_5184ba07__.ModuleFederationPlugin(moduleFederationPluginOptions)
351
+ new ModuleFederationPlugin(moduleFederationPluginOptions)
352
352
  ],
353
353
  transformers: [
354
354
  devRemoteModuleTransformer,
@@ -365,13 +365,13 @@ function defineBuildRemoteModuleConfig(swcConfig, applicationName, options = {})
365
365
  shared: sharedDependencies,
366
366
  runtimePlugins
367
367
  }), ...webpackOptions } = options;
368
- return (0,__WEBPACK_EXTERNAL_MODULE__workleap_webpack_configs_227c33a7__.defineBuildConfig)(swcConfig, {
368
+ return defineBuildConfig(swcConfig, {
369
369
  entry,
370
370
  publicPath,
371
371
  htmlWebpackPlugin,
372
372
  plugins: [
373
373
  ...plugins,
374
- new __WEBPACK_EXTERNAL_MODULE__module_federation_enhanced_webpack_5184ba07__.ModuleFederationPlugin(moduleFederationPluginOptions)
374
+ new ModuleFederationPlugin(moduleFederationPluginOptions)
375
375
  ],
376
376
  transformers: [
377
377
  forceNamedChunkIdsTransformer,
@@ -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,uBAAuBJ,0DAAOA,CAACE,+DAAaA,CAAC,YAAY,GAAG;AAClE,MAAMG,mBAAmBJ,sEAAiB,CAAC,IAAIK,IAAI,KAAK,YAAY,GAAG;AAEvE,6EAA6E;AAC7E,MAAMC,2BAA2B;AACjC,MAAMC,mBAAmB;AASzB,uEAAuE;AACvE,8GAA8G;AAC9G,SAASC,6BAA6BC,QAAkB,EAAEC,MAAe;IACrE,OAAO;QACH,SAAS;YACL,WAAW;YACX,OAAOA,SAAS,OAAOC;YACvB,4EAA4E;YAC5E,gHAAgH;YAChH,iBAAiBF,SAAS,OAAO,GAAG,QAAQE;QAChD;QACA,aAAa;YACT,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;QACA,gBAAgB;YACZ,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;QACA,6BAA6B;YACzB,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;IACJ;AACJ;AAYA,uEAAuE;AACvE,8GAA8G;AAC9G,SAASC,iCAAiCF,MAAe;IACrD,OAAO;QACH,gBAAgB;YACZ,WAAW;YACX,OAAOA,SAAS,OAAOC;QAC3B;Q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jD;QAAU,QAAQ2C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAO3C,oFAAiBA,CAACoD,WAAW;QAChCE;QACAC;QACAe;QACA,SAAS;eACFb;YACH,IAAI1D,+FAAsBA,CAAC8D;SAC9B;QACD,cAAc;YACV7B;YACAE,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ"}
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,uBAAuBJ,OAAOA,CAACE,aAAaA,CAAC,YAAY,GAAG;AAClE,MAAMG,mBAAmBJ,sBAAiB,CAAC,IAAIK,IAAI,KAAK,YAAY,GAAG;AAEvE,6EAA6E;AAC7E,MAAMC,2BAA2B;AACjC,MAAMC,mBAAmB;AASzB,uEAAuE;AACvE,8GAA8G;AAC9G,SAASC,6BAA6BC,QAAkB,EAAEC,MAAe;IACrE,OAAO;QACH,SAAS;YACL,WAAW;YACX,OAAOA,SAAS,OAAOC;YACvB,4EAA4E;YAC5E,gHAAgH;YAChH,iBAAiBF,SAAS,OAAO,GAAG,QAAQE;QAChD;QACA,aAAa;YACT,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;QACA,gBAAgB;YACZ,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;QACA,6BAA6B;YACzB,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC3B;IACJ;AACJ;AAYA,uEAAuE;AACvE,8GAA8G;AAC9G,SAASC,iCAAiCF,MAAe;IACrD,OAAO;QACH,gBAAgB;YACZ,WAAW;YACX,OAAOA,SAAS,OAAOC;QAC3B;QACA,wBAAwB;YACpB,WAAW;YACX,OAAOD,SAAS,OAAOC;QAC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ACN,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,5 +1,5 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_semver__ from "semver";
2
- import * as __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__ from "./shared.js";
1
+ import { minVersion, parse, rcompare } from "semver";
2
+ import { HostApplicationName } from "./shared.js";
3
3
 
4
4
  ;// CONCATENATED MODULE: external "semver"
5
5
 
@@ -38,7 +38,7 @@ function log(...args) {
38
38
  }
39
39
  function findHighestVersionForMajor(entries, major) {
40
40
  return entries.find((x)=>{
41
- return (0,__WEBPACK_EXTERNAL_MODULE_semver__.parse)(x.version).major === major;
41
+ return parse(x.version).major === major;
42
42
  });
43
43
  }
44
44
  // 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.
@@ -46,15 +46,15 @@ function resolveSharedDependency(pkgName, entries, logFct = ()=>{}) {
46
46
  const cleanedEntries = entries.map((x)=>({
47
47
  ...x,
48
48
  // Removing any special characters like >,>=,^,~ etc...
49
- version: (0,__WEBPACK_EXTERNAL_MODULE_semver__.minVersion)(x.version).version
49
+ version: minVersion(x.version).version
50
50
  }));
51
51
  // From higher to lower versions.
52
- const sortedEntries = cleanedEntries.sort((x, y)=>(0,__WEBPACK_EXTERNAL_MODULE_semver__.rcompare)(x.version, y.version));
52
+ const sortedEntries = cleanedEntries.sort((x, y)=>rcompare(x.version, y.version));
53
53
  logFct("[squide] Sorted the entries by version from higher to lower", sortedEntries);
54
54
  const highestVersionEntry = sortedEntries[0];
55
55
  logFct(`[squide] ${pkgName} highest requested version is`, highestVersionEntry.version, highestVersionEntry);
56
56
  // The host is always right!
57
- if (highestVersionEntry.from === __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__.HostApplicationName) {
57
+ if (highestVersionEntry.from === HostApplicationName) {
58
58
  logFct("[squide] %cThis is the host version%c, great, resolving to:", "color: black; background-color: pink;", "", highestVersionEntry.version, highestVersionEntry);
59
59
  return {
60
60
  resolvedEntry: highestVersionEntry,
@@ -62,7 +62,7 @@ function resolveSharedDependency(pkgName, entries, logFct = ()=>{}) {
62
62
  };
63
63
  }
64
64
  logFct(`[squide] ${pkgName} Highest requested version is not from the host.`);
65
- const hostEntry = sortedEntries.find((x)=>x.from === __WEBPACK_EXTERNAL_MODULE__shared_js_cc7b7cda__.HostApplicationName);
65
+ const hostEntry = sortedEntries.find((x)=>x.from === HostApplicationName);
66
66
  // Found nothing, that's odd but let's not break the app for this.
67
67
  if (!hostEntry) {
68
68
  logFct(`[squide] The host is not requesting any version of ${pkgName}, %caborting%c.`, "color: black; background-color: pink;", "");
@@ -72,8 +72,8 @@ function resolveSharedDependency(pkgName, entries, logFct = ()=>{}) {
72
72
  };
73
73
  }
74
74
  logFct(`[squide] ${pkgName} version requested by the host is:`, hostEntry.version, hostEntry);
75
- const parsedHighestVersion = (0,__WEBPACK_EXTERNAL_MODULE_semver__.parse)(highestVersionEntry.version);
76
- const parsedHostVersion = (0,__WEBPACK_EXTERNAL_MODULE_semver__.parse)(hostEntry.version);
75
+ const parsedHighestVersion = parse(highestVersionEntry.version);
76
+ const parsedHostVersion = parse(hostEntry.version);
77
77
  // Major versions should always be introduced by the host application.
78
78
  if (parsedHighestVersion.major === parsedHostVersion.major) {
79
79
  logFct(`[squide] Resolving to %c${parsedHighestVersion.major}%c.`, "color: black; background-color: pink;", "");
@@ -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,4CAAKA,CAACU,EAAE,OAAO,EAAG,KAAK,KAAKD;IACvC;AACJ;AAO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ACZD,IAAI,CAAC,yDAAyD,EAAEQ,QAAQ,CAAC,CAAC,EAAE,yCAAyC,IAAIJ,QAAQ,MAAM,EAAEe,aAAa,CAACC,MAAM,CAACZ,QAAQ;gBAEtK,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":["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,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,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B,EAAEd,QAAQ,sBAAsB,EAAEc,cAAc,OAAO,CAAC,EAAE,CAAC,EAAE;gBAC9U;gBAEA,OAAOA;YACX;YAEA,OAAOrB;QACX;IACJ;AACJ;AAEA,qEAAeiB,yCAAMA,EAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly-webpack-configs",
3
3
  "author": "Workleap",
4
- "version": "5.0.4",
4
+ "version": "5.1.0",
5
5
  "description": "Webpack configuration helpers for the Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,35 +28,35 @@
28
28
  "README.md"
29
29
  ],
30
30
  "peerDependencies": {
31
- "@swc/core": "^1.11.29",
31
+ "@swc/core": "^1.12.14",
32
32
  "@swc/helpers": "^0.5.17",
33
- "@workleap/swc-configs": "^2.2.8",
34
- "browserslist": "^4.24.5",
33
+ "@workleap/swc-configs": "^2.3.0",
34
+ "browserslist": "^4.25.1",
35
35
  "postcss": "^8.5.3",
36
- "webpack": "^5.99.9",
37
- "webpack-dev-server": "^5.2.1"
36
+ "webpack": "^5.100.2",
37
+ "webpack-dev-server": "^5.2.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "@module-federation/enhanced": "0.11.4",
41
- "@workleap/webpack-configs": "^1.5.7",
41
+ "@workleap/webpack-configs": "^1.6.0",
42
42
  "deepmerge": "^4.3.1",
43
43
  "html-webpack-plugin": "^5.6.3",
44
44
  "semver": "^7.7.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@rsbuild/core": "1.3.21",
48
- "@rslib/core": "0.8.0",
49
- "@types/node": "22.15.21",
47
+ "@rsbuild/core": "1.4.7",
48
+ "@rslib/core": "0.10.6",
49
+ "@types/node": "24.0.14",
50
50
  "@types/semver": "7.7.0",
51
- "@typescript-eslint/parser": "8.32.1",
52
- "@workleap/eslint-plugin": "3.4.2",
53
- "@workleap/rslib-configs": "1.0.6",
51
+ "@typescript-eslint/parser": "8.37.0",
52
+ "@workleap/eslint-plugin": "3.5.0",
53
+ "@workleap/rslib-configs": "1.1.0",
54
54
  "@workleap/typescript-configs": "3.0.4",
55
55
  "eslint": "8.57.0",
56
56
  "typescript": "5.8.3",
57
- "vitest": "3.1.4",
58
- "webpack": "5.99.9",
59
- "webpack-dev-server": "5.2.1"
57
+ "vitest": "3.2.4",
58
+ "webpack": "5.100.2",
59
+ "webpack-dev-server": "5.2.2"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=21.1.0"