@squide/firefly-webpack-configs 5.1.7 → 5.2.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 +12 -0
- package/dist/defineConfig.d.ts +1 -0
- package/dist/defineConfig.js +15 -2
- package/dist/defineConfig.js.map +1 -1
- package/package.json +6 -6
- package/src/defineConfig.ts +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @squide/firefly-webpack-configs
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#363](https://github.com/workleap/wl-squide/pull/363) [`b114284`](https://github.com/workleap/wl-squide/commit/b114284529ff87e719d594d9612a52b1935a0bb2) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added support for LaunchDarkly.
|
|
8
|
+
|
|
9
|
+
## 5.1.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#361](https://github.com/workleap/wl-squide/pull/361) [`0479f4b`](https://github.com/workleap/wl-squide/commit/0479f4bb0bf17282dbd19dba92b3ac097cf01614) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependency versions.
|
|
14
|
+
|
|
3
15
|
## 5.1.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/defineConfig.d.ts
CHANGED
package/dist/defineConfig.js
CHANGED
|
@@ -120,14 +120,27 @@ function getHoneycombSharedDependencies(isHost) {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
function getLaunchDarklySharedDependencies(isHost) {
|
|
124
|
+
return {
|
|
125
|
+
"@squide/launch-darkly": {
|
|
126
|
+
singleton: true,
|
|
127
|
+
eager: isHost ? true : undefined
|
|
128
|
+
},
|
|
129
|
+
"launchdarkly-js-client-sdk": {
|
|
130
|
+
singleton: true,
|
|
131
|
+
eager: isHost ? true : undefined
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
123
135
|
function getFeaturesDependencies(features, isHost) {
|
|
124
|
-
const { router = "react-router", msw = true, i18next, environmentVariables = true, honeycomb = true } = features;
|
|
136
|
+
const { router = "react-router", msw = true, i18next, environmentVariables = true, honeycomb = true, launchDarkly = true } = features;
|
|
125
137
|
return {
|
|
126
138
|
...router === "react-router" ? getReactRouterSharedDependencies(isHost) : {},
|
|
127
139
|
...msw ? getMswSharedDependency(isHost) : {},
|
|
128
140
|
...i18next ? getI18nextSharedDependency(isHost) : {},
|
|
129
141
|
...environmentVariables ? getEnvironmentVariablesSharedDependencies(isHost) : {},
|
|
130
|
-
...honeycomb ? getHoneycombSharedDependencies(isHost) : {}
|
|
142
|
+
...honeycomb ? getHoneycombSharedDependencies(isHost) : {},
|
|
143
|
+
...launchDarkly ? getLaunchDarklySharedDependencies(isHost) : {}
|
|
131
144
|
};
|
|
132
145
|
}
|
|
133
146
|
function resolveDefaultSharedDependencies(features, isHost) {
|
package/dist/defineConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 \"@opentelemetry/api\": {\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 = true,\n honeycomb = true\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,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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,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 launchDarkly?: 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 \"@opentelemetry/api\": {\n singleton: true,\n eager: isHost ? true : undefined\n }\n };\n}\n\nfunction getLaunchDarklySharedDependencies(isHost: boolean): ModuleFederationShared {\n return {\n \"@squide/launch-darkly\": {\n singleton: true,\n eager: isHost ? true : undefined\n },\n \"launchdarkly-js-client-sdk\": {\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 = true,\n honeycomb = true,\n launchDarkly = true\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 ...(launchDarkly ? getLaunchDarklySharedDependencies(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","getLaunchDarklySharedDependencies","getFeaturesDependencies","router","msw","i18next","environmentVariables","honeycomb","launchDarkly","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;AAaA,uEAAuE;AACvE,8GAA8G;AAC9G,SAASC,iCAAi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M,EACnBE,UAAU,EAAE,EACZa,oBAAoB,KAAK,EACzBX,eAAe,EAAE,EACjB5C,QAAQ,EACR6C,kBAAkB,EAClBf,cAAc,EACdgB,gCAAgCI,0CAA0CC,iBAAiB;QAAEnD;QAAU,QAAQ6C;QAAoBf;IAAe,EAAE,EACpJ,GAAGiB,gBACN,GAAGnB;IAEJ,OAAO7C,iBAAiBA,CAACsD,WAAW;QAChCE;QACAC;QACAe;QACA,SAAS;eACFb;YACH,IAAI5D,sBAAsBA,CAACgE;SAC9B;QACD,cAAc;YACV7B;YACAE,+BAA+BgC;eAC5BP;SACN;QACD,GAAGG,cAAc;IACrB;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly-webpack-configs",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"description": "Webpack configuration helpers for the Squide firefly technology stack.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@swc/core": "^1.15.3",
|
|
31
31
|
"@swc/helpers": "^0.5.17",
|
|
32
|
-
"@workleap/swc-configs": "^2.3.
|
|
32
|
+
"@workleap/swc-configs": "^2.3.4",
|
|
33
33
|
"browserslist": "^4.28.1",
|
|
34
34
|
"postcss": "^8.5.3",
|
|
35
35
|
"webpack": "^5.103.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@module-federation/enhanced": "0.11.4",
|
|
40
|
-
"@workleap/webpack-configs": "^1.6.
|
|
40
|
+
"@workleap/webpack-configs": "^1.6.4",
|
|
41
41
|
"deepmerge": "^4.3.1",
|
|
42
42
|
"html-webpack-plugin": "^5.6.5",
|
|
43
43
|
"semver": "^7.7.3"
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"@eslint/js": "9.39.1",
|
|
47
47
|
"@rsbuild/core": "1.6.14",
|
|
48
48
|
"@rslib/core": "0.18.4",
|
|
49
|
-
"@types/node": "25.0.
|
|
49
|
+
"@types/node": "25.0.1",
|
|
50
50
|
"@types/semver": "7.7.1",
|
|
51
51
|
"@typescript-eslint/parser": "8.49.0",
|
|
52
|
-
"@workleap/eslint-configs": "1.1.
|
|
53
|
-
"@workleap/rslib-configs": "1.1.
|
|
52
|
+
"@workleap/eslint-configs": "1.1.7",
|
|
53
|
+
"@workleap/rslib-configs": "1.1.4",
|
|
54
54
|
"@workleap/typescript-configs": "3.0.7",
|
|
55
55
|
"eslint": "9.39.1",
|
|
56
56
|
"typescript": "5.9.3",
|
package/src/defineConfig.ts
CHANGED
|
@@ -59,6 +59,7 @@ export interface Features {
|
|
|
59
59
|
i18next?: boolean;
|
|
60
60
|
environmentVariables?: boolean;
|
|
61
61
|
honeycomb?: boolean;
|
|
62
|
+
launchDarkly?: boolean;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
// Generally, only the host application should have eager dependencies.
|
|
@@ -126,13 +127,27 @@ function getHoneycombSharedDependencies(isHost: boolean): ModuleFederationShared
|
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
function getLaunchDarklySharedDependencies(isHost: boolean): ModuleFederationShared {
|
|
131
|
+
return {
|
|
132
|
+
"@squide/launch-darkly": {
|
|
133
|
+
singleton: true,
|
|
134
|
+
eager: isHost ? true : undefined
|
|
135
|
+
},
|
|
136
|
+
"launchdarkly-js-client-sdk": {
|
|
137
|
+
singleton: true,
|
|
138
|
+
eager: isHost ? true : undefined
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
129
143
|
function getFeaturesDependencies(features: Features, isHost: boolean) {
|
|
130
144
|
const {
|
|
131
145
|
router = "react-router",
|
|
132
146
|
msw = true,
|
|
133
147
|
i18next,
|
|
134
148
|
environmentVariables = true,
|
|
135
|
-
honeycomb = true
|
|
149
|
+
honeycomb = true,
|
|
150
|
+
launchDarkly = true
|
|
136
151
|
} = features;
|
|
137
152
|
|
|
138
153
|
return {
|
|
@@ -140,7 +155,8 @@ function getFeaturesDependencies(features: Features, isHost: boolean) {
|
|
|
140
155
|
...(msw ? getMswSharedDependency(isHost) : {}),
|
|
141
156
|
...(i18next ? getI18nextSharedDependency(isHost) : {}),
|
|
142
157
|
...(environmentVariables ? getEnvironmentVariablesSharedDependencies(isHost) : {}),
|
|
143
|
-
...(honeycomb ? getHoneycombSharedDependencies(isHost) : {})
|
|
158
|
+
...(honeycomb ? getHoneycombSharedDependencies(isHost) : {}),
|
|
159
|
+
...(launchDarkly ? getLaunchDarklySharedDependencies(isHost) : {})
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
162
|
|