every-plugin 0.8.9 → 2.2.2
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/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
- package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
- package/dist/build/rspack/dev-server-middleware.cjs +15 -4
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +15 -4
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +8 -6
- package/dist/build/rspack/index.d.cts +4 -3
- package/dist/build/rspack/index.d.mts +4 -3
- package/dist/build/rspack/index.mjs +4 -3
- package/dist/build/rspack/module-federation.cjs +3 -3
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +83 -5
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +12 -1
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +12 -1
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +80 -5
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs +5 -4
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs +3 -2
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +50 -65
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts +27 -4
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts +27 -4
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs +48 -64
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/orpc-client.cjs +17 -0
- package/dist/orpc-client.d.cts +2 -0
- package/dist/orpc-client.d.mts +2 -0
- package/dist/orpc-client.mjs +5 -0
- package/dist/orpc-openapi.cjs +17 -0
- package/dist/orpc-openapi.d.cts +2 -0
- package/dist/orpc-openapi.d.mts +2 -0
- package/dist/orpc-openapi.mjs +5 -0
- package/dist/orpc.cjs +8 -7
- package/dist/plugin.cjs +10 -9
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +28 -29
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +28 -29
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +10 -10
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/errors.cjs +2 -2
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +4 -4
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +4 -4
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +1 -1
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +24 -20
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +3 -3
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +3 -3
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +12 -9
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +33 -0
- package/dist/runtime/mf-config.cjs.map +1 -0
- package/dist/runtime/mf-config.d.cts +41 -0
- package/dist/runtime/mf-config.d.cts.map +1 -0
- package/dist/runtime/mf-config.d.mts +41 -0
- package/dist/runtime/mf-config.d.mts.map +1 -0
- package/dist/runtime/mf-config.mjs +29 -0
- package/dist/runtime/mf-config.mjs.map +1 -0
- package/dist/runtime/services/module-federation.service.cjs +19 -56
- 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 +18 -55
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs +3 -2
- package/dist/runtime/services/normalize.cjs.map +1 -1
- package/dist/runtime/services/normalize.d.cts.map +1 -1
- package/dist/runtime/services/normalize.d.mts.map +1 -1
- package/dist/runtime/services/normalize.mjs +2 -2
- package/dist/runtime/services/normalize.mjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +3 -3
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +2 -2
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +1 -1
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +6 -7
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +6 -7
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs +4 -4
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts.map +1 -1
- package/dist/runtime/services/secrets.service.d.mts.map +1 -1
- package/dist/runtime/services/secrets.service.mjs +3 -3
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/validation.cjs +1 -1
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/testing/index.cjs +2 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +0 -2
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +0 -2
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.d.cts +22 -22
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +22 -22
- package/dist/types.d.mts.map +1 -1
- package/dist/zod.cjs +4 -3
- package/dist/zod.mjs +2 -2
- package/package.json +204 -194
- package/src/build/rspack/dev-server-middleware.ts +233 -0
- package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
- package/src/build/rspack/index.ts +14 -0
- package/src/build/rspack/module-federation.ts +6 -0
- package/src/build/rspack/plugin.ts +252 -0
- package/src/build/rspack/utils.ts +60 -0
- package/src/build/shared-deps.ts +79 -0
- package/src/effect.ts +1 -0
- package/src/errors.ts +140 -0
- package/src/index.ts +26 -0
- package/src/orpc-client.ts +2 -0
- package/src/orpc-openapi.ts +2 -0
- package/src/orpc.ts +9 -0
- package/src/plugin.ts +220 -0
- package/src/runtime/errors.ts +332 -0
- package/src/runtime/index.ts +258 -0
- package/src/runtime/mf-config.ts +29 -0
- package/src/runtime/services/module-federation.service.ts +181 -0
- package/src/runtime/services/normalize.ts +18 -0
- package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
- package/src/runtime/services/plugin-loader.service.ts +254 -0
- package/src/runtime/services/plugin.service.ts +66 -0
- package/src/runtime/services/secrets.service.ts +74 -0
- package/src/runtime/services.ts +5 -0
- package/src/runtime/validation.ts +23 -0
- package/src/testing/index.ts +87 -0
- package/src/testing/mocks/module-federation.service.ts +41 -0
- package/src/types.ts +309 -0
- package/src/zod-core.ts +4 -0
- package/src/zod.ts +1 -0
- package/dist/package.cjs +0 -47
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -29
- package/dist/package.mjs.map +0 -1
|
@@ -1,12 +1,82 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_dev_server_middleware = require('./dev-server-middleware.cjs');
|
|
3
3
|
const require_module_federation = require('./module-federation.cjs');
|
|
4
4
|
const require_utils = require('./utils.cjs');
|
|
5
|
-
let
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
6
7
|
let node_path = require("node:path");
|
|
7
|
-
node_path =
|
|
8
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
9
|
+
let node_crypto = require("node:crypto");
|
|
10
|
+
node_crypto = require_runtime.__toESM(node_crypto, 1);
|
|
11
|
+
let _module_federation_enhanced_rspack = require("@module-federation/enhanced/rspack");
|
|
8
12
|
|
|
9
13
|
//#region src/build/rspack/plugin.ts
|
|
14
|
+
var EmitPluginManifest = class {
|
|
15
|
+
name = "EmitPluginManifest";
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
}
|
|
19
|
+
apply(compiler) {
|
|
20
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
|
|
21
|
+
const webpack = compiler.webpack;
|
|
22
|
+
const rawSource = webpack?.sources?.RawSource;
|
|
23
|
+
const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1e3;
|
|
24
|
+
compilation.hooks.processAssets.tapPromise({
|
|
25
|
+
name: this.name,
|
|
26
|
+
stage
|
|
27
|
+
}, async () => {
|
|
28
|
+
const context = compiler.options.context || process.cwd();
|
|
29
|
+
const pluginInfo = require_utils.getPluginInfo(context);
|
|
30
|
+
const contractFileName = this.options.contractFileName ?? "contract.d.ts";
|
|
31
|
+
const manifestFileName = this.options.manifestFileName ?? "plugin.manifest.json";
|
|
32
|
+
const sourceContractPath = node_path.default.join(context, "types", contractFileName);
|
|
33
|
+
let contractTypes;
|
|
34
|
+
const tryReadFile = async (filePath) => {
|
|
35
|
+
if (!node_fs.default.existsSync(filePath)) return null;
|
|
36
|
+
if (!node_fs.default.statSync(filePath).isFile()) return null;
|
|
37
|
+
try {
|
|
38
|
+
return await node_fs.default.promises.readFile(filePath, "utf8");
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
contractTypes = await tryReadFile(sourceContractPath) ?? "";
|
|
44
|
+
if (!contractTypes) {
|
|
45
|
+
const packageDir = context.split("/").pop();
|
|
46
|
+
const nestedPath = node_path.default.join(context, "types", packageDir ?? "", "src", contractFileName);
|
|
47
|
+
contractTypes = await tryReadFile(nestedPath) ?? "";
|
|
48
|
+
if (!contractTypes) {
|
|
49
|
+
console.warn(`[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. Skipping manifest generation.`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const contractSha256 = node_crypto.default.createHash("sha256").update(contractTypes).digest("hex");
|
|
54
|
+
const manifest = {
|
|
55
|
+
schemaVersion: 1,
|
|
56
|
+
kind: "every-plugin/manifest",
|
|
57
|
+
plugin: {
|
|
58
|
+
name: pluginInfo.name,
|
|
59
|
+
version: pluginInfo.version
|
|
60
|
+
},
|
|
61
|
+
runtime: { remoteEntry: "./remoteEntry.js" },
|
|
62
|
+
contract: {
|
|
63
|
+
kind: "orpc",
|
|
64
|
+
types: {
|
|
65
|
+
path: `./types/${contractFileName}`,
|
|
66
|
+
exportName: "contract",
|
|
67
|
+
typeName: "ContractType",
|
|
68
|
+
sha256: contractSha256
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (rawSource) {
|
|
73
|
+
compilation.emitAsset(manifestFileName, new rawSource(`${JSON.stringify(manifest, null, 2)}\n`));
|
|
74
|
+
compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
10
80
|
var EveryPluginDevServer = class {
|
|
11
81
|
name = "EveryPluginDevServer";
|
|
12
82
|
constructor(options = {}) {
|
|
@@ -15,20 +85,22 @@ var EveryPluginDevServer = class {
|
|
|
15
85
|
apply(compiler) {
|
|
16
86
|
const pluginInfo = require_utils.getPluginInfo(compiler.options.context || process.cwd());
|
|
17
87
|
const devConfig = require_utils.loadDevConfig(this.options.devConfigPath || "./plugin.dev.ts");
|
|
18
|
-
const port = this.options.port || devConfig?.port || 3999;
|
|
88
|
+
const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;
|
|
19
89
|
this.configureDefaults(compiler, pluginInfo);
|
|
20
90
|
if (!compiler.options.devServer) compiler.options.devServer = {};
|
|
21
91
|
this.configureDevServer(compiler, pluginInfo, devConfig, port);
|
|
22
92
|
new _module_federation_enhanced_rspack.ModuleFederationPlugin({
|
|
23
93
|
name: pluginInfo.normalizedName,
|
|
24
94
|
filename: "remoteEntry.js",
|
|
25
|
-
dts: false,
|
|
95
|
+
dts: this.options.dts !== false,
|
|
96
|
+
manifest: {},
|
|
26
97
|
runtimePlugins: [require.resolve("@module-federation/node/runtimePlugin")],
|
|
27
98
|
library: { type: "commonjs-module" },
|
|
28
99
|
exposes: { "./plugin": "./src/index.ts" },
|
|
29
100
|
shared: require_module_federation.buildSharedDependencies(pluginInfo),
|
|
30
101
|
shareStrategy: "version-first"
|
|
31
102
|
}).apply(compiler);
|
|
103
|
+
if (this.options.dts === false) compiler.options.plugins = (compiler.options.plugins ?? []).filter((p) => !p || typeof p !== "object" || p.name !== "MFDevPlugin" && p.name !== "ModuleFederationDtsPlugin");
|
|
32
104
|
}
|
|
33
105
|
configureDefaults(compiler, pluginInfo) {
|
|
34
106
|
const context = compiler.options.context || process.cwd();
|
|
@@ -49,6 +121,11 @@ var EveryPluginDevServer = class {
|
|
|
49
121
|
".tsx",
|
|
50
122
|
".ts"
|
|
51
123
|
];
|
|
124
|
+
compiler.options.resolve.fallback = {
|
|
125
|
+
...compiler.options.resolve.fallback,
|
|
126
|
+
bufferutil: false,
|
|
127
|
+
"utf-8-validate": false
|
|
128
|
+
};
|
|
52
129
|
}
|
|
53
130
|
ensureTypeScriptLoader(compiler) {
|
|
54
131
|
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
@@ -87,5 +164,6 @@ var EveryPluginDevServer = class {
|
|
|
87
164
|
};
|
|
88
165
|
|
|
89
166
|
//#endregion
|
|
167
|
+
exports.EmitPluginManifest = EmitPluginManifest;
|
|
90
168
|
exports.EveryPluginDevServer = EveryPluginDevServer;
|
|
91
169
|
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["getPluginInfo","loadDevConfig","ModuleFederationPlugin","buildSharedDependencies","path"],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\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\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\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 // Configure target and mode defaults\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 // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\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 // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((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 // Add TypeScript loader if not present\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; // Should never happen due to check in apply()\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 // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\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":";;;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAAO;CAEP,YAAY,AAAQ,UAA8B,EAAE,EAAE;EAAlC;;CAEpB,MAAM,UAAoB;EAExB,MAAM,aAAaA,4BAAc,SAAS,QAAQ,WAAW,QAAQ,KAAK,CAAC;EAC3E,MAAM,YAAYC,4BAAc,KAAK,QAAQ,iBAAiB,kBAAkB;EAChF,MAAM,OAAO,KAAK,QAAQ,QAAQ,WAAW,QAAQ;AAGrD,OAAK,kBAAkB,UAAU,WAAW;AAG5C,MAAI,CAAC,SAAS,QAAQ,UACpB,UAAS,QAAQ,YAAY,EAAE;AAIjC,OAAK,mBAAmB,UAAU,YAAY,WAAW,KAAK;AAG9D,MAAIC,0DAAuB;GACzB,MAAM,WAAW;GACjB,UAAU;GAEV,KAAK;GACL,gBAAgB,CACd,QAAQ,QAAQ,wCAAwC,CACzD;GACD,SAAS,EAAE,MAAM,mBAAmB;GACpC,SAAS,EACP,YAAY,kBACb;GACD,QAAQC,kDAAwB,WAAW;GAC3C,eAAe;GAChB,CAAC,CAAC,MAAM,SAAS;;CAGpB,AAAQ,kBAAkB,UAAoB,YAAiB;EAC7D,MAAM,UAAU,SAAS,QAAQ,WAAW,QAAQ,KAAK;AAGzD,MAAI,CAAC,SAAS,QAAQ,OACpB,UAAS,QAAQ,SAAS,EAAE;AAE9B,WAAS,QAAQ,OAAO,aAAa,WAAW;AAChD,WAAS,QAAQ,OAAO,aAAa;AACrC,WAAS,QAAQ,OAAO,OAAOC,kBAAK,QAAQ,SAAS,OAAO;AAC5D,WAAS,QAAQ,OAAO,QAAQ;AAChC,WAAS,QAAQ,OAAO,UAAU,EAAE,MA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AQ,UAAU,UAAU;GACnC,+BAA+B;GAC/B,gCAAgC;GAChC,gCAAgC;GACjC;AAGD,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 PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\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 = {\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 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) {\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.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":";;;;;;;;;;;;;AAqBA,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,QA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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"}
|
|
@@ -5,6 +5,17 @@ interface EveryPluginOptions {
|
|
|
5
5
|
devConfigPath?: string;
|
|
6
6
|
port?: number;
|
|
7
7
|
pluginId?: string;
|
|
8
|
+
dts?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface PluginManifestEmitterOptions {
|
|
11
|
+
manifestFileName?: string;
|
|
12
|
+
contractFileName?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class EmitPluginManifest implements RspackPluginInstance {
|
|
15
|
+
private options;
|
|
16
|
+
name: string;
|
|
17
|
+
constructor(options?: PluginManifestEmitterOptions);
|
|
18
|
+
apply(compiler: Compiler): void;
|
|
8
19
|
}
|
|
9
20
|
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
21
|
private options;
|
|
@@ -16,5 +27,5 @@ declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
|
16
27
|
private configureDevServer;
|
|
17
28
|
}
|
|
18
29
|
//#endregion
|
|
19
|
-
export { EveryPluginDevServer, EveryPluginOptions };
|
|
30
|
+
export { EmitPluginManifest, EveryPluginDevServer, EveryPluginOptions, PluginManifestEmitterOptions };
|
|
20
31
|
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;
|
|
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,4BAAA;EACf,gBAAA;EACA,gBAAA;AAAA;AAAA,cAGW,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAkFL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,QA2CA,sBAAA;EAAA,QA2BA,kBAAA;AAAA"}
|
|
@@ -5,6 +5,17 @@ interface EveryPluginOptions {
|
|
|
5
5
|
devConfigPath?: string;
|
|
6
6
|
port?: number;
|
|
7
7
|
pluginId?: string;
|
|
8
|
+
dts?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface PluginManifestEmitterOptions {
|
|
11
|
+
manifestFileName?: string;
|
|
12
|
+
contractFileName?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class EmitPluginManifest implements RspackPluginInstance {
|
|
15
|
+
private options;
|
|
16
|
+
name: string;
|
|
17
|
+
constructor(options?: PluginManifestEmitterOptions);
|
|
18
|
+
apply(compiler: Compiler): void;
|
|
8
19
|
}
|
|
9
20
|
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
21
|
private options;
|
|
@@ -16,5 +27,5 @@ declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
|
16
27
|
private configureDevServer;
|
|
17
28
|
}
|
|
18
29
|
//#endregion
|
|
19
|
-
export { EveryPluginDevServer, EveryPluginOptions };
|
|
30
|
+
export { EmitPluginManifest, EveryPluginDevServer, EveryPluginOptions, PluginManifestEmitterOptions };
|
|
20
31
|
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"mappings":";;;
|
|
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,4BAAA;EACf,gBAAA;EACA,gBAAA;AAAA;AAAA,cAGW,kBAAA,YAA8B,oBAAA;EAAA,QAGrB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,4BAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;AAAA,cAkFL,oBAAA,YAAgC,oBAAA;EAAA,QAGvB,OAAA;EAFpB,IAAA;cAEoB,OAAA,GAAS,kBAAA;EAE7B,KAAA,CAAM,QAAA,EAAU,QAAA;EAAA,QAqCR,iBAAA;EAAA,QA2CA,sBAAA;EAAA,QA2BA,kBAAA;AAAA"}
|
|
@@ -1,11 +1,79 @@
|
|
|
1
|
-
import { __require } from "../../_virtual/
|
|
1
|
+
import { __require } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { setupPluginMiddleware } from "./dev-server-middleware.mjs";
|
|
3
3
|
import { buildSharedDependencies } from "./module-federation.mjs";
|
|
4
4
|
import { getPluginInfo, loadDevConfig } from "./utils.mjs";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
import crypto from "node:crypto";
|
|
8
|
+
import { ModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
7
9
|
|
|
8
10
|
//#region src/build/rspack/plugin.ts
|
|
11
|
+
var EmitPluginManifest = class {
|
|
12
|
+
name = "EmitPluginManifest";
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
|
|
18
|
+
const webpack = compiler.webpack;
|
|
19
|
+
const rawSource = webpack?.sources?.RawSource;
|
|
20
|
+
const stage = webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? 1e3;
|
|
21
|
+
compilation.hooks.processAssets.tapPromise({
|
|
22
|
+
name: this.name,
|
|
23
|
+
stage
|
|
24
|
+
}, async () => {
|
|
25
|
+
const context = compiler.options.context || process.cwd();
|
|
26
|
+
const pluginInfo = getPluginInfo(context);
|
|
27
|
+
const contractFileName = this.options.contractFileName ?? "contract.d.ts";
|
|
28
|
+
const manifestFileName = this.options.manifestFileName ?? "plugin.manifest.json";
|
|
29
|
+
const sourceContractPath = path.join(context, "types", contractFileName);
|
|
30
|
+
let contractTypes;
|
|
31
|
+
const tryReadFile = async (filePath) => {
|
|
32
|
+
if (!fs.existsSync(filePath)) return null;
|
|
33
|
+
if (!fs.statSync(filePath).isFile()) return null;
|
|
34
|
+
try {
|
|
35
|
+
return await fs.promises.readFile(filePath, "utf8");
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
contractTypes = await tryReadFile(sourceContractPath) ?? "";
|
|
41
|
+
if (!contractTypes) {
|
|
42
|
+
const packageDir = context.split("/").pop();
|
|
43
|
+
const nestedPath = path.join(context, "types", packageDir ?? "", "src", contractFileName);
|
|
44
|
+
contractTypes = await tryReadFile(nestedPath) ?? "";
|
|
45
|
+
if (!contractTypes) {
|
|
46
|
+
console.warn(`[EmitPluginManifest] Contract file not found at ${sourceContractPath} or ${nestedPath}. Skipping manifest generation.`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const contractSha256 = crypto.createHash("sha256").update(contractTypes).digest("hex");
|
|
51
|
+
const manifest = {
|
|
52
|
+
schemaVersion: 1,
|
|
53
|
+
kind: "every-plugin/manifest",
|
|
54
|
+
plugin: {
|
|
55
|
+
name: pluginInfo.name,
|
|
56
|
+
version: pluginInfo.version
|
|
57
|
+
},
|
|
58
|
+
runtime: { remoteEntry: "./remoteEntry.js" },
|
|
59
|
+
contract: {
|
|
60
|
+
kind: "orpc",
|
|
61
|
+
types: {
|
|
62
|
+
path: `./types/${contractFileName}`,
|
|
63
|
+
exportName: "contract",
|
|
64
|
+
typeName: "ContractType",
|
|
65
|
+
sha256: contractSha256
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
if (rawSource) {
|
|
70
|
+
compilation.emitAsset(manifestFileName, new rawSource(`${JSON.stringify(manifest, null, 2)}\n`));
|
|
71
|
+
compilation.emitAsset(`types/${contractFileName}`, new rawSource(`${contractTypes}`));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
9
77
|
var EveryPluginDevServer = class {
|
|
10
78
|
name = "EveryPluginDevServer";
|
|
11
79
|
constructor(options = {}) {
|
|
@@ -14,20 +82,22 @@ var EveryPluginDevServer = class {
|
|
|
14
82
|
apply(compiler) {
|
|
15
83
|
const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());
|
|
16
84
|
const devConfig = loadDevConfig(this.options.devConfigPath || "./plugin.dev.ts");
|
|
17
|
-
const port = this.options.port || devConfig?.port || 3999;
|
|
85
|
+
const port = Number(process.env.PORT) || this.options.port || devConfig?.port || 3999;
|
|
18
86
|
this.configureDefaults(compiler, pluginInfo);
|
|
19
87
|
if (!compiler.options.devServer) compiler.options.devServer = {};
|
|
20
88
|
this.configureDevServer(compiler, pluginInfo, devConfig, port);
|
|
21
89
|
new ModuleFederationPlugin({
|
|
22
90
|
name: pluginInfo.normalizedName,
|
|
23
91
|
filename: "remoteEntry.js",
|
|
24
|
-
dts: false,
|
|
92
|
+
dts: this.options.dts !== false,
|
|
93
|
+
manifest: {},
|
|
25
94
|
runtimePlugins: [__require.resolve("@module-federation/node/runtimePlugin")],
|
|
26
95
|
library: { type: "commonjs-module" },
|
|
27
96
|
exposes: { "./plugin": "./src/index.ts" },
|
|
28
97
|
shared: buildSharedDependencies(pluginInfo),
|
|
29
98
|
shareStrategy: "version-first"
|
|
30
99
|
}).apply(compiler);
|
|
100
|
+
if (this.options.dts === false) compiler.options.plugins = (compiler.options.plugins ?? []).filter((p) => !p || typeof p !== "object" || p.name !== "MFDevPlugin" && p.name !== "ModuleFederationDtsPlugin");
|
|
31
101
|
}
|
|
32
102
|
configureDefaults(compiler, pluginInfo) {
|
|
33
103
|
const context = compiler.options.context || process.cwd();
|
|
@@ -48,6 +118,11 @@ var EveryPluginDevServer = class {
|
|
|
48
118
|
".tsx",
|
|
49
119
|
".ts"
|
|
50
120
|
];
|
|
121
|
+
compiler.options.resolve.fallback = {
|
|
122
|
+
...compiler.options.resolve.fallback,
|
|
123
|
+
bufferutil: false,
|
|
124
|
+
"utf-8-validate": false
|
|
125
|
+
};
|
|
51
126
|
}
|
|
52
127
|
ensureTypeScriptLoader(compiler) {
|
|
53
128
|
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
@@ -86,5 +161,5 @@ var EveryPluginDevServer = class {
|
|
|
86
161
|
};
|
|
87
162
|
|
|
88
163
|
//#endregion
|
|
89
|
-
export { EveryPluginDevServer };
|
|
164
|
+
export { EmitPluginManifest, EveryPluginDevServer };
|
|
90
165
|
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/build/rspack/plugin.ts"],"sourcesContent":["import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';\nimport type { Compiler, RspackPluginInstance } from '@rspack/core';\nimport path from 'node:path';\nimport { setupPluginMiddleware } from './dev-server-middleware';\nimport { buildSharedDependencies } from './module-federation';\nimport { getPluginInfo, loadDevConfig } from './utils';\n\n\nexport interface EveryPluginOptions {\n devConfigPath?: string; // defaults to './plugin.dev.ts'\n port?: number; // override plugin.dev.ts port\n pluginId?: string; // override auto-detected\n}\n\nexport class EveryPluginDevServer implements RspackPluginInstance {\n name = 'EveryPluginDevServer';\n\n constructor(private options: EveryPluginOptions = {}) { }\n\n apply(compiler: Compiler) {\n // Load configuration\n const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());\n const devConfig = loadDevConfig(this.options.devConfigPath || './plugin.dev.ts');\n const port = this.options.port || devConfig?.port || 3999;\n\n // Configure defaults immediately (no hooks needed)\n this.configureDefaults(compiler, pluginInfo);\n\n // Initialize devServer if it doesn't exist\n if (!compiler.options.devServer) {\n compiler.options.devServer = {};\n }\n\n // Configure dev server\n this.configureDevServer(compiler, pluginInfo, devConfig, port);\n\n // Apply Module Federation plugin\n new ModuleFederationPlugin({\n name: pluginInfo.normalizedName,\n filename: 'remoteEntry.js',\n // manifest: true, // Enable MF 2.0 manifest generation\n dts: false,\n runtimePlugins: [\n require.resolve('@module-federation/node/runtimePlugin'),\n ],\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\n private configureDefaults(compiler: Compiler, pluginInfo: any) {\n const context = compiler.options.context || process.cwd();\n\n // Configure output defaults\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 // Configure target and mode defaults\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 // Configure devtool\n if (!compiler.options.devtool) {\n compiler.options.devtool = 'source-map';\n }\n\n // Suppress verbose infrastructure logging\n if (!compiler.options.infrastructureLogging) {\n compiler.options.infrastructureLogging = {\n level: 'warn', // Only show warnings and errors\n };\n }\n\n // Configure module rules - ensure TypeScript loader is present\n this.ensureTypeScriptLoader(compiler);\n\n // Configure resolve extensions\n if (!compiler.options.resolve) {\n compiler.options.resolve = {};\n }\n compiler.options.resolve.extensions = ['...', '.tsx', '.ts'];\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 // Check if TypeScript loader is already configured\n const hasTsLoader = compiler.options.module.rules.some((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 // Add TypeScript loader if not present\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; // Should never happen due to check in apply()\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 // Suppress verbose logging\n compiler.options.devServer.client = {\n logging: 'warn', // Only show warnings and errors\n overlay: {\n warnings: false, // Don't show warning overlay\n errors: true, // Still show errors\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":";;;;;;;;AAcA,IAAa,uBAAb,MAAkE;CAChE,OAA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,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 PluginManifestEmitterOptions {\n manifestFileName?: string;\n contractFileName?: string;\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 = {\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 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) {\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.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":";;;;;;;;;;AAqBA,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,SAAS,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AY,WAAW,KAAK;AAC7D,UAAO,gBAAgB,cAAc,aAAa,UAAU,GAAG"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_runtime_services_normalize = require('../../runtime/services/normalize.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
5
3
|
let node_fs = require("node:fs");
|
|
6
|
-
node_fs =
|
|
4
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
7
7
|
|
|
8
8
|
//#region src/build/rspack/utils.ts
|
|
9
9
|
function getPluginInfo(context) {
|
|
@@ -19,6 +19,7 @@ function getPluginInfo(context) {
|
|
|
19
19
|
}
|
|
20
20
|
const loadedModules = /* @__PURE__ */ new Set();
|
|
21
21
|
function loadDevConfig(devConfigPath) {
|
|
22
|
+
if (process.env.DEPLOY === "true") return null;
|
|
22
23
|
try {
|
|
23
24
|
const fullPath = node_path.default.resolve(devConfigPath);
|
|
24
25
|
if (loadedModules.has(fullPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["path","fs","getNormalizedRemoteName"],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["path","fs","getNormalizedRemoteName"],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAUA,kBAAK,KAAK,SAAS,eAAe;CAClD,MAAM,MAAM,KAAK,MAAMC,gBAAG,aAAa,SAAS,QAAQ,CAAC;AAEzD,QAAO;EACL,MAAM,IAAI;EACV,SAAS,IAAI;EACb,gBAAgBC,2DAAwB,IAAI,KAAK;EACjD,cAAc,IAAI,gBAAgB,EAAE;EACpC,kBAAkB,IAAI,oBAAoB,EAAE;EAC7C;;AAGH,MAAM,gCAAgB,IAAI,KAAa;AAEvC,SAAgB,cAAc,eAAuB;AACnD,KAAI,QAAQ,IAAI,WAAW,OACzB,QAAO;AAGT,KAAI;EACF,MAAM,WAAWF,kBAAK,QAAQ,cAAc;AAE5C,MAAI,cAAc,IAAI,SAAS,EAAE;AAC/B,UAAO,QAAQ,MAAM;GACrB,MAAM,UAAUA,kBAAK,QAAQ,SAAS;AACtC,QAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,MAAM,CAC1C,KAAI,IAAI,WAAW,QAAQ,IAAI,QAAQ,SACrC,QAAO,QAAQ,MAAM;;EAK3B,MAAM,SAAS,QAAQ,SAAS,CAAC;AACjC,gBAAc,IAAI,SAAS;AAC3B,SAAO;UACA,OAAO;AACd,UAAQ,KAAK,kCAAkC,cAAc,IAAK,MAAgB,QAAQ;AAC1F,SAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __require } from "../../_virtual/
|
|
1
|
+
import { __require } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { getNormalizedRemoteName } from "../../runtime/services/normalize.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
3
|
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/build/rspack/utils.ts
|
|
7
7
|
function getPluginInfo(context) {
|
|
@@ -17,6 +17,7 @@ function getPluginInfo(context) {
|
|
|
17
17
|
}
|
|
18
18
|
const loadedModules = /* @__PURE__ */ new Set();
|
|
19
19
|
function loadDevConfig(devConfigPath) {
|
|
20
|
+
if (process.env.DEPLOY === "true") return null;
|
|
20
21
|
try {
|
|
21
22
|
const fullPath = path.resolve(devConfigPath);
|
|
22
23
|
if (loadedModules.has(fullPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/build/rspack/utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { getNormalizedRemoteName } from \"every-plugin/normalize\";\n\nexport interface PluginInfo {\n name: string;\n version: string;\n normalizedName: string;\n dependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n}\n\nexport function getPluginInfo(context: string): PluginInfo {\n const pkgPath = path.join(context, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\n return {\n name: pkg.name,\n version: pkg.version,\n normalizedName: getNormalizedRemoteName(pkg.name),\n dependencies: pkg.dependencies || {},\n peerDependencies: pkg.peerDependencies || {},\n };\n}\n\nconst loadedModules = new Set<string>();\n\nexport function loadDevConfig(devConfigPath: string) {\n if (process.env.DEPLOY === \"true\") {\n return null;\n }\n\n try {\n const fullPath = path.resolve(devConfigPath);\n\n if (loadedModules.has(fullPath)) {\n delete require.cache[fullPath];\n const dirPath = path.dirname(fullPath);\n for (const key of Object.keys(require.cache)) {\n if (key.startsWith(dirPath) && key !== fullPath) {\n delete require.cache[key];\n }\n }\n }\n\n const module = require(fullPath).default;\n loadedModules.add(fullPath);\n return module;\n } catch (error) {\n console.warn(`Could not load dev config from ${devConfigPath}:`, (error as Error).message);\n return null;\n }\n}\n\nexport function cleanupDevConfig() {\n for (const modulePath of loadedModules) {\n delete require.cache[modulePath];\n }\n loadedModules.clear();\n}\n"],"mappings":";;;;;;AAYA,SAAgB,cAAc,SAA6B;CACzD,MAAM,UAAU,KAAK,KAAK,SAAS,eAAe;CAClD,MAAM,MAAM,KAAK,MAAM,GAAG,aAAa,SAAS,QAAQ,CAAC;AAEzD,QAAO;EACL,MAAM,IAAI;EACV,SAAS,IAAI;EACb,gBAAgB,wBAAwB,IAAI,KAAK;EACjD,cAAc,IAAI,gBAAgB,EAAE;EACpC,kBAAkB,IAAI,oBAAoB,EAAE;EAC7C;;AAGH,MAAM,gCAAgB,IAAI,KAAa;AAEvC,SAAgB,cAAc,eAAuB;AACnD,KAAI,QAAQ,IAAI,WAAW,OACzB,QAAO;AAGT,KAAI;EACF,MAAM,WAAW,KAAK,QAAQ,cAAc;AAE5C,MAAI,cAAc,IAAI,SAAS,EAAE;AAC/B,oBAAe,MAAM;GACrB,MAAM,UAAU,KAAK,QAAQ,SAAS;AACtC,QAAK,MAAM,OAAO,OAAO,eAAa,MAAM,CAC1C,KAAI,IAAI,WAAW,QAAQ,IAAI,QAAQ,SACrC,kBAAe,MAAM;;EAK3B,MAAM,mBAAiB,SAAS,CAAC;AACjC,gBAAc,IAAI,SAAS;AAC3B,SAAO;UACA,OAAO;AACd,UAAQ,KAAK,kCAAkC,cAAc,IAAK,MAAgB,QAAQ;AAC1F,SAAO"}
|
|
@@ -1,80 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let node_module = require("node:module");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let node_url = require("node:url");
|
|
2
7
|
|
|
3
8
|
//#region src/build/shared-deps.ts
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
singleton: true,
|
|
22
|
-
strictVersion: false,
|
|
23
|
-
eager: false
|
|
24
|
-
},
|
|
25
|
-
"@orpc/contract": {
|
|
26
|
-
version: require_package.dependencies["@orpc/contract"],
|
|
27
|
-
singleton: true,
|
|
28
|
-
strictVersion: false,
|
|
29
|
-
eager: false
|
|
30
|
-
},
|
|
31
|
-
"@orpc/server": {
|
|
32
|
-
version: require_package.dependencies["@orpc/server"],
|
|
33
|
-
singleton: true,
|
|
34
|
-
strictVersion: false,
|
|
35
|
-
eager: false
|
|
36
|
-
}
|
|
37
|
-
};
|
|
9
|
+
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
10
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
11
|
+
let pkg;
|
|
12
|
+
try {
|
|
13
|
+
pkg = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(__dirname$1, "../../package.json"), "utf-8"));
|
|
14
|
+
} catch {
|
|
15
|
+
pkg = require$1("every-plugin/package.json");
|
|
16
|
+
}
|
|
17
|
+
const DEFAULT_SHARE_CONFIG = {
|
|
18
|
+
requiredVersion: false,
|
|
19
|
+
singleton: true,
|
|
20
|
+
strictVersion: false,
|
|
21
|
+
eager: false
|
|
22
|
+
};
|
|
23
|
+
function extractExactVersion(input) {
|
|
24
|
+
const match = input.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/);
|
|
25
|
+
return match ? match[0] : input.replace(/^[\^~>=<\s]+/, "");
|
|
38
26
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
27
|
+
function getInstalledPackageVersion(packageName, fallbackVersion) {
|
|
28
|
+
try {
|
|
29
|
+
return require$1(`${packageName}/package.json`).version;
|
|
30
|
+
} catch {
|
|
31
|
+
return extractExactVersion(fallbackVersion);
|
|
32
|
+
}
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
34
|
+
const pluginSharedDependencies = {
|
|
35
|
+
"every-plugin": {
|
|
36
|
+
version: pkg.version,
|
|
37
|
+
...DEFAULT_SHARE_CONFIG
|
|
38
|
+
},
|
|
39
|
+
effect: {
|
|
40
|
+
version: getInstalledPackageVersion("effect", pkg.peerDependencies.effect),
|
|
41
|
+
...DEFAULT_SHARE_CONFIG
|
|
42
|
+
},
|
|
43
|
+
zod: {
|
|
44
|
+
version: getInstalledPackageVersion("zod", pkg.peerDependencies.zod),
|
|
45
|
+
...DEFAULT_SHARE_CONFIG
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function getPluginSharedDependencies() {
|
|
49
|
+
return pluginSharedDependencies;
|
|
52
50
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
55
|
-
...getPluginSharedDependencies(),
|
|
56
|
-
...getUISharedDependencies()
|
|
57
|
-
};
|
|
51
|
+
function getPluginSharedDependenciesVersionRange() {
|
|
52
|
+
return Object.fromEntries(Object.entries(getPluginSharedDependencies()).map(([name, config]) => [name, getMajorMinorVersion(config.version)]));
|
|
58
53
|
}
|
|
59
|
-
function getMajorMinorVersion(version
|
|
60
|
-
const match = version
|
|
54
|
+
function getMajorMinorVersion(version) {
|
|
55
|
+
const match = version.replace(/^[\^~>=<]+/, "").match(/^(\d+)\.(\d+)/);
|
|
61
56
|
if (!match) return "^0.0.0";
|
|
62
57
|
return `^${match[1]}.${match[2]}.0`;
|
|
63
58
|
}
|
|
64
|
-
function getPluginSharedDependenciesVersionRange() {
|
|
65
|
-
const deps = getPluginSharedDependencies();
|
|
66
|
-
const result = {};
|
|
67
|
-
for (const [key, config] of Object.entries(deps)) result[key] = {
|
|
68
|
-
...config,
|
|
69
|
-
version: getMajorMinorVersion(config.version)
|
|
70
|
-
};
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
59
|
|
|
74
60
|
//#endregion
|
|
75
|
-
exports.getHostSharedDependencies = getHostSharedDependencies;
|
|
76
61
|
exports.getMajorMinorVersion = getMajorMinorVersion;
|
|
77
62
|
exports.getPluginSharedDependencies = getPluginSharedDependencies;
|
|
78
63
|
exports.getPluginSharedDependenciesVersionRange = getPluginSharedDependenciesVersionRange;
|
|
79
|
-
exports.
|
|
64
|
+
exports.pluginSharedDependencies = pluginSharedDependencies;
|
|
80
65
|
//# sourceMappingURL=shared-deps.cjs.map
|