every-plugin 2.4.3 → 2.5.1
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/dist/build/rspack/plugin.cjs +1 -2
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +1 -2
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +0 -8
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts +0 -14
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts +0 -14
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs +0 -8
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +21 -11
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts +16 -21
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts +16 -21
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +20 -11
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +4 -6
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +5 -7
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/package.json +1 -1
- package/src/build/rspack/plugin.ts +0 -1
- package/src/build/shared-deps.ts +0 -8
- package/src/runtime/mf-config.ts +39 -10
- package/src/runtime/services/module-federation.service.ts +10 -9
|
@@ -156,8 +156,7 @@ var EveryPluginDevServer = class {
|
|
|
156
156
|
compiler.options.resolve.fallback = {
|
|
157
157
|
...compiler.options.resolve.fallback,
|
|
158
158
|
bufferutil: false,
|
|
159
|
-
"utf-8-validate": false
|
|
160
|
-
"@opentelemetry/api": false
|
|
159
|
+
"utf-8-validate": false
|
|
161
160
|
};
|
|
162
161
|
}
|
|
163
162
|
ensureTypeScriptLoader(compiler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["getPluginInfo","path","fs","crypto","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\n library: { type: \"commonjs-module\" },\n exposes: {\n \"./plugin\": \"./src/index.ts\",\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: \"version-first\",\n }).apply(compiler);\n\n if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = \"auto\";\n compiler.options.output.path = path.resolve(context, \"dist\");\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: \"commonjs-module\" };\n\n if (!compiler.options.target) {\n compiler.options.target = \"async-node\";\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === \"development\" ? \"development\" : \"production\";\n }\n\n if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n \"@opentelemetry/api\": false,\n };\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n const hasTsLoader = compiler.options.module.rules.some(\n (rule: any) =>\n typeof rule === \"object\" &&\n rule !== null &&\n \"test\" in rule &&\n rule.test instanceof RegExp &&\n rule.test.test(\".ts\"),\n );\n\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: \"builtin:swc-loader\",\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return;\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, \"dist\");\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, PATCH, OPTIONS\",\n \"Access-Control-Allow-Headers\": \"X-Requested-With, content-type, Authorization\",\n };\n\n compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAC9D,OAAO;CAEP,YAAY,AAAQ,UAAwC,EAAE,EAAE;EAA5C;;CAEpB,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAAI,KAAK,OAAO,gBAAgB;GAC7D,MAAM,UAAW,SAA0C;GAC3D,MAAM,YAAY,SAAS,SAAS;GACpC,MAAM,QAAQ,SAAS,aAAa,kCAAkC;AAEtE,eAAY,MAAM,cAAc,WAAW;IAAE,MAAM,KAAK;IAAM;IAAO,EAAE,YAAY;IACjF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;IACzD,MAAM,aAAaA,4BAAc,QAAQ;IACzC,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAC1D,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAE1D,MAAM,qBAAqBC,kBAAK,KAAK,SAAS,SAAS,iBAAiB;IAExE,IAAI;IAEJ,MAAM,cAAc,OAAO,aAA6C;AACtE,SAAI,CAACC,gBAAG,WAAW,SAAS,CAC1B,QAAO;AAGT,SAAI,CADUA,gBAAG,SAAS,SAAS,CACxB,QAAQ,CACjB,QAAO;AAET,SAAI;AACF,aAAO,MAAMA,gBAAG,SAAS,SAAS,UAAU,OAAO;aAC7C;AACN,aAAO;;;AAIX,oBAAiB,MAAM,YAAY,mBAAmB,IAA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ACC,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,KAAK,gBAAgB,UACrB,KAAK,KAAK,KAAK,MAAM,CACxB,CAGC,UAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,KAAK;GACL,SAAS;GACV,CAAC;;CAIN,AAAQ,mBAAmB,UAAoB,YAAiB,WAAgB,MAAc;AAC5F,MAAI,CAAC,SAAS,QAAQ,UACpB;EAGF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;EACzD,MAAM,gBAAgB,SAAS,QAAQ,UAAU;AAEjD,WAAS,QAAQ,UAAU,OAAO;AAClC,WAAS,QAAQ,UAAU,SAASA,kBAAK,KAAK,SAAS,OAAO;AAC9D,WAAS,QAAQ,UAAU,MAAM;AACjC,WAAS,QAAQ,UAAU,gBAAgB,EAAE,aAAa,MAAM;AAChE,WAAS,QAAQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;GACjC;AAED,WAAS,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;IACT;GACF;AAED,WAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;AACxE,uDAAsB,WAAW,YAAY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["getPluginInfo","path","fs","crypto","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\n library: { type: \"commonjs-module\" },\n exposes: {\n \"./plugin\": \"./src/index.ts\",\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: \"version-first\",\n }).apply(compiler);\n\n if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = \"auto\";\n compiler.options.output.path = path.resolve(context, \"dist\");\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: \"commonjs-module\" };\n\n if (!compiler.options.target) {\n compiler.options.target = \"async-node\";\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === \"development\" ? \"development\" : \"production\";\n }\n\n if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n };\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n const hasTsLoader = compiler.options.module.rules.some(\n (rule: any) =>\n typeof rule === \"object\" &&\n rule !== null &&\n \"test\" in rule &&\n rule.test instanceof RegExp &&\n rule.test.test(\".ts\"),\n );\n\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: \"builtin:swc-loader\",\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return;\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, \"dist\");\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, PATCH, OPTIONS\",\n \"Access-Control-Allow-Headers\": \"X-Requested-With, content-type, Authorization\",\n };\n\n compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAC9D,OAAO;CAEP,YAAY,AAAQ,UAAwC,EAAE,EAAE;EAA5C;;CAEpB,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAAI,KAAK,OAAO,gBAAgB;GAC7D,MAAM,UAAW,SAA0C;GAC3D,MAAM,YAAY,S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,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;IACT;GACF;AAED,WAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;AACxE,uDAAsB,WAAW,YAAY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;UASiB,kBAAA;EACf,aAAA;EACA,IAAA;EACA,QAAA;EACA,GAAA;AAAA;AAAA,UAGe,gBAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,4BAAA;EACf,gBAAA;EACA,gBAAA;EACA,iBAAA,GAAoB,gBAAA;AAAA;AAAA,cAGT,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAiHL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;UASiB,kBAAA;EACf,aAAA;EACA,IAAA;EACA,QAAA;EACA,GAAA;AAAA;AAAA,UAGe,gBAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,4BAAA;EACf,gBAAA;EACA,gBAAA;EACA,iBAAA,GAAoB,gBAAA;AAAA;AAAA,cAGT,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAiHL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,QA6DA,sBAAA;EAAA,QA2BA,kBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;UASiB,kBAAA;EACf,aAAA;EACA,IAAA;EACA,QAAA;EACA,GAAA;AAAA;AAAA,UAGe,gBAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,4BAAA;EACf,gBAAA;EACA,gBAAA;EACA,iBAAA,GAAoB,gBAAA;AAAA;AAAA,cAGT,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAiHL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;UASiB,kBAAA;EACf,aAAA;EACA,IAAA;EACA,QAAA;EACA,GAAA;AAAA;AAAA,UAGe,gBAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,4BAAA;EACf,gBAAA;EACA,gBAAA;EACA,iBAAA,GAAoB,gBAAA;AAAA;AAAA,cAGT,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAiHL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,QA6DA,sBAAA;EAAA,QA2BA,kBAAA;AAAA"}
|
|
@@ -153,8 +153,7 @@ var EveryPluginDevServer = class {
|
|
|
153
153
|
compiler.options.resolve.fallback = {
|
|
154
154
|
...compiler.options.resolve.fallback,
|
|
155
155
|
bufferutil: false,
|
|
156
|
-
"utf-8-validate": false
|
|
157
|
-
"@opentelemetry/api": false
|
|
156
|
+
"utf-8-validate": false
|
|
158
157
|
};
|
|
159
158
|
}
|
|
160
159
|
ensureTypeScriptLoader(compiler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\n library: { type: \"commonjs-module\" },\n exposes: {\n \"./plugin\": \"./src/index.ts\",\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: \"version-first\",\n }).apply(compiler);\n\n if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = \"auto\";\n compiler.options.output.path = path.resolve(context, \"dist\");\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: \"commonjs-module\" };\n\n if (!compiler.options.target) {\n compiler.options.target = \"async-node\";\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === \"development\" ? \"development\" : \"production\";\n }\n\n if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n \"@opentelemetry/api\": false,\n };\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n const hasTsLoader = compiler.options.module.rules.some(\n (rule: any) =>\n typeof rule === \"object\" &&\n rule !== null &&\n \"test\" in rule &&\n rule.test instanceof RegExp &&\n rule.test.test(\".ts\"),\n );\n\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: \"builtin:swc-loader\",\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return;\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, \"dist\");\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, PATCH, OPTIONS\",\n \"Access-Control-Allow-Headers\": \"X-Requested-With, content-type, Authorization\",\n };\n\n compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAC9D,OAAO;CAEP,YAAY,AAAQ,UAAwC,EAAE,EAAE;EAA5C;;CAEpB,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAAI,KAAK,OAAO,gBAAgB;GAC7D,MAAM,UAAW,SAA0C;GAC3D,MAAM,YAAY,SAAS,SAAS;GACpC,MAAM,QAAQ,SAAS,aAAa,kCAAkC;AAEtE,eAAY,MAAM,cAAc,WAAW;IAAE,MAAM,KAAK;IAAM;IAAO,EAAE,YAAY;IACjF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;IACzD,MAAM,aAAa,cAAc,QAAQ;IACzC,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAC1D,MAAM,mBAAmB,KAAK,QAAQ,oBAAoB;IAE1D,MAAM,qBAAqB,KAAK,KAAK,SAAS,SAAS,iBAAiB;IAExE,IAAI;IAEJ,MAAM,cAAc,OAAO,aAA6C;AACtE,SAAI,CAAC,GAAG,WAAW,SAAS,CAC1B,QAAO;AAGT,SAAI,CADU,GAAG,SAAS,S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AAI,CAAC,SAAS,QAAQ,OAAO,MAC3B,UAAS,QAAQ,OAAO,QAAQ,EAAE;AAYpC,MAAI,CATgB,SAAS,QAAQ,OAAO,MAAM,MAC/C,SACC,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,KAAK,gBAAgB,UACrB,KAAK,KAAK,KAAK,MAAM,CACxB,CAGC,UAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,KAAK;GACL,SAAS;GACV,CAAC;;CAIN,AAAQ,mBAAmB,UAAoB,YAAiB,WAAgB,MAAc;AAC5F,MAAI,CAAC,SAAS,QAAQ,UACpB;EAGF,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;EACzD,MAAM,gBAAgB,SAAS,QAAQ,UAAU;AAEjD,WAAS,QAAQ,UAAU,OAAO;AAClC,WAAS,QAAQ,UAAU,SAAS,KAAK,KAAK,SAAS,OAAO;AAC9D,WAAS,QAAQ,UAAU,MAAM;AACjC,WAAS,QAAQ,UAAU,gBAAgB,EAAE,aAAa,MAAM;AAChE,WAAS,QAAQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;GACjC;AAED,WAAS,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;IACT;GACF;AAED,WAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;AACxE,yBAAsB,WAAW,YAAY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleFederationPlugin } from \"@module-federation/enhanced/rspack\";\nimport type { Compiler, RspackPluginInstance } from \"@rspack/core\";\nimport { setupPluginMiddleware } from \"./dev-server-middleware\";\nimport { buildSharedDependencies } from \"./module-federation\";\nimport { getPluginInfo, loadDevConfig } from \"./utils\";\n\nexport interface EveryPluginOptions {\n devConfigPath?: string;\n port?: number;\n pluginId?: string;\n dts?: boolean;\n}\n\nexport interface AdditionalExport {\n srcPath: string;\n exportNames: string[];\n}\n\nexport interface PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\n additionalExports?: AdditionalExport[];\n}\n\nexport class EmitPluginManifest implements RspackPluginInstance {\n name = \"EmitPluginManifest\";\n\n constructor(private options: PluginManifestEmitterOptions = {}) {}\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(this.name, (compilation) => {\n const webpack = (compiler as Compiler & { webpack?: any }).webpack;\n const rawSource = webpack?.sources?.RawSource;\n const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1000;\n\n compilation.hooks.processAssets.tapPromise({ name: this.name, stage }, async () => {\n const context = compiler.options.context || process.cwd();\n const pluginInfo = getPluginInfo(context);\n const contractFileName = this.options.contractFileName ?? \"contract.d.ts\";\n const manifestFileName = this.options.manifestFileName ?? \"plugin.manifest.json\";\n\n const sourceContractPath = path.join(context, \"types\", contractFileName);\n\n let contractTypes: string;\n\n const tryReadFile = async (filePath: string): Promise<string | null> => {\n if (!fs.existsSync(filePath)) {\n return null;\n }\n const stats = fs.statSync(filePath);\n if (!stats.isFile()) {\n return null;\n }\n try {\n return await fs.promises.readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n };\n\n contractTypes = (await tryReadFile(sourceContractPath)) ?? \"\";\n\n if (!contractTypes) {\n const packageDir = context.split(\"/\").pop();\n const nestedPath = path.join(context, \"types\", packageDir ?? \"\", \"src\", contractFileName);\n\n contractTypes = (await tryReadFile(nestedPath)) ?? \"\";\n\n if (!contractTypes) {\n console.warn(\n `[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. ` +\n `Skipping manifest generation.`,\n );\n return;\n }\n }\n\n const contractSha256 = crypto.createHash(\"sha256\").update(contractTypes).digest(\"hex\");\n const manifest: Record<string, unknown> = {\n schemaVersion: 1,\n kind: \"every-plugin/manifest\",\n plugin: {\n name: pluginInfo.name,\n version: pluginInfo.version,\n },\n runtime: {\n remoteEntry: \"./remoteEntry.js\",\n },\n contract: {\n kind: \"orpc\",\n types: {\n path: `./types/${contractFileName}`,\n exportName: \"contract\",\n typeName: \"ContractType\",\n sha256: contractSha256,\n },\n },\n };\n\n const additionalExportsEntries: Array<{ path: string; exports: string[]; sha256: string }> =\n [];\n\n if (this.options.additionalExports?.length) {\n for (const additional of this.options.additionalExports) {\n const sourcePath = path.join(context, \"types\", additional.srcPath);\n const content = await tryReadFile(sourcePath);\n if (!content) {\n console.warn(\n `[EmitPluginManifest] Additional export file not found at ${sourcePath}. Skipping.`,\n );\n continue;\n }\n const sha256 = crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n const distPath = `./types/${additional.srcPath}`;\n additionalExportsEntries.push({\n path: distPath,\n exports: additional.exportNames,\n sha256,\n });\n\n if (rawSource) {\n compilation.emitAsset(`types/${additional.srcPath}`, new rawSource(content));\n }\n }\n\n if (additionalExportsEntries.length > 0) {\n manifest.additionalExports = additionalExportsEntries;\n }\n }\n\n if (rawSource) {\n compilation.emitAsset(\n manifestFileName,\n new rawSource(`${JSON.stringify(manifest, null, 2)}\\n`),\n );\n compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));\n }\n });\n });\n }\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = \"EveryPluginDevServer\";\n\n constructor(private options: EveryPluginOptions = {}) {}\n\n apply(compiler: Compiler) {\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || \"./plugin.dev.ts\");\n const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;\n\n this.configureDefaults(compiler, pluginInfo);\n\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: \"remoteEntry.js\",\n dts: this.options.dts !== false,\n manifest: {},\n runtimePlugins: [require.resolve(\"@module-federation/node/runtimePlugin\")],\n library: { type: \"commonjs-module\" },\n exposes: {\n \"./plugin\": \"./src/index.ts\",\n },\n shared: buildSharedDependencies(pluginInfo),\n shareStrategy: \"version-first\",\n }).apply(compiler);\n\n if (this.options.dts === false) {\n compiler.options.plugins = (compiler.options.plugins ?? []).filter(\n (p) =>\n !p ||\n typeof p !== \"object\" ||\n ((p as any).name !== \"MFDevPlugin\" && (p as any).name !== \"ModuleFederationDtsPlugin\"),\n );\n }\n }\n\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n if (!compiler.options.output) {\n compiler.options.output = {};\n }\n compiler.options.output.uniqueName = pluginInfo.normalizedName;\n compiler.options.output.publicPath = \"auto\";\n compiler.options.output.path = path.resolve(context, \"dist\");\n compiler.options.output.clean = true;\n compiler.options.output.library = { type: \"commonjs-module\" };\n\n if (!compiler.options.target) {\n compiler.options.target = \"async-node\";\n }\n\n if (!compiler.options.mode) {\n compiler.options.mode = process.env.NODE_ENV === \"development\" ? \"development\" : \"production\";\n }\n\n if (compiler.options.devtool === undefined) {\n compiler.options.devtool = \"source-map\";\n }\n\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: \"warn\",\n };\n }\n\n this.ensureTypeScriptLoader(compiler);\n\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = [\"...\", \".tsx\", \".ts\"];\n compiler.options.resolve.conditionNames = [\n \"webpack\",\n \"import\",\n \"module\",\n \"require\",\n \"node\",\n \"default\",\n ];\n if (compiler.options.resolve.byDependency) {\n for (const depType of Object.keys(compiler.options.resolve.byDependency)) {\n const depConfig = (\n compiler.options.resolve.byDependency as Record<string, { conditionNames?: string[] }>\n )[depType];\n if (depConfig?.conditionNames) {\n depConfig.conditionNames = depConfig.conditionNames.filter((c) => c !== \"development\");\n }\n }\n }\n compiler.options.resolve.fallback = {\n ...compiler.options.resolve.fallback,\n bufferutil: false,\n \"utf-8-validate\": false,\n };\n }\n\n private ensureTypeScriptLoader(compiler: Compiler) {\n if (!compiler.options.module) {\n compiler.options.module = { rules: [] } as any;\n }\n\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n const hasTsLoader = compiler.options.module.rules.some(\n (rule: any) =>\n typeof rule === \"object\" &&\n rule !== null &&\n \"test\" in rule &&\n rule.test instanceof RegExp &&\n rule.test.test(\".ts\"),\n );\n\n if (!hasTsLoader) {\n compiler.options.module.rules.push({\n test: /\\.tsx?$/,\n use: \"builtin:swc-loader\",\n exclude: /node_modules/,\n });\n }\n }\n\n private configureDevServer(compiler: Compiler, pluginInfo: any, devConfig: any, port: number) {\n if (!compiler.options.devServer) {\n return;\n }\n\n const context = compiler.options.context || process.cwd();\n const originalSetup = compiler.options.devServer.setupMiddlewares;\n\n compiler.options.devServer.port = port;\n compiler.options.devServer.static = path.join(context, \"dist\");\n compiler.options.devServer.hot = true;\n compiler.options.devServer.devMiddleware = { writeToDisk: true };\n compiler.options.devServer.headers = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, PATCH, OPTIONS\",\n \"Access-Control-Allow-Headers\": \"X-Requested-With, content-type, Authorization\",\n };\n\n compiler.options.devServer.client = {\n logging: \"warn\",\n overlay: {\n warnings: false,\n errors: true,\n },\n };\n\n compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {\n setupPluginMiddleware(devServer, pluginInfo, devConfig, port);\n return originalSetup ? originalSetup(middlewares, devServer) : middlewares;\n };\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,IAAa,qBAAb,MAAgE;CAC9D,OAAO;CAEP,YAAY,AAAQ,UAAwC,EAAE,EAAE;EAA5C;;CAEpB,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAAI,KAAK,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,gCAAgC;GACjC;AAED,WAAS,QAAQ,UAAU,SAAS;GAClC,SAAS;GACT,SAAS;IACP,UAAU;IACV,QAAQ;IACT;GACF;AAED,WAAS,QAAQ,UAAU,oBAAoB,aAAa,cAAc;AACxE,yBAAsB,WAAW,YAAY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
|
@@ -44,14 +44,6 @@ const pluginSharedDependencies = {
|
|
|
44
44
|
version: getInstalledPackageVersion("zod", pkg.peerDependencies.zod),
|
|
45
45
|
...DEFAULT_SHARE_CONFIG
|
|
46
46
|
},
|
|
47
|
-
"better-auth": {
|
|
48
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
49
|
-
...DEFAULT_SHARE_CONFIG
|
|
50
|
-
},
|
|
51
|
-
"drizzle-orm": {
|
|
52
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
53
|
-
...DEFAULT_SHARE_CONFIG
|
|
54
|
-
},
|
|
55
47
|
"@orpc/contract": {
|
|
56
48
|
version: getInstalledPackageVersion("@orpc/contract", pkg.peerDependencies["@orpc/contract"]),
|
|
57
49
|
...DEFAULT_SHARE_CONFIG
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.cjs","names":["__dirname","require"],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"
|
|
1
|
+
{"version":3,"file":"shared-deps.cjs","names":["__dirname","require"],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\^~>=<]+/, \"\");\n const match = clean.match(/^(\\d+)\\.(\\d+)/);\n if (!match) return \"^0.0.0\";\n return `^${match[1]}.${match[2]}.0`;\n}\n"],"mappings":";;;;;;;;AAKA,MAAMA,+GAAkD,CAAC;AACzD,MAAMC,yFAAwC;AAE9C,IAAI;AAEJ,IAAI;AACF,OAAM,KAAK,oDAAwBD,aAAW,qBAAqB,EAAE,QAAQ,CAAC;QACxE;AACN,OAAMC,UAAQ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
|
-
requiredVersion: string | false;
|
|
34
|
-
singleton: boolean;
|
|
35
|
-
strictVersion: boolean;
|
|
36
|
-
eager: boolean;
|
|
37
|
-
version: string;
|
|
38
|
-
};
|
|
39
|
-
"drizzle-orm": {
|
|
40
|
-
requiredVersion: string | false;
|
|
41
|
-
singleton: boolean;
|
|
42
|
-
strictVersion: boolean;
|
|
43
|
-
eager: boolean;
|
|
44
|
-
version: string;
|
|
45
|
-
};
|
|
46
32
|
"@orpc/contract": {
|
|
47
33
|
requiredVersion: string | false;
|
|
48
34
|
singleton: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA
|
|
1
|
+
{"version":3,"file":"shared-deps.d.cts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBD,0BAAA,gBAA0C,wBAAA;AAAA,iBAEtC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAI/B,uCAAA,CAAA,GAA2C,MAAA;AAAA,iBAS3C,oBAAA,CAAqB,OAAA"}
|
|
@@ -29,20 +29,6 @@ declare const pluginSharedDependencies: {
|
|
|
29
29
|
eager: boolean;
|
|
30
30
|
version: string;
|
|
31
31
|
};
|
|
32
|
-
"better-auth": {
|
|
33
|
-
requiredVersion: string | false;
|
|
34
|
-
singleton: boolean;
|
|
35
|
-
strictVersion: boolean;
|
|
36
|
-
eager: boolean;
|
|
37
|
-
version: string;
|
|
38
|
-
};
|
|
39
|
-
"drizzle-orm": {
|
|
40
|
-
requiredVersion: string | false;
|
|
41
|
-
singleton: boolean;
|
|
42
|
-
strictVersion: boolean;
|
|
43
|
-
eager: boolean;
|
|
44
|
-
version: string;
|
|
45
|
-
};
|
|
46
32
|
"@orpc/contract": {
|
|
47
33
|
requiredVersion: string | false;
|
|
48
34
|
singleton: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA
|
|
1
|
+
{"version":3,"file":"shared-deps.d.mts","names":[],"sources":["../../src/build/shared-deps.ts"],"mappings":";UAgBiB,sBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;AAAA;AAAA,KAGU,kBAAA,GAAqB,MAAA,SAAe,sBAAA;AAAA,cAsBnC,wBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBD,0BAAA,gBAA0C,wBAAA;AAAA,iBAEtC,2BAAA,CAAA,GAA+B,kBAAA;AAAA,iBAI/B,uCAAA,CAAA,GAA2C,MAAA;AAAA,iBAS3C,oBAAA,CAAqB,OAAA"}
|
|
@@ -42,14 +42,6 @@ const pluginSharedDependencies = {
|
|
|
42
42
|
version: getInstalledPackageVersion("zod", pkg.peerDependencies.zod),
|
|
43
43
|
...DEFAULT_SHARE_CONFIG
|
|
44
44
|
},
|
|
45
|
-
"better-auth": {
|
|
46
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
47
|
-
...DEFAULT_SHARE_CONFIG
|
|
48
|
-
},
|
|
49
|
-
"drizzle-orm": {
|
|
50
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
51
|
-
...DEFAULT_SHARE_CONFIG
|
|
52
|
-
},
|
|
53
45
|
"@orpc/contract": {
|
|
54
46
|
version: getInstalledPackageVersion("@orpc/contract", pkg.peerDependencies["@orpc/contract"]),
|
|
55
47
|
...DEFAULT_SHARE_CONFIG
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps.mjs","names":[],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"
|
|
1
|
+
{"version":3,"file":"shared-deps.mjs","names":[],"sources":["../../src/build/shared-deps.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\nlet pkg: typeof import(\"../../package.json\");\n\ntry {\n pkg = JSON.parse(readFileSync(join(__dirname, \"../../package.json\"), \"utf-8\"));\n} catch {\n pkg = require(\"every-plugin/package.json\");\n}\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nconst DEFAULT_SHARE_CONFIG: Omit<SharedDependencyConfig, \"version\"> = {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n};\n\nfunction extractExactVersion(input: string): string {\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : input.replace(/^[\\^~>=<\\s]+/, \"\");\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackVersion: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n return extractExactVersion(fallbackVersion);\n }\n}\n\nexport const pluginSharedDependencies = {\n \"every-plugin\": { version: pkg.version, ...DEFAULT_SHARE_CONFIG },\n effect: {\n version: getInstalledPackageVersion(\"effect\", pkg.peerDependencies.effect),\n ...DEFAULT_SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", pkg.peerDependencies.zod),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", pkg.peerDependencies[\"@orpc/contract\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", pkg.peerDependencies[\"@orpc/server\"]),\n ...DEFAULT_SHARE_CONFIG,\n },\n} satisfies SharedDependencies;\n\nexport type PluginSharedDependencyName = keyof typeof pluginSharedDependencies;\n\nexport function getPluginSharedDependencies(): SharedDependencies {\n return pluginSharedDependencies;\n}\n\nexport function getPluginSharedDependenciesVersionRange(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies()).map(([name, config]) => [\n name,\n getMajorMinorVersion(config.version),\n ]),\n );\n}\n\nexport function getMajorMinorVersion(version: string): string {\n const clean = version.replace(/^[\\^~>=<]+/, \"\");\n const match = clean.match(/^(\\d+)\\.(\\d+)/);\n if (!match) return \"^0.0.0\";\n return `^${match[1]}.${match[2]}.0`;\n}\n"],"mappings":";;;;;;AAKA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AACzD,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAI;AAEJ,IAAI;AACF,OAAM,KAAK,MAAM,aAAa,KAAK,WAAW,qBAAqB,EAAE,QAAQ,CAAC;QACxE;AACN,OAAM,QAAQ,4BAA4B;;AAa5C,MAAM,uBAAgE;CACpE,iBAAiB;CACjB,WAAW;CACX,eAAe;CACf,OAAO;CACR;AAED,SAAS,oBAAoB,OAAuB;CAClD,MAAM,QAAQ,MAAM,MAAM,oCAAoC;AAC9D,QAAO,QAAQ,MAAM,KAAK,MAAM,QAAQ,gBAAgB,GAAG;;AAG7D,SAAS,2BAA2B,aAAqB,iBAAiC;AACxF,KAAI;AACF,SAAO,QAAQ,GAAG,YAAY,eAAe,CAAC;SACxC;AACN,SAAO,oBAAoB,gBAAgB;;;AAI/C,MAAa,2BAA2B;CACtC,gBAAgB;EAAE,SAAS,IAAI;EAAS,GAAG;EAAsB;CACjE,QAAQ;EACN,SAAS,2BAA2B,UAAU,IAAI,iBAAiB,OAAO;EAC1E,GAAG;EACJ;CACD,KAAK;EACH,SAAS,2BAA2B,OAAO,IAAI,iBAAiB,IAAI;EACpE,GAAG;EACJ;CACD,kBAAkB;EAChB,SAAS,2BAA2B,kBAAkB,IAAI,iBAAiB,kBAAkB;EAC7F,GAAG;EACJ;CACD,gBAAgB;EACd,SAAS,2BAA2B,gBAAgB,IAAI,iBAAiB,gBAAgB;EACzF,GAAG;EACJ;CACF;AAID,SAAgB,8BAAkD;AAChE,QAAO;;AAGT,SAAgB,0CAAkE;AAChF,QAAO,OAAO,YACZ,OAAO,QAAQ,6BAA6B,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CACpE,MACA,qBAAqB,OAAO,QAAQ,CACrC,CAAC,CACH;;AAGH,SAAgB,qBAAqB,SAAyB;CAE5D,MAAM,QADQ,QAAQ,QAAQ,cAAc,GAAG,CAC3B,MAAM,gBAAgB;AAC1C,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG"}
|
|
@@ -12,14 +12,14 @@ function getInstalledPackageVersion(packageName, fallbackRange) {
|
|
|
12
12
|
return match ? match[0] : fallbackRange.replace(/^[\^~>=<\s]+/, "");
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const PLUGIN_VERSION = "2.
|
|
15
|
+
const PLUGIN_VERSION = "2.5.1";
|
|
16
16
|
const SHARE_CONFIG = {
|
|
17
17
|
singleton: true,
|
|
18
18
|
requiredVersion: false,
|
|
19
19
|
strictVersion: false,
|
|
20
20
|
eager: false
|
|
21
21
|
};
|
|
22
|
-
const
|
|
22
|
+
const MF_CORE_SHARED_DEPS = {
|
|
23
23
|
"every-plugin": {
|
|
24
24
|
version: PLUGIN_VERSION,
|
|
25
25
|
shareConfig: SHARE_CONFIG
|
|
@@ -32,14 +32,6 @@ const MF_SHARED_DEPS = {
|
|
|
32
32
|
version: getInstalledPackageVersion("zod", "^4.3.6"),
|
|
33
33
|
shareConfig: SHARE_CONFIG
|
|
34
34
|
},
|
|
35
|
-
"better-auth": {
|
|
36
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
37
|
-
shareConfig: SHARE_CONFIG
|
|
38
|
-
},
|
|
39
|
-
"drizzle-orm": {
|
|
40
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
41
|
-
shareConfig: SHARE_CONFIG
|
|
42
|
-
},
|
|
43
35
|
"@orpc/contract": {
|
|
44
36
|
version: getInstalledPackageVersion("@orpc/contract", "^1.13.4"),
|
|
45
37
|
shareConfig: SHARE_CONFIG
|
|
@@ -49,9 +41,27 @@ const MF_SHARED_DEPS = {
|
|
|
49
41
|
shareConfig: SHARE_CONFIG
|
|
50
42
|
}
|
|
51
43
|
};
|
|
44
|
+
function buildMergedSharedDeps(appShared) {
|
|
45
|
+
const merged = {};
|
|
46
|
+
for (const [name, config] of Object.entries(MF_CORE_SHARED_DEPS)) merged[name] = {
|
|
47
|
+
version: config.version,
|
|
48
|
+
shareConfig: config.shareConfig
|
|
49
|
+
};
|
|
50
|
+
if (appShared) for (const [name, config] of Object.entries(appShared)) merged[name] = {
|
|
51
|
+
version: config.version,
|
|
52
|
+
shareConfig: {
|
|
53
|
+
singleton: config.singleton ?? true,
|
|
54
|
+
requiredVersion: config.requiredVersion ?? false,
|
|
55
|
+
strictVersion: config.strictVersion ?? false,
|
|
56
|
+
eager: config.eager ?? false
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return merged;
|
|
60
|
+
}
|
|
52
61
|
|
|
53
62
|
//#endregion
|
|
54
|
-
exports.
|
|
63
|
+
exports.MF_CORE_SHARED_DEPS = MF_CORE_SHARED_DEPS;
|
|
55
64
|
exports.PLUGIN_VERSION = PLUGIN_VERSION;
|
|
56
65
|
exports.SHARE_CONFIG = SHARE_CONFIG;
|
|
66
|
+
exports.buildMergedSharedDeps = buildMergedSharedDeps;
|
|
57
67
|
//# sourceMappingURL=mf-config.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mf-config.cjs","names":["require"],"sources":["../../src/runtime/mf-config.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\ndeclare const __EVERY_PLUGIN_VERSION__: string | undefined;\n\nfunction readPackageVersion(): string {\n try {\n return (require(\"../../package.json\") as { version: string }).version;\n } catch {\n return \"0.0.0\";\n }\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackRange: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n const match = fallbackRange.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : fallbackRange.replace(/^[\\^~>=<\\s]+/, \"\");\n }\n}\n\nexport const PLUGIN_VERSION =\n typeof __EVERY_PLUGIN_VERSION__ === \"string\" ? __EVERY_PLUGIN_VERSION__ : readPackageVersion();\n\nexport const SHARE_CONFIG = {\n singleton: true,\n requiredVersion: false,\n strictVersion: false,\n eager: false,\n} as const;\n\nexport const
|
|
1
|
+
{"version":3,"file":"mf-config.cjs","names":["require"],"sources":["../../src/runtime/mf-config.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\ndeclare const __EVERY_PLUGIN_VERSION__: string | undefined;\n\nfunction readPackageVersion(): string {\n try {\n return (require(\"../../package.json\") as { version: string }).version;\n } catch {\n return \"0.0.0\";\n }\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackRange: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n const match = fallbackRange.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : fallbackRange.replace(/^[\\^~>=<\\s]+/, \"\");\n }\n}\n\nexport const PLUGIN_VERSION =\n typeof __EVERY_PLUGIN_VERSION__ === \"string\" ? __EVERY_PLUGIN_VERSION__ : readPackageVersion();\n\nexport const SHARE_CONFIG = {\n singleton: true,\n requiredVersion: false,\n strictVersion: false,\n eager: false,\n} as const;\n\nexport const MF_CORE_SHARED_DEPS = {\n \"every-plugin\": {\n version: PLUGIN_VERSION,\n shareConfig: SHARE_CONFIG,\n },\n effect: {\n version: getInstalledPackageVersion(\"effect\", \"^3.21.0\"),\n shareConfig: SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", \"^4.3.6\"),\n shareConfig: SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", \"^1.13.4\"),\n shareConfig: SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", \"^1.13.4\"),\n shareConfig: SHARE_CONFIG,\n },\n} as const;\n\nexport type CoreSharedDepName = keyof typeof MF_CORE_SHARED_DEPS;\n\nexport interface AppSharedDepConfig {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n}\n\nexport type AppSharedDeps = Record<string, AppSharedDepConfig>;\n\nexport function buildMergedSharedDeps(\n appShared?: AppSharedDeps,\n): Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> {\n const merged: Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> = {};\n\n for (const [name, config] of Object.entries(MF_CORE_SHARED_DEPS)) {\n merged[name] = { version: config.version, shareConfig: config.shareConfig };\n }\n\n if (appShared) {\n for (const [name, config] of Object.entries(appShared)) {\n merged[name] = {\n version: config.version,\n shareConfig: {\n singleton: (config.singleton ?? true) as true,\n requiredVersion: (config.requiredVersion ?? false) as false,\n strictVersion: (config.strictVersion ?? false) as false,\n eager: (config.eager ?? false) as false,\n },\n };\n }\n }\n\n return merged;\n}\n"],"mappings":";;;;;AAEA,MAAMA,yFAAwC;AAW9C,SAAS,2BAA2B,aAAqB,eAA+B;AACtF,KAAI;AACF,SAAOA,UAAQ,GAAG,YAAY,eAAe,CAAC;SACxC;EACN,MAAM,QAAQ,cAAc,MAAM,oCAAoC;AACtE,SAAO,QAAQ,MAAM,KAAK,cAAc,QAAQ,gBAAgB,GAAG;;;AAIvE,MAAa;AAGb,MAAa,eAAe;CAC1B,WAAW;CACX,iBAAiB;CACjB,eAAe;CACf,OAAO;CACR;AAED,MAAa,sBAAsB;CACjC,gBAAgB;EACd,SAAS;EACT,aAAa;EACd;CACD,QAAQ;EACN,SAAS,2BAA2B,UAAU,UAAU;EACxD,aAAa;EACd;CACD,KAAK;EACH,SAAS,2BAA2B,OAAO,SAAS;EACpD,aAAa;EACd;CACD,kBAAkB;EAChB,SAAS,2BAA2B,kBAAkB,UAAU;EAChE,aAAa;EACd;CACD,gBAAgB;EACd,SAAS,2BAA2B,gBAAgB,UAAU;EAC9D,aAAa;EACd;CACF;AAeD,SAAgB,sBACd,WACuE;CACvE,MAAM,SAAgF,EAAE;AAExF,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,oBAAoB,CAC9D,QAAO,QAAQ;EAAE,SAAS,OAAO;EAAS,aAAa,OAAO;EAAa;AAG7E,KAAI,UACF,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,UAAU,CACpD,QAAO,QAAQ;EACb,SAAS,OAAO;EAChB,aAAa;GACX,WAAY,OAAO,aAAa;GAChC,iBAAkB,OAAO,mBAAmB;GAC5C,eAAgB,OAAO,iBAAiB;GACxC,OAAQ,OAAO,SAAS;GACzB;EACF;AAIL,QAAO"}
|
|
@@ -6,7 +6,7 @@ declare const SHARE_CONFIG: {
|
|
|
6
6
|
readonly strictVersion: false;
|
|
7
7
|
readonly eager: false;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
9
|
+
declare const MF_CORE_SHARED_DEPS: {
|
|
10
10
|
readonly "every-plugin": {
|
|
11
11
|
readonly version: string;
|
|
12
12
|
readonly shareConfig: {
|
|
@@ -34,24 +34,6 @@ declare const MF_SHARED_DEPS: {
|
|
|
34
34
|
readonly eager: false;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
readonly "better-auth": {
|
|
38
|
-
readonly version: string;
|
|
39
|
-
readonly shareConfig: {
|
|
40
|
-
readonly singleton: true;
|
|
41
|
-
readonly requiredVersion: false;
|
|
42
|
-
readonly strictVersion: false;
|
|
43
|
-
readonly eager: false;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
readonly "drizzle-orm": {
|
|
47
|
-
readonly version: string;
|
|
48
|
-
readonly shareConfig: {
|
|
49
|
-
readonly singleton: true;
|
|
50
|
-
readonly requiredVersion: false;
|
|
51
|
-
readonly strictVersion: false;
|
|
52
|
-
readonly eager: false;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
37
|
readonly "@orpc/contract": {
|
|
56
38
|
readonly version: string;
|
|
57
39
|
readonly shareConfig: {
|
|
@@ -71,7 +53,20 @@ declare const MF_SHARED_DEPS: {
|
|
|
71
53
|
};
|
|
72
54
|
};
|
|
73
55
|
};
|
|
74
|
-
type
|
|
56
|
+
type CoreSharedDepName = keyof typeof MF_CORE_SHARED_DEPS;
|
|
57
|
+
interface AppSharedDepConfig {
|
|
58
|
+
version: string;
|
|
59
|
+
requiredVersion?: string | false;
|
|
60
|
+
singleton?: boolean;
|
|
61
|
+
strictVersion?: boolean;
|
|
62
|
+
eager?: boolean;
|
|
63
|
+
shareScope?: string;
|
|
64
|
+
}
|
|
65
|
+
type AppSharedDeps = Record<string, AppSharedDepConfig>;
|
|
66
|
+
declare function buildMergedSharedDeps(appShared?: AppSharedDeps): Record<string, {
|
|
67
|
+
version: string;
|
|
68
|
+
shareConfig: typeof SHARE_CONFIG;
|
|
69
|
+
}>;
|
|
75
70
|
//#endregion
|
|
76
|
-
export {
|
|
71
|
+
export { AppSharedDepConfig, AppSharedDeps, CoreSharedDepName, MF_CORE_SHARED_DEPS, PLUGIN_VERSION, SHARE_CONFIG, buildMergedSharedDeps };
|
|
77
72
|
//# sourceMappingURL=mf-config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mf-config.d.cts","names":[],"sources":["../../src/runtime/mf-config.ts"],"mappings":";cAsBa,cAAA;AAAA,cAGA,YAAA;EAAA;;;;;cAOA,
|
|
1
|
+
{"version":3,"file":"mf-config.d.cts","names":[],"sources":["../../src/runtime/mf-config.ts"],"mappings":";cAsBa,cAAA;AAAA,cAGA,YAAA;EAAA;;;;;cAOA,mBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuBD,iBAAA,gBAAiC,mBAAA;AAAA,UAE5B,kBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;EACA,UAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,MAAA,SAAe,kBAAA;AAAA,iBAE3B,qBAAA,CACd,SAAA,GAAY,aAAA,GACX,MAAA;EAAiB,OAAA;EAAiB,WAAA,SAAoB,YAAA;AAAA"}
|
|
@@ -6,7 +6,7 @@ declare const SHARE_CONFIG: {
|
|
|
6
6
|
readonly strictVersion: false;
|
|
7
7
|
readonly eager: false;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
9
|
+
declare const MF_CORE_SHARED_DEPS: {
|
|
10
10
|
readonly "every-plugin": {
|
|
11
11
|
readonly version: string;
|
|
12
12
|
readonly shareConfig: {
|
|
@@ -34,24 +34,6 @@ declare const MF_SHARED_DEPS: {
|
|
|
34
34
|
readonly eager: false;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
readonly "better-auth": {
|
|
38
|
-
readonly version: string;
|
|
39
|
-
readonly shareConfig: {
|
|
40
|
-
readonly singleton: true;
|
|
41
|
-
readonly requiredVersion: false;
|
|
42
|
-
readonly strictVersion: false;
|
|
43
|
-
readonly eager: false;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
readonly "drizzle-orm": {
|
|
47
|
-
readonly version: string;
|
|
48
|
-
readonly shareConfig: {
|
|
49
|
-
readonly singleton: true;
|
|
50
|
-
readonly requiredVersion: false;
|
|
51
|
-
readonly strictVersion: false;
|
|
52
|
-
readonly eager: false;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
37
|
readonly "@orpc/contract": {
|
|
56
38
|
readonly version: string;
|
|
57
39
|
readonly shareConfig: {
|
|
@@ -71,7 +53,20 @@ declare const MF_SHARED_DEPS: {
|
|
|
71
53
|
};
|
|
72
54
|
};
|
|
73
55
|
};
|
|
74
|
-
type
|
|
56
|
+
type CoreSharedDepName = keyof typeof MF_CORE_SHARED_DEPS;
|
|
57
|
+
interface AppSharedDepConfig {
|
|
58
|
+
version: string;
|
|
59
|
+
requiredVersion?: string | false;
|
|
60
|
+
singleton?: boolean;
|
|
61
|
+
strictVersion?: boolean;
|
|
62
|
+
eager?: boolean;
|
|
63
|
+
shareScope?: string;
|
|
64
|
+
}
|
|
65
|
+
type AppSharedDeps = Record<string, AppSharedDepConfig>;
|
|
66
|
+
declare function buildMergedSharedDeps(appShared?: AppSharedDeps): Record<string, {
|
|
67
|
+
version: string;
|
|
68
|
+
shareConfig: typeof SHARE_CONFIG;
|
|
69
|
+
}>;
|
|
75
70
|
//#endregion
|
|
76
|
-
export {
|
|
71
|
+
export { AppSharedDepConfig, AppSharedDeps, CoreSharedDepName, MF_CORE_SHARED_DEPS, PLUGIN_VERSION, SHARE_CONFIG, buildMergedSharedDeps };
|
|
77
72
|
//# sourceMappingURL=mf-config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mf-config.d.mts","names":[],"sources":["../../src/runtime/mf-config.ts"],"mappings":";cAsBa,cAAA;AAAA,cAGA,YAAA;EAAA;;;;;cAOA,
|
|
1
|
+
{"version":3,"file":"mf-config.d.mts","names":[],"sources":["../../src/runtime/mf-config.ts"],"mappings":";cAsBa,cAAA;AAAA,cAGA,YAAA;EAAA;;;;;cAOA,mBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuBD,iBAAA,gBAAiC,mBAAA;AAAA,UAE5B,kBAAA;EACf,OAAA;EACA,eAAA;EACA,SAAA;EACA,aAAA;EACA,KAAA;EACA,UAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,MAAA,SAAe,kBAAA;AAAA,iBAE3B,qBAAA,CACd,SAAA,GAAY,aAAA,GACX,MAAA;EAAiB,OAAA;EAAiB,WAAA,SAAoB,YAAA;AAAA"}
|
|
@@ -10,14 +10,14 @@ function getInstalledPackageVersion(packageName, fallbackRange) {
|
|
|
10
10
|
return match ? match[0] : fallbackRange.replace(/^[\^~>=<\s]+/, "");
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const PLUGIN_VERSION = "2.
|
|
13
|
+
const PLUGIN_VERSION = "2.5.1";
|
|
14
14
|
const SHARE_CONFIG = {
|
|
15
15
|
singleton: true,
|
|
16
16
|
requiredVersion: false,
|
|
17
17
|
strictVersion: false,
|
|
18
18
|
eager: false
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const MF_CORE_SHARED_DEPS = {
|
|
21
21
|
"every-plugin": {
|
|
22
22
|
version: PLUGIN_VERSION,
|
|
23
23
|
shareConfig: SHARE_CONFIG
|
|
@@ -30,14 +30,6 @@ const MF_SHARED_DEPS = {
|
|
|
30
30
|
version: getInstalledPackageVersion("zod", "^4.3.6"),
|
|
31
31
|
shareConfig: SHARE_CONFIG
|
|
32
32
|
},
|
|
33
|
-
"better-auth": {
|
|
34
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
35
|
-
shareConfig: SHARE_CONFIG
|
|
36
|
-
},
|
|
37
|
-
"drizzle-orm": {
|
|
38
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
39
|
-
shareConfig: SHARE_CONFIG
|
|
40
|
-
},
|
|
41
33
|
"@orpc/contract": {
|
|
42
34
|
version: getInstalledPackageVersion("@orpc/contract", "^1.13.4"),
|
|
43
35
|
shareConfig: SHARE_CONFIG
|
|
@@ -47,7 +39,24 @@ const MF_SHARED_DEPS = {
|
|
|
47
39
|
shareConfig: SHARE_CONFIG
|
|
48
40
|
}
|
|
49
41
|
};
|
|
42
|
+
function buildMergedSharedDeps(appShared) {
|
|
43
|
+
const merged = {};
|
|
44
|
+
for (const [name, config] of Object.entries(MF_CORE_SHARED_DEPS)) merged[name] = {
|
|
45
|
+
version: config.version,
|
|
46
|
+
shareConfig: config.shareConfig
|
|
47
|
+
};
|
|
48
|
+
if (appShared) for (const [name, config] of Object.entries(appShared)) merged[name] = {
|
|
49
|
+
version: config.version,
|
|
50
|
+
shareConfig: {
|
|
51
|
+
singleton: config.singleton ?? true,
|
|
52
|
+
requiredVersion: config.requiredVersion ?? false,
|
|
53
|
+
strictVersion: config.strictVersion ?? false,
|
|
54
|
+
eager: config.eager ?? false
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return merged;
|
|
58
|
+
}
|
|
50
59
|
|
|
51
60
|
//#endregion
|
|
52
|
-
export {
|
|
61
|
+
export { MF_CORE_SHARED_DEPS, PLUGIN_VERSION, SHARE_CONFIG, buildMergedSharedDeps };
|
|
53
62
|
//# sourceMappingURL=mf-config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mf-config.mjs","names":[],"sources":["../../src/runtime/mf-config.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\ndeclare const __EVERY_PLUGIN_VERSION__: string | undefined;\n\nfunction readPackageVersion(): string {\n try {\n return (require(\"../../package.json\") as { version: string }).version;\n } catch {\n return \"0.0.0\";\n }\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackRange: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n const match = fallbackRange.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : fallbackRange.replace(/^[\\^~>=<\\s]+/, \"\");\n }\n}\n\nexport const PLUGIN_VERSION =\n typeof __EVERY_PLUGIN_VERSION__ === \"string\" ? __EVERY_PLUGIN_VERSION__ : readPackageVersion();\n\nexport const SHARE_CONFIG = {\n singleton: true,\n requiredVersion: false,\n strictVersion: false,\n eager: false,\n} as const;\n\nexport const
|
|
1
|
+
{"version":3,"file":"mf-config.mjs","names":[],"sources":["../../src/runtime/mf-config.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\ndeclare const __EVERY_PLUGIN_VERSION__: string | undefined;\n\nfunction readPackageVersion(): string {\n try {\n return (require(\"../../package.json\") as { version: string }).version;\n } catch {\n return \"0.0.0\";\n }\n}\n\nfunction getInstalledPackageVersion(packageName: string, fallbackRange: string): string {\n try {\n return require(`${packageName}/package.json`).version as string;\n } catch {\n const match = fallbackRange.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : fallbackRange.replace(/^[\\^~>=<\\s]+/, \"\");\n }\n}\n\nexport const PLUGIN_VERSION =\n typeof __EVERY_PLUGIN_VERSION__ === \"string\" ? __EVERY_PLUGIN_VERSION__ : readPackageVersion();\n\nexport const SHARE_CONFIG = {\n singleton: true,\n requiredVersion: false,\n strictVersion: false,\n eager: false,\n} as const;\n\nexport const MF_CORE_SHARED_DEPS = {\n \"every-plugin\": {\n version: PLUGIN_VERSION,\n shareConfig: SHARE_CONFIG,\n },\n effect: {\n version: getInstalledPackageVersion(\"effect\", \"^3.21.0\"),\n shareConfig: SHARE_CONFIG,\n },\n zod: {\n version: getInstalledPackageVersion(\"zod\", \"^4.3.6\"),\n shareConfig: SHARE_CONFIG,\n },\n \"@orpc/contract\": {\n version: getInstalledPackageVersion(\"@orpc/contract\", \"^1.13.4\"),\n shareConfig: SHARE_CONFIG,\n },\n \"@orpc/server\": {\n version: getInstalledPackageVersion(\"@orpc/server\", \"^1.13.4\"),\n shareConfig: SHARE_CONFIG,\n },\n} as const;\n\nexport type CoreSharedDepName = keyof typeof MF_CORE_SHARED_DEPS;\n\nexport interface AppSharedDepConfig {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n}\n\nexport type AppSharedDeps = Record<string, AppSharedDepConfig>;\n\nexport function buildMergedSharedDeps(\n appShared?: AppSharedDeps,\n): Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> {\n const merged: Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> = {};\n\n for (const [name, config] of Object.entries(MF_CORE_SHARED_DEPS)) {\n merged[name] = { version: config.version, shareConfig: config.shareConfig };\n }\n\n if (appShared) {\n for (const [name, config] of Object.entries(appShared)) {\n merged[name] = {\n version: config.version,\n shareConfig: {\n singleton: (config.singleton ?? true) as true,\n requiredVersion: (config.requiredVersion ?? false) as false,\n strictVersion: (config.strictVersion ?? false) as false,\n eager: (config.eager ?? false) as false,\n },\n };\n }\n }\n\n return merged;\n}\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAW9C,SAAS,2BAA2B,aAAqB,eAA+B;AACtF,KAAI;AACF,SAAO,QAAQ,GAAG,YAAY,eAAe,CAAC;SACxC;EACN,MAAM,QAAQ,cAAc,MAAM,oCAAoC;AACtE,SAAO,QAAQ,MAAM,KAAK,cAAc,QAAQ,gBAAgB,GAAG;;;AAIvE,MAAa;AAGb,MAAa,eAAe;CAC1B,WAAW;CACX,iBAAiB;CACjB,eAAe;CACf,OAAO;CACR;AAED,MAAa,sBAAsB;CACjC,gBAAgB;EACd,SAAS;EACT,aAAa;EACd;CACD,QAAQ;EACN,SAAS,2BAA2B,UAAU,UAAU;EACxD,aAAa;EACd;CACD,KAAK;EACH,SAAS,2BAA2B,OAAO,SAAS;EACpD,aAAa;EACd;CACD,kBAAkB;EAChB,SAAS,2BAA2B,kBAAkB,UAAU;EAChE,aAAa;EACd;CACD,gBAAgB;EACd,SAAS,2BAA2B,gBAAgB,UAAU;EAC9D,aAAa;EACd;CACF;AAeD,SAAgB,sBACd,WACuE;CACvE,MAAM,SAAgF,EAAE;AAExF,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,oBAAoB,CAC9D,QAAO,QAAQ;EAAE,SAAS,OAAO;EAAS,aAAa,OAAO;EAAa;AAG7E,KAAI,UACF,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,UAAU,CACpD,QAAO,QAAQ;EACb,SAAS,OAAO;EAChB,aAAa;GACX,WAAY,OAAO,aAAa;GAChC,iBAAkB,OAAO,mBAAmB;GAC5C,eAAgB,OAAO,iBAAiB;GACxC,OAAQ,OAAO,SAAS;GACzB;EACF;AAIL,QAAO"}
|
|
@@ -7,19 +7,17 @@ let _module_federation_enhanced_runtime = require("@module-federation/enhanced/r
|
|
|
7
7
|
let _module_federation_runtime_core = require("@module-federation/runtime-core");
|
|
8
8
|
|
|
9
9
|
//#region src/runtime/services/module-federation.service.ts
|
|
10
|
-
const
|
|
10
|
+
const coreModuleLoaders = {
|
|
11
11
|
"every-plugin": () => Promise.resolve().then(() => require("../../index.cjs")),
|
|
12
12
|
effect: () => import("effect"),
|
|
13
13
|
zod: () => import("zod"),
|
|
14
|
-
"better-auth": () => Promise.resolve().then(() => require("../../node_modules/.bun/better-auth@1.6.9_a51fe808ef526527/node_modules/better-auth/dist/index.cjs")),
|
|
15
|
-
"drizzle-orm": () => Promise.resolve().then(() => require("../../node_modules/.bun/drizzle-orm@0.45.2_5d168cad3842e387/node_modules/drizzle-orm/index.cjs")),
|
|
16
14
|
"@orpc/contract": () => import("@orpc/contract"),
|
|
17
15
|
"@orpc/server": () => import("@orpc/server")
|
|
18
16
|
};
|
|
19
17
|
function buildSharedConfig() {
|
|
20
|
-
return Object.fromEntries(Object.entries(require_runtime_mf_config.
|
|
21
|
-
const load =
|
|
22
|
-
if (!load) throw new Error(`Missing shared module loader for ${name}`);
|
|
18
|
+
return Object.fromEntries(Object.entries(require_runtime_mf_config.MF_CORE_SHARED_DEPS).map(([name, config]) => {
|
|
19
|
+
const load = coreModuleLoaders[name];
|
|
20
|
+
if (!load) throw new Error(`Missing core shared module loader for ${name}`);
|
|
23
21
|
return [name, {
|
|
24
22
|
version: config.version,
|
|
25
23
|
get: () => load().then((mod) => () => mod),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.cjs","names":["
|
|
1
|
+
{"version":3,"file":"module-federation.service.cjs","names":["MF_CORE_SHARED_DEPS","Effect","getNormalizedRemoteName","ModuleFederationError"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import { createInstance, getInstance } from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { type CoreSharedDepName, MF_CORE_SHARED_DEPS } from \"../mf-config\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = (new () => AnyPlugin) | { default: new () => AnyPlugin };\n\nconst coreModuleLoaders: Record<CoreSharedDepName, () => Promise<unknown>> = {\n \"every-plugin\": () => import(\"every-plugin\"),\n effect: () => import(\"effect\"),\n zod: () => import(\"zod\"),\n \"@orpc/contract\": () => import(\"@orpc/contract\"),\n \"@orpc/server\": () => import(\"@orpc/server\"),\n};\n\nfunction buildSharedConfig(): Record<\n string,\n {\n version: string;\n get: () => Promise<() => unknown>;\n shareConfig: (typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName][\"shareConfig\"];\n }\n> {\n return Object.fromEntries(\n (\n Object.entries(MF_CORE_SHARED_DEPS) as [\n CoreSharedDepName,\n (typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName],\n ][]\n ).map(([name, config]) => {\n const load = coreModuleLoaders[name];\n\n if (!load) {\n throw new Error(`Missing core shared module loader for ${name}`);\n }\n\n return [\n name,\n {\n version: config.version,\n get: () => load().then((mod) => () => mod),\n shareConfig: config.shareConfig,\n },\n ];\n }),\n );\n}\n\nconst createModuleFederationInstance = Effect.cached(\n Effect.sync(() => {\n try {\n const shared = buildSharedConfig();\n let instance = getInstance();\n\n if (!instance) {\n instance = createInstance({\n name: \"host\",\n remotes: [],\n shared,\n });\n\n setGlobalFederationInstance(instance);\n } else {\n instance.registerShared(shared);\n }\n\n return instance;\n } catch (error) {\n throw new Error(`Failed to initialize Module Federation: ${error}`);\n }\n }),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\n \"ModuleFederationService\",\n {\n effect: Effect.gen(function* () {\n const mf = yield* Effect.flatten(createModuleFederationInstance);\n\n return {\n registerRemote: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n console.log(`[MF] Registering ${pluginId}`);\n\n const remoteName = getNormalizedRemoteName(pluginId);\n const type = url.endsWith(\"/mf-manifest.json\")\n ? (\"manifest\" as const)\n : url.endsWith(\"/remoteEntry.js\")\n ? (\"script\" as const)\n : undefined;\n\n yield* Effect.try({\n try: () =>\n mf.registerRemotes([\n {\n name: remoteName,\n entry: url,\n ...(type ? { type } : {}),\n },\n ]),\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n\n console.log(`[MF] ✅ Registered ${pluginId}`);\n }),\n\n loadRemoteConstructor: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n const remoteName = getNormalizedRemoteName(pluginId);\n console.log(`[MF] Loading remote ${remoteName}`);\n const modulePath = `${remoteName}/plugin`;\n\n return yield* Effect.tryPromise({\n try: async () => {\n const container = await mf.loadRemote<RemoteModule>(modulePath);\n if (!container) {\n throw new Error(`No container returned for ${modulePath}`);\n }\n\n // Support multiple export patterns: direct function, default export, named exports\n let Constructor: any;\n\n if (typeof container === \"function\") {\n // Direct function export\n Constructor = container;\n } else if (container.default) {\n // Default export\n Constructor = container.default;\n } else {\n // Named export fallback - prioritize exports with 'binding' property (plugin classes)\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && (exp as any).binding !== undefined,\n );\n\n // Fallback to any function export if no binding found\n if (!Constructor) {\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp,\n );\n }\n }\n\n if (!Constructor || typeof Constructor !== \"function\") {\n const containerInfo =\n typeof container === \"object\"\n ? `Available exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `No valid plugin constructor found for '${pluginId}'.\\n` +\n `Supported patterns:\\n` +\n ` - export const YourPlugin = createPlugin({...})\\n` +\n ` - export default createPlugin({...})\\n` +\n `${containerInfo}`,\n );\n }\n\n // Validate it looks like a plugin constructor (has binding property)\n if (!(Constructor as any).binding) {\n const containerInfo =\n typeof container === \"object\"\n ? `Found exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `Invalid plugin constructor for '${pluginId}'. ` +\n `The exported value must be created with createPlugin(). ` +\n `Found a function but it's missing the required 'binding' property.\\n` +\n `${containerInfo}`,\n );\n }\n\n console.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n return Constructor;\n },\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;;AAUA,MAAM,oBAAuE;CAC3E,2DAAsB;CACtB,cAAc,OAAO;CACrB,WAAW,OAAO;CAClB,wBAAwB,OAAO;CAC/B,sBAAsB,OAAO;CAC9B;AAED,SAAS,oBAOP;AACA,QAAO,OAAO,YAEV,OAAO,QAAQA,8CAAoB,CAInC,KAAK,CAAC,MAAM,YAAY;EACxB,MAAM,OAAO,kBAAkB;AAE/B,MAAI,CAAC,KACH,OAAM,IAAI,MAAM,yCAAyC,OAAO;AAGlE,SAAO,CACL,MACA;GACE,SAAS,OAAO;GAChB,WAAW,MAAM,CAAC,MAAM,cAAc,IAAI;GAC1C,aAAa,OAAO;GACrB,CACF;GACD,CACH;;AAGH,MAAM,iCAAiCC,cAAO,OAC5CA,cAAO,WAAW;AAChB,KAAI;EACF,MAAM,SAAS,mBAAmB;EAClC,IAAI,iE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,UAAU;UACnB;AAEL,oBAAc,OAAO,OAAO,UAAU,CAAC,MACpC,QAAQ,OAAO,QAAQ,cAAe,IAAY,YAAY,OAChE;AAGD,UAAI,CAAC,YACH,eAAc,OAAO,OAAO,UAAU,CAAC,MACpC,QAAQ,OAAO,QAAQ,cAAc,IAAI,WAAW,gBAAgB,IACtE;;AAIL,SAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY;MACrD,MAAM,gBACJ,OAAO,cAAc,WACjB,sBAAsB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACvD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,0CAA0C,SAAS,sHAI9C,gBACN;;AAIH,SAAI,CAAE,YAAoB,SAAS;MACjC,MAAM,gBACJ,OAAO,cAAc,WACjB,kBAAkB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACnD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,mCAAmC,SAAS,iIAGvC,gBACN;;AAGH,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAET,QAAQ,UACN,IAAIE,qCAAsB;KACxB;KACA,WAAW;KACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KACjE,CAAC;IACL,CAAC;IACF;EACL;EACD,EACH,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;
|
|
1
|
+
{"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;uCA+ET,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CA+BN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cAtChD,uBAAA,SAAgC,4BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;
|
|
1
|
+
{"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;uCA+ET,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CA+BN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cAtChD,uBAAA,SAAgC,4BAAA"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { ModuleFederationError } from "../errors.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { MF_CORE_SHARED_DEPS } from "../mf-config.mjs";
|
|
3
3
|
import { getNormalizedRemoteName } from "./normalize.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { createInstance, getInstance } from "@module-federation/enhanced/runtime";
|
|
6
6
|
import { setGlobalFederationInstance } from "@module-federation/runtime-core";
|
|
7
7
|
|
|
8
8
|
//#region src/runtime/services/module-federation.service.ts
|
|
9
|
-
const
|
|
9
|
+
const coreModuleLoaders = {
|
|
10
10
|
"every-plugin": () => import("../../index.mjs"),
|
|
11
11
|
effect: () => import("effect"),
|
|
12
12
|
zod: () => import("zod"),
|
|
13
|
-
"better-auth": () => import("../../node_modules/.bun/better-auth@1.6.9_a51fe808ef526527/node_modules/better-auth/dist/index.mjs"),
|
|
14
|
-
"drizzle-orm": () => import("../../node_modules/.bun/drizzle-orm@0.45.2_5d168cad3842e387/node_modules/drizzle-orm/index.mjs"),
|
|
15
13
|
"@orpc/contract": () => import("@orpc/contract"),
|
|
16
14
|
"@orpc/server": () => import("@orpc/server")
|
|
17
15
|
};
|
|
18
16
|
function buildSharedConfig() {
|
|
19
|
-
return Object.fromEntries(Object.entries(
|
|
20
|
-
const load =
|
|
21
|
-
if (!load) throw new Error(`Missing shared module loader for ${name}`);
|
|
17
|
+
return Object.fromEntries(Object.entries(MF_CORE_SHARED_DEPS).map(([name, config]) => {
|
|
18
|
+
const load = coreModuleLoaders[name];
|
|
19
|
+
if (!load) throw new Error(`Missing core shared module loader for ${name}`);
|
|
22
20
|
return [name, {
|
|
23
21
|
version: config.version,
|
|
24
22
|
get: () => load().then((mod) => () => mod),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.mjs","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import { createInstance, getInstance } from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport {
|
|
1
|
+
{"version":3,"file":"module-federation.service.mjs","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import { createInstance, getInstance } from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { type CoreSharedDepName, MF_CORE_SHARED_DEPS } from \"../mf-config\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = (new () => AnyPlugin) | { default: new () => AnyPlugin };\n\nconst coreModuleLoaders: Record<CoreSharedDepName, () => Promise<unknown>> = {\n \"every-plugin\": () => import(\"every-plugin\"),\n effect: () => import(\"effect\"),\n zod: () => import(\"zod\"),\n \"@orpc/contract\": () => import(\"@orpc/contract\"),\n \"@orpc/server\": () => import(\"@orpc/server\"),\n};\n\nfunction buildSharedConfig(): Record<\n string,\n {\n version: string;\n get: () => Promise<() => unknown>;\n shareConfig: (typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName][\"shareConfig\"];\n }\n> {\n return Object.fromEntries(\n (\n Object.entries(MF_CORE_SHARED_DEPS) as [\n CoreSharedDepName,\n (typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName],\n ][]\n ).map(([name, config]) => {\n const load = coreModuleLoaders[name];\n\n if (!load) {\n throw new Error(`Missing core shared module loader for ${name}`);\n }\n\n return [\n name,\n {\n version: config.version,\n get: () => load().then((mod) => () => mod),\n shareConfig: config.shareConfig,\n },\n ];\n }),\n );\n}\n\nconst createModuleFederationInstance = Effect.cached(\n Effect.sync(() => {\n try {\n const shared = buildSharedConfig();\n let instance = getInstance();\n\n if (!instance) {\n instance = createInstance({\n name: \"host\",\n remotes: [],\n shared,\n });\n\n setGlobalFederationInstance(instance);\n } else {\n instance.registerShared(shared);\n }\n\n return instance;\n } catch (error) {\n throw new Error(`Failed to initialize Module Federation: ${error}`);\n }\n }),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\n \"ModuleFederationService\",\n {\n effect: Effect.gen(function* () {\n const mf = yield* Effect.flatten(createModuleFederationInstance);\n\n return {\n registerRemote: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n console.log(`[MF] Registering ${pluginId}`);\n\n const remoteName = getNormalizedRemoteName(pluginId);\n const type = url.endsWith(\"/mf-manifest.json\")\n ? (\"manifest\" as const)\n : url.endsWith(\"/remoteEntry.js\")\n ? (\"script\" as const)\n : undefined;\n\n yield* Effect.try({\n try: () =>\n mf.registerRemotes([\n {\n name: remoteName,\n entry: url,\n ...(type ? { type } : {}),\n },\n ]),\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n\n console.log(`[MF] ✅ Registered ${pluginId}`);\n }),\n\n loadRemoteConstructor: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n const remoteName = getNormalizedRemoteName(pluginId);\n console.log(`[MF] Loading remote ${remoteName}`);\n const modulePath = `${remoteName}/plugin`;\n\n return yield* Effect.tryPromise({\n try: async () => {\n const container = await mf.loadRemote<RemoteModule>(modulePath);\n if (!container) {\n throw new Error(`No container returned for ${modulePath}`);\n }\n\n // Support multiple export patterns: direct function, default export, named exports\n let Constructor: any;\n\n if (typeof container === \"function\") {\n // Direct function export\n Constructor = container;\n } else if (container.default) {\n // Default export\n Constructor = container.default;\n } else {\n // Named export fallback - prioritize exports with 'binding' property (plugin classes)\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && (exp as any).binding !== undefined,\n );\n\n // Fallback to any function export if no binding found\n if (!Constructor) {\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp,\n );\n }\n }\n\n if (!Constructor || typeof Constructor !== \"function\") {\n const containerInfo =\n typeof container === \"object\"\n ? `Available exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `No valid plugin constructor found for '${pluginId}'.\\n` +\n `Supported patterns:\\n` +\n ` - export const YourPlugin = createPlugin({...})\\n` +\n ` - export default createPlugin({...})\\n` +\n `${containerInfo}`,\n );\n }\n\n // Validate it looks like a plugin constructor (has binding property)\n if (!(Constructor as any).binding) {\n const containerInfo =\n typeof container === \"object\"\n ? `Found exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `Invalid plugin constructor for '${pluginId}'. ` +\n `The exported value must be created with createPlugin(). ` +\n `Found a function but it's missing the required 'binding' property.\\n` +\n `${containerInfo}`,\n );\n }\n\n console.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n return Constructor;\n },\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;AAUA,MAAM,oBAAuE;CAC3E,sBAAsB,OAAO;CAC7B,cAAc,OAAO;CACrB,WAAW,OAAO;CAClB,wBAAwB,OAAO;CAC/B,sBAAsB,OAAO;CAC9B;AAED,SAAS,oBAOP;AACA,QAAO,OAAO,YAEV,OAAO,QAAQ,oBAAoB,CAIn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54
54
|
version: getInstalledPackageVersion("zod", pkg.peerDependencies.zod),
|
|
55
55
|
...DEFAULT_SHARE_CONFIG,
|
|
56
56
|
},
|
|
57
|
-
"better-auth": {
|
|
58
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
59
|
-
...DEFAULT_SHARE_CONFIG,
|
|
60
|
-
},
|
|
61
|
-
"drizzle-orm": {
|
|
62
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
63
|
-
...DEFAULT_SHARE_CONFIG,
|
|
64
|
-
},
|
|
65
57
|
"@orpc/contract": {
|
|
66
58
|
version: getInstalledPackageVersion("@orpc/contract", pkg.peerDependencies["@orpc/contract"]),
|
|
67
59
|
...DEFAULT_SHARE_CONFIG,
|
package/src/runtime/mf-config.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const SHARE_CONFIG = {
|
|
|
30
30
|
eager: false,
|
|
31
31
|
} as const;
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const MF_CORE_SHARED_DEPS = {
|
|
34
34
|
"every-plugin": {
|
|
35
35
|
version: PLUGIN_VERSION,
|
|
36
36
|
shareConfig: SHARE_CONFIG,
|
|
@@ -43,14 +43,6 @@ export const MF_SHARED_DEPS = {
|
|
|
43
43
|
version: getInstalledPackageVersion("zod", "^4.3.6"),
|
|
44
44
|
shareConfig: SHARE_CONFIG,
|
|
45
45
|
},
|
|
46
|
-
"better-auth": {
|
|
47
|
-
version: getInstalledPackageVersion("better-auth", "^1.6.9"),
|
|
48
|
-
shareConfig: SHARE_CONFIG,
|
|
49
|
-
},
|
|
50
|
-
"drizzle-orm": {
|
|
51
|
-
version: getInstalledPackageVersion("drizzle-orm", "^0.45.1"),
|
|
52
|
-
shareConfig: SHARE_CONFIG,
|
|
53
|
-
},
|
|
54
46
|
"@orpc/contract": {
|
|
55
47
|
version: getInstalledPackageVersion("@orpc/contract", "^1.13.4"),
|
|
56
48
|
shareConfig: SHARE_CONFIG,
|
|
@@ -61,4 +53,41 @@ export const MF_SHARED_DEPS = {
|
|
|
61
53
|
},
|
|
62
54
|
} as const;
|
|
63
55
|
|
|
64
|
-
export type
|
|
56
|
+
export type CoreSharedDepName = keyof typeof MF_CORE_SHARED_DEPS;
|
|
57
|
+
|
|
58
|
+
export interface AppSharedDepConfig {
|
|
59
|
+
version: string;
|
|
60
|
+
requiredVersion?: string | false;
|
|
61
|
+
singleton?: boolean;
|
|
62
|
+
strictVersion?: boolean;
|
|
63
|
+
eager?: boolean;
|
|
64
|
+
shareScope?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type AppSharedDeps = Record<string, AppSharedDepConfig>;
|
|
68
|
+
|
|
69
|
+
export function buildMergedSharedDeps(
|
|
70
|
+
appShared?: AppSharedDeps,
|
|
71
|
+
): Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> {
|
|
72
|
+
const merged: Record<string, { version: string; shareConfig: typeof SHARE_CONFIG }> = {};
|
|
73
|
+
|
|
74
|
+
for (const [name, config] of Object.entries(MF_CORE_SHARED_DEPS)) {
|
|
75
|
+
merged[name] = { version: config.version, shareConfig: config.shareConfig };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (appShared) {
|
|
79
|
+
for (const [name, config] of Object.entries(appShared)) {
|
|
80
|
+
merged[name] = {
|
|
81
|
+
version: config.version,
|
|
82
|
+
shareConfig: {
|
|
83
|
+
singleton: (config.singleton ?? true) as true,
|
|
84
|
+
requiredVersion: (config.requiredVersion ?? false) as false,
|
|
85
|
+
strictVersion: (config.strictVersion ?? false) as false,
|
|
86
|
+
eager: (config.eager ?? false) as false,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return merged;
|
|
93
|
+
}
|
|
@@ -3,37 +3,38 @@ import { setGlobalFederationInstance } from "@module-federation/runtime-core";
|
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import type { AnyPlugin } from "../../types";
|
|
5
5
|
import { ModuleFederationError } from "../errors";
|
|
6
|
-
import {
|
|
6
|
+
import { type CoreSharedDepName, MF_CORE_SHARED_DEPS } from "../mf-config";
|
|
7
7
|
import { getNormalizedRemoteName } from "./normalize";
|
|
8
8
|
|
|
9
9
|
type RemoteModule = (new () => AnyPlugin) | { default: new () => AnyPlugin };
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const coreModuleLoaders: Record<CoreSharedDepName, () => Promise<unknown>> = {
|
|
12
12
|
"every-plugin": () => import("every-plugin"),
|
|
13
13
|
effect: () => import("effect"),
|
|
14
14
|
zod: () => import("zod"),
|
|
15
|
-
"better-auth": () => import("better-auth"),
|
|
16
|
-
"drizzle-orm": () => import("drizzle-orm"),
|
|
17
15
|
"@orpc/contract": () => import("@orpc/contract"),
|
|
18
16
|
"@orpc/server": () => import("@orpc/server"),
|
|
19
|
-
}
|
|
17
|
+
};
|
|
20
18
|
|
|
21
19
|
function buildSharedConfig(): Record<
|
|
22
20
|
string,
|
|
23
21
|
{
|
|
24
22
|
version: string;
|
|
25
23
|
get: () => Promise<() => unknown>;
|
|
26
|
-
shareConfig: (typeof
|
|
24
|
+
shareConfig: (typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName]["shareConfig"];
|
|
27
25
|
}
|
|
28
26
|
> {
|
|
29
27
|
return Object.fromEntries(
|
|
30
28
|
(
|
|
31
|
-
Object.entries(
|
|
29
|
+
Object.entries(MF_CORE_SHARED_DEPS) as [
|
|
30
|
+
CoreSharedDepName,
|
|
31
|
+
(typeof MF_CORE_SHARED_DEPS)[CoreSharedDepName],
|
|
32
|
+
][]
|
|
32
33
|
).map(([name, config]) => {
|
|
33
|
-
const load =
|
|
34
|
+
const load = coreModuleLoaders[name];
|
|
34
35
|
|
|
35
36
|
if (!load) {
|
|
36
|
-
throw new Error(`Missing shared module loader for ${name}`);
|
|
37
|
+
throw new Error(`Missing core shared module loader for ${name}`);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
return [
|