@module-federation/rsbuild-plugin 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,406 @@
1
+ import { parseOptions } from "@module-federation/enhanced";
2
+ import { ModuleFederationPlugin, PLUGIN_NAME, TreeShakingSharedPlugin } from "@module-federation/enhanced/rspack";
3
+ import { createModuleFederationConfig, getManifestFileName, isRequiredVersion } from "@module-federation/sdk";
4
+ import package_0 from "../../package.json";
5
+ import logger from "../logger.mjs";
6
+ import { SSR_DIR, SSR_ENV_NAME, addDataFetchExposes, autoDeleteSplitChunkCacheGroups, createSSRMFConfig, createSSRREnvConfig, isRegExp, patchSSRRspackConfig, setSSREnv, updateStatsAndManifest } from "../utils.mjs";
7
+ import { CALL_NAME_MAP, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSG_MD_ENV_NAME, RSPRESS_SSR_DIR } from "../constant.mjs";
8
+ import { patchNodeConfig, patchToolsTspack } from "../utils/ssr.mjs";
9
+
10
+ ;// CONCATENATED MODULE: external "@module-federation/enhanced"
11
+
12
+ ;// CONCATENATED MODULE: external "@module-federation/enhanced/rspack"
13
+
14
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
15
+
16
+ ;// CONCATENATED MODULE: external "../../package.json"
17
+
18
+ ;// CONCATENATED MODULE: external "../logger.mjs"
19
+
20
+ ;// CONCATENATED MODULE: external "../utils.mjs"
21
+
22
+ ;// CONCATENATED MODULE: external "../constant.mjs"
23
+
24
+ ;// CONCATENATED MODULE: external "../utils/ssr.mjs"
25
+
26
+ ;// CONCATENATED MODULE: ./src/cli/index.ts
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ const RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
36
+ const RSBUILD_PLUGIN_NAME = '@module-federation/rsbuild-plugin';
37
+
38
+ const LIB_FORMAT = [
39
+ 'umd',
40
+ 'modern-module'
41
+ ];
42
+ const DEFAULT_MF_ENVIRONMENT_NAME = 'mf';
43
+ const DEFAULT_WEB_ENVIRONMENT_NAME = 'web';
44
+ const DEFAULT_NODE_ENVIRONMENT_NAME = 'node';
45
+ const resolveDefaultEnvironmentName = ({ callerName, target })=>{
46
+ if (callerName === CALL_NAME_MAP.RSLIB) {
47
+ return DEFAULT_MF_ENVIRONMENT_NAME;
48
+ }
49
+ if (callerName === CALL_NAME_MAP.RSPRESS) {
50
+ if (target === 'node') {
51
+ return DEFAULT_NODE_ENVIRONMENT_NAME;
52
+ }
53
+ return DEFAULT_WEB_ENVIRONMENT_NAME;
54
+ }
55
+ if (target === 'node') {
56
+ return DEFAULT_NODE_ENVIRONMENT_NAME;
57
+ }
58
+ return DEFAULT_WEB_ENVIRONMENT_NAME;
59
+ };
60
+ function isStoryBook(rsbuildConfig) {
61
+ var _rsbuildConfig_plugins;
62
+ if ((_rsbuildConfig_plugins = rsbuildConfig.plugins) === null || _rsbuildConfig_plugins === void 0 ? void 0 : _rsbuildConfig_plugins.find((p)=>p && 'name' in p && p.name === 'module-federation-storybook-plugin')) {
63
+ return true;
64
+ }
65
+ return false;
66
+ }
67
+ function isMFFormat(bundlerConfig) {
68
+ var _bundlerConfig_output;
69
+ const library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
70
+ if (bundlerConfig.name === SSR_ENV_NAME) {
71
+ return true;
72
+ }
73
+ return !(typeof library === 'object' && !Array.isArray(library) && 'type' in library && // if the type is umd/modern-module or commonjs*, means this is a normal library , not mf
74
+ (LIB_FORMAT.includes(library.type) || /commonjs/.test(library.type)));
75
+ }
76
+ const isSSRConfig = (bundlerConfigName)=>Boolean(bundlerConfigName === SSR_ENV_NAME);
77
+ const isRspressSSGConfig = (bundlerConfigName)=>{
78
+ return [
79
+ RSPRESS_BUNDLER_CONFIG_NAME,
80
+ RSPRESS_SSG_MD_ENV_NAME
81
+ ].includes(bundlerConfigName || '');
82
+ };
83
+ const pluginModuleFederation = (moduleFederationOptions, rsbuildOptions)=>({
84
+ name: RSBUILD_PLUGIN_MODULE_FEDERATION_NAME,
85
+ setup: (api)=>{
86
+ if (!(moduleFederationOptions === null || moduleFederationOptions === void 0 ? void 0 : moduleFederationOptions.name)) {
87
+ throw new Error('The module federation option "name" is required in @module-federation/rsbuild-plugin.');
88
+ }
89
+ const { target = 'web', ssr = undefined, ssrDir = SSR_DIR, environment: configuredEnvironment } = rsbuildOptions || {};
90
+ if (ssr) {
91
+ throw new Error("The `ssr` option is deprecated. If you want to enable SSR, please use `target: 'dual'` instead.");
92
+ }
93
+ const { callerName } = api.context;
94
+ const originalRsbuildConfig = api.getRsbuildConfig();
95
+ if (!callerName) {
96
+ throw new Error('`callerName` is undefined. Please ensure the @rsbuild/core version is higher than 1.3.21 .');
97
+ }
98
+ const isRslib = callerName === CALL_NAME_MAP.RSLIB;
99
+ const isRspress = callerName === CALL_NAME_MAP.RSPRESS;
100
+ const isSSR = target === 'dual';
101
+ const environment = configuredEnvironment ?? resolveDefaultEnvironmentName({
102
+ callerName,
103
+ target
104
+ });
105
+ if (isSSR && !isStoryBook(originalRsbuildConfig)) {
106
+ var _rsbuildConfig_environments;
107
+ if (!isRslib && !isRspress) {
108
+ throw new Error(`'target' option is only supported in Rslib.`);
109
+ }
110
+ const rsbuildConfig = api.getRsbuildConfig();
111
+ if (!isRspress && (!((_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[environment]) || Object.keys(rsbuildConfig.environments).some((key)=>key.startsWith(environment) && key !== environment))) {
112
+ throw new Error(`Please set ${RSBUILD_PLUGIN_NAME} as global plugin in rslib.config.ts if you set 'target: "dual"'.`);
113
+ }
114
+ setSSREnv();
115
+ }
116
+ const sharedOptions = parseOptions(moduleFederationOptions.shared || [], (item, key)=>{
117
+ if (typeof item !== 'string') throw new Error('Unexpected array in shared');
118
+ const config = item === key || !isRequiredVersion(item) ? {
119
+ import: item
120
+ } : {
121
+ import: key,
122
+ requiredVersion: item
123
+ };
124
+ return config;
125
+ }, (item)=>item);
126
+ // shared[0] is the shared name
127
+ const shared = sharedOptions.map((shared)=>shared[0].endsWith('/') ? shared[0].slice(0, -1) : shared[0]);
128
+ api.modifyRsbuildConfig((config)=>{
129
+ // skip storybook
130
+ if (isStoryBook(config)) {
131
+ return;
132
+ }
133
+ // Change some default configs for remote modules
134
+ if (moduleFederationOptions.exposes) {
135
+ var _userConfig_server, _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
136
+ config.dev ||= {};
137
+ config.server ||= {};
138
+ const userConfig = api.getRsbuildConfig('original');
139
+ // Allow remote modules to be loaded by setting CORS headers
140
+ // This is required for MF to work properly across different origins
141
+ config.server.headers ||= {};
142
+ if (!config.server.headers['Access-Control-Allow-Origin'] && !(typeof ((_userConfig_server = userConfig.server) === null || _userConfig_server === void 0 ? void 0 : _userConfig_server.cors) === 'object' && userConfig.server.cors.origin)) {
143
+ const corsWarnMsgs = [
144
+ 'Detect that CORS options are not set, mf Rsbuild plugin will add default cors header: server.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins in "server.cors" instead.',
145
+ 'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
146
+ ];
147
+ !isRslib && !isRspress && logger.warn(corsWarnMsgs.join('\n'));
148
+ config.server.headers['Access-Control-Allow-Origin'] = '*';
149
+ }
150
+ // For remote modules, Rsbuild should send the ws request to the provider's dev server.
151
+ // This allows the provider to do HMR when the provider module is loaded in the consumer's page.
152
+ if (((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.port) && !((_config_dev_client = config.dev.client) === null || _config_dev_client === void 0 ? void 0 : _config_dev_client.port)) {
153
+ config.dev.client ||= {};
154
+ config.dev.client.port = config.server.port;
155
+ }
156
+ // Change the default assetPrefix to `true` for remote modules.
157
+ // This ensures that the remote module's assets can be requested by consumer apps with the correct URL.
158
+ const originalConfig = api.getRsbuildConfig('original');
159
+ if (((_originalConfig_dev = originalConfig.dev) === null || _originalConfig_dev === void 0 ? void 0 : _originalConfig_dev.assetPrefix) === undefined && config.dev.assetPrefix === ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.base)) {
160
+ config.dev.assetPrefix = true;
161
+ }
162
+ }
163
+ if (isSSR) {
164
+ var _config_environments, _config_environments1;
165
+ if ((_config_environments = config.environments) === null || _config_environments === void 0 ? void 0 : _config_environments[SSR_ENV_NAME]) {
166
+ throw new Error(`'${SSR_ENV_NAME}' environment is already defined.Please use another name.`);
167
+ }
168
+ config.environments[SSR_ENV_NAME] = createSSRREnvConfig((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1[environment], moduleFederationOptions, ssrDir, config, callerName);
169
+ const ssgMDEnv = config.environments[RSPRESS_SSG_MD_ENV_NAME];
170
+ if (isRspress && ssgMDEnv) {
171
+ patchToolsTspack(ssgMDEnv, (config, { environment })=>{
172
+ config.target = 'async-node';
173
+ });
174
+ }
175
+ } else if (target === 'node') {
176
+ var _config_environments2;
177
+ const nodeTargetEnv = (_config_environments2 = config.environments) === null || _config_environments2 === void 0 ? void 0 : _config_environments2[environment];
178
+ if (!nodeTargetEnv) {
179
+ const availableEnvironments = Object.keys(config.environments || {});
180
+ const availableEnvironmentsLabel = availableEnvironments.length > 0 ? availableEnvironments.join(', ') : '(none)';
181
+ throw new Error(`Can not find environment '${environment}' when using target: 'node'. Available environments: ${availableEnvironmentsLabel}.`);
182
+ }
183
+ patchToolsTspack(nodeTargetEnv, (config, { environment })=>{
184
+ config.target = 'async-node';
185
+ });
186
+ }
187
+ });
188
+ api.modifyEnvironmentConfig((config)=>{
189
+ // Module Federation runtime uses ES6+ syntax,
190
+ // adding to include and let SWC transform it
191
+ config.source.include = [
192
+ ...config.source.include || [],
193
+ /@module-federation[\\/]/
194
+ ];
195
+ return config;
196
+ });
197
+ const generateMergedStatsAndManifestOptions = {
198
+ options: {
199
+ nodePlugin: undefined,
200
+ browserPlugin: undefined,
201
+ rspressSSGPlugin: undefined,
202
+ distOutputDir: undefined,
203
+ browserEnvironmentName: undefined,
204
+ nodeEnvironmentName: undefined
205
+ },
206
+ assetResources: {},
207
+ isSSRConfig,
208
+ isRspressSSGConfig
209
+ };
210
+ api.expose(RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, generateMergedStatsAndManifestOptions);
211
+ const defaultBrowserEnvironmentName = environment;
212
+ const assetFileNames = getManifestFileName(moduleFederationOptions.manifest);
213
+ if (moduleFederationOptions.manifest !== false) {
214
+ api.processAssets({
215
+ stage: 'report'
216
+ }, ({ assets, environment: envContext })=>{
217
+ const expectedBrowserEnv = generateMergedStatsAndManifestOptions.options.browserEnvironmentName ?? defaultBrowserEnvironmentName;
218
+ const expectedNodeEnv = generateMergedStatsAndManifestOptions.options.nodeEnvironmentName ?? SSR_ENV_NAME;
219
+ const envName = envContext.name;
220
+ if (envName !== expectedBrowserEnv && envName !== expectedNodeEnv) {
221
+ return;
222
+ }
223
+ const assetResources = generateMergedStatsAndManifestOptions.assetResources;
224
+ const targetResources = assetResources[envName] || (assetResources[envName] = {});
225
+ const statsAsset = assets[assetFileNames.statsFileName];
226
+ if (statsAsset) {
227
+ try {
228
+ const raw = statsAsset.source();
229
+ const content = typeof raw === 'string' ? raw : raw.toString();
230
+ targetResources.stats = {
231
+ data: JSON.parse(content),
232
+ filename: assetFileNames.statsFileName
233
+ };
234
+ } catch (err) {
235
+ const message = err instanceof Error ? err.message : String(err);
236
+ logger.error(`Failed to parse stats asset "${assetFileNames.statsFileName}" for environment "${envName}": ${message} `);
237
+ }
238
+ }
239
+ const manifestAsset = assets[assetFileNames.manifestFileName];
240
+ if (manifestAsset) {
241
+ try {
242
+ const raw = manifestAsset.source();
243
+ const content = typeof raw === 'string' ? raw : raw.toString();
244
+ targetResources.manifest = {
245
+ data: JSON.parse(content),
246
+ filename: assetFileNames.manifestFileName
247
+ };
248
+ } catch (err) {
249
+ const message = err instanceof Error ? err.message : String(err);
250
+ logger.error(`Failed to parse manifest asset "${assetFileNames.manifestFileName}" for environment "${envName}": ${message} `);
251
+ }
252
+ }
253
+ });
254
+ }
255
+ api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
256
+ if (!bundlerConfigs) {
257
+ throw new Error('Can not get bundlerConfigs!');
258
+ }
259
+ bundlerConfigs.forEach((bundlerConfig)=>{
260
+ const bundlerConfigName = bundlerConfig.name || '';
261
+ const isConfiguredEnvironmentConfig = bundlerConfigName === environment;
262
+ const isNodeTargetEnvironmentConfig = target === 'node' && bundlerConfigName === environment;
263
+ const isRspressSSGEnvironmentConfig = isRspressSSGConfig(bundlerConfig.name);
264
+ const isActiveRspressSSGEnvironmentConfig = isRspress && isRspressSSGEnvironmentConfig;
265
+ const shouldUseSSRPluginConfig = isSSRConfig(bundlerConfig.name) || isNodeTargetEnvironmentConfig;
266
+ if (target === 'node' && !isNodeTargetEnvironmentConfig && !isActiveRspressSSGEnvironmentConfig) {
267
+ return;
268
+ }
269
+ // For non-node targets, scope each plugin instance to its configured
270
+ // environment plus explicit SSR/SSG environments. This prevents a
271
+ // browser-targeted instance from mutating SSR configs.
272
+ if (target !== 'node' && !isConfiguredEnvironmentConfig && !shouldUseSSRPluginConfig && !isActiveRspressSSGEnvironmentConfig) {
273
+ return;
274
+ }
275
+ if (!isMFFormat(bundlerConfig) && !isRspress && !isNodeTargetEnvironmentConfig) {
276
+ return;
277
+ } else if (isStoryBook(originalRsbuildConfig)) {
278
+ bundlerConfig.output.uniqueName = `${moduleFederationOptions.name} -storybook - host`;
279
+ } else {
280
+ var _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output, _bundlerConfig_output1, _bundlerConfig_output2;
281
+ // mf
282
+ autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig === null || bundlerConfig === void 0 ? void 0 : (_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks);
283
+ addDataFetchExposes(moduleFederationOptions.exposes, shouldUseSSRPluginConfig);
284
+ const ssrModuleFederationOptions = shouldUseSSRPluginConfig ? createSSRMFConfig(moduleFederationOptions) : undefined;
285
+ (_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? true : delete _bundlerConfig_optimization1.runtimeChunk;
286
+ const externals = bundlerConfig.externals;
287
+ if (Array.isArray(externals)) {
288
+ const sharedModules = new Set();
289
+ bundlerConfig.externals = externals.filter((ext)=>{
290
+ let sharedModule;
291
+ if (isRegExp(ext)) {
292
+ const match = shared.some((dep)=>{
293
+ if (ext.test(dep) || ext.test(package_0.name)) {
294
+ sharedModule = dep;
295
+ return true;
296
+ }
297
+ return false;
298
+ });
299
+ match && sharedModule && sharedModules.add(sharedModule);
300
+ return !match;
301
+ }
302
+ if (typeof ext === 'string') {
303
+ if (ext === package_0.name) {
304
+ return false;
305
+ }
306
+ const match = shared.some((dep)=>{
307
+ if (dep === ext) {
308
+ sharedModule = dep;
309
+ }
310
+ return dep === ext;
311
+ });
312
+ if (match) {
313
+ sharedModule && sharedModules.add(sharedModule);
314
+ return false;
315
+ }
316
+ return true;
317
+ }
318
+ return true;
319
+ });
320
+ if (sharedModules.size > 0) {
321
+ for (const sharedModule of sharedModules){
322
+ logger.log(`${sharedModule} is removed from externals because it is a shared module.`);
323
+ }
324
+ }
325
+ }
326
+ if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal) && !shouldUseSSRPluginConfig && !isActiveRspressSSGEnvironmentConfig && target !== 'node') {
327
+ bundlerConfig.output.chunkLoading = 'jsonp';
328
+ bundlerConfig.output.chunkLoadingGlobal = `chunk_${moduleFederationOptions.name} `;
329
+ }
330
+ if (isNodeTargetEnvironmentConfig) {
331
+ patchNodeConfig(bundlerConfig, ssrModuleFederationOptions ?? moduleFederationOptions);
332
+ }
333
+ // `uniqueName` is required for react refresh to work
334
+ if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.uniqueName)) {
335
+ bundlerConfig.output.uniqueName = moduleFederationOptions.name;
336
+ }
337
+ // Set default publicPath to 'auto' if not explicitly configured
338
+ // This allows remote chunks to load from the same origin as the remote application's manifest
339
+ if (((_bundlerConfig_output2 = bundlerConfig.output) === null || _bundlerConfig_output2 === void 0 ? void 0 : _bundlerConfig_output2.publicPath) === undefined && !shouldUseSSRPluginConfig && !isActiveRspressSSGEnvironmentConfig) {
340
+ bundlerConfig.output.publicPath = 'auto';
341
+ }
342
+ if (!bundlerConfig.plugins.find((p)=>p && p.name === PLUGIN_NAME)) {
343
+ var _bundlerConfig_output3;
344
+ if (shouldUseSSRPluginConfig) {
345
+ const ssrMFConfig = ssrModuleFederationOptions ?? createSSRMFConfig(moduleFederationOptions);
346
+ generateMergedStatsAndManifestOptions.options.nodePlugin = new ModuleFederationPlugin(ssrMFConfig);
347
+ generateMergedStatsAndManifestOptions.options.nodeEnvironmentName = bundlerConfig.name || SSR_ENV_NAME;
348
+ bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.nodePlugin);
349
+ return;
350
+ } else if (isActiveRspressSSGEnvironmentConfig) {
351
+ const mfConfig = {
352
+ ...createSSRMFConfig(moduleFederationOptions),
353
+ // expose in mf-ssg env
354
+ exposes: {},
355
+ manifest: false,
356
+ library: undefined
357
+ };
358
+ patchSSRRspackConfig(bundlerConfig, mfConfig, RSPRESS_SSR_DIR, callerName, false, false);
359
+ bundlerConfig.output ||= {};
360
+ bundlerConfig.output.publicPath = '/';
361
+ // MF depend on asyncChunks
362
+ bundlerConfig.output.asyncChunks = undefined;
363
+ const p = new ModuleFederationPlugin(mfConfig);
364
+ if (bundlerConfig.name === RSPRESS_BUNDLER_CONFIG_NAME) {
365
+ generateMergedStatsAndManifestOptions.options.rspressSSGPlugin = p;
366
+ }
367
+ bundlerConfig.plugins.push(p);
368
+ return;
369
+ }
370
+ generateMergedStatsAndManifestOptions.options.browserPlugin = new ModuleFederationPlugin(moduleFederationOptions);
371
+ generateMergedStatsAndManifestOptions.options.distOutputDir = ((_bundlerConfig_output3 = bundlerConfig.output) === null || _bundlerConfig_output3 === void 0 ? void 0 : _bundlerConfig_output3.path) || '';
372
+ generateMergedStatsAndManifestOptions.options.browserEnvironmentName = bundlerConfig.name || defaultBrowserEnvironmentName;
373
+ bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.browserPlugin);
374
+ }
375
+ }
376
+ });
377
+ });
378
+ const generateMergedStatsAndManifest = ()=>{
379
+ const { distOutputDir, browserEnvironmentName, nodeEnvironmentName } = generateMergedStatsAndManifestOptions.options;
380
+ if (!distOutputDir || !browserEnvironmentName || !nodeEnvironmentName) {
381
+ return;
382
+ }
383
+ const assetResources = generateMergedStatsAndManifestOptions.assetResources;
384
+ const browserAssets = assetResources[browserEnvironmentName];
385
+ const nodeAssets = assetResources[nodeEnvironmentName];
386
+ if (!browserAssets || !nodeAssets) {
387
+ return;
388
+ }
389
+ try {
390
+ updateStatsAndManifest(nodeAssets, browserAssets, distOutputDir);
391
+ } catch (err) {
392
+ logger.error(err);
393
+ }
394
+ };
395
+ api.onDevCompileDone(()=>{
396
+ generateMergedStatsAndManifest();
397
+ });
398
+ api.onAfterBuild(()=>{
399
+ generateMergedStatsAndManifest();
400
+ });
401
+ }
402
+ });
403
+
404
+
405
+
406
+ export { PLUGIN_NAME, RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, SSR_DIR, TreeShakingSharedPlugin, createModuleFederationConfig, isMFFormat, pluginModuleFederation };
@@ -6,4 +6,5 @@ export declare const CALL_NAME_MAP: {
6
6
  RSLIB: string;
7
7
  };
8
8
  export declare const RSPRESS_BUNDLER_CONFIG_NAME = "node";
9
+ export declare const RSPRESS_SSG_MD_ENV_NAME = "node_md";
9
10
  export declare const RSPRESS_SSR_DIR = "ssr";
package/dist/constant.js CHANGED
@@ -1,35 +1,50 @@
1
1
  "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
2
10
  var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/define_property_getters
14
+ (() => {
15
+ __webpack_require__.d = (exports, definition) => {
16
+ for(var key in definition) {
17
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
18
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
19
+ }
20
+ }
21
+ };
10
22
  })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
23
+ // webpack/runtime/has_own_property
24
+ (() => {
25
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
13
26
  })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
27
+ // webpack/runtime/make_namespace_object
28
+ (() => {
29
+ // define __esModule on exports
30
+ __webpack_require__.r = (exports) => {
31
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
32
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33
+ }
34
+ Object.defineProperty(exports, '__esModule', { value: true });
35
+ };
23
36
  })();
37
+ /************************************************************************/
24
38
  var __webpack_exports__ = {};
25
39
  __webpack_require__.r(__webpack_exports__);
26
40
  __webpack_require__.d(__webpack_exports__, {
27
- CALL_NAME_MAP: ()=>CALL_NAME_MAP,
28
- DATA_FETCH_CLIENT_SUFFIX: ()=>DATA_FETCH_CLIENT_SUFFIX,
29
- DATA_FETCH_IDENTIFIER: ()=>DATA_FETCH_IDENTIFIER,
30
- DEFAULT_ASSET_PREFIX: ()=>DEFAULT_ASSET_PREFIX,
31
- RSPRESS_BUNDLER_CONFIG_NAME: ()=>RSPRESS_BUNDLER_CONFIG_NAME,
32
- RSPRESS_SSR_DIR: ()=>RSPRESS_SSR_DIR
41
+ CALL_NAME_MAP: () => (CALL_NAME_MAP),
42
+ DATA_FETCH_CLIENT_SUFFIX: () => (DATA_FETCH_CLIENT_SUFFIX),
43
+ DATA_FETCH_IDENTIFIER: () => (DATA_FETCH_IDENTIFIER),
44
+ DEFAULT_ASSET_PREFIX: () => (DEFAULT_ASSET_PREFIX),
45
+ RSPRESS_BUNDLER_CONFIG_NAME: () => (RSPRESS_BUNDLER_CONFIG_NAME),
46
+ RSPRESS_SSG_MD_ENV_NAME: () => (RSPRESS_SSG_MD_ENV_NAME),
47
+ RSPRESS_SSR_DIR: () => (RSPRESS_SSR_DIR)
33
48
  });
34
49
  const DEFAULT_ASSET_PREFIX = '/';
35
50
  const DATA_FETCH_IDENTIFIER = 'data';
@@ -39,21 +54,19 @@ const CALL_NAME_MAP = {
39
54
  RSLIB: 'rslib'
40
55
  };
41
56
  const RSPRESS_BUNDLER_CONFIG_NAME = 'node';
57
+ const RSPRESS_SSG_MD_ENV_NAME = 'node_md';
42
58
  const RSPRESS_SSR_DIR = 'ssr';
59
+
43
60
  exports.CALL_NAME_MAP = __webpack_exports__.CALL_NAME_MAP;
44
61
  exports.DATA_FETCH_CLIENT_SUFFIX = __webpack_exports__.DATA_FETCH_CLIENT_SUFFIX;
45
62
  exports.DATA_FETCH_IDENTIFIER = __webpack_exports__.DATA_FETCH_IDENTIFIER;
46
63
  exports.DEFAULT_ASSET_PREFIX = __webpack_exports__.DEFAULT_ASSET_PREFIX;
47
64
  exports.RSPRESS_BUNDLER_CONFIG_NAME = __webpack_exports__.RSPRESS_BUNDLER_CONFIG_NAME;
65
+ exports.RSPRESS_SSG_MD_ENV_NAME = __webpack_exports__.RSPRESS_SSG_MD_ENV_NAME;
48
66
  exports.RSPRESS_SSR_DIR = __webpack_exports__.RSPRESS_SSR_DIR;
49
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
50
- "CALL_NAME_MAP",
51
- "DATA_FETCH_CLIENT_SUFFIX",
52
- "DATA_FETCH_IDENTIFIER",
53
- "DEFAULT_ASSET_PREFIX",
54
- "RSPRESS_BUNDLER_CONFIG_NAME",
55
- "RSPRESS_SSR_DIR"
56
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
57
- Object.defineProperty(exports, '__esModule', {
58
- value: true
59
- });
67
+ for(var __webpack_i__ in __webpack_exports__) {
68
+ if(["CALL_NAME_MAP","DATA_FETCH_CLIENT_SUFFIX","DATA_FETCH_IDENTIFIER","DEFAULT_ASSET_PREFIX","RSPRESS_BUNDLER_CONFIG_NAME","RSPRESS_SSG_MD_ENV_NAME","RSPRESS_SSR_DIR"].indexOf(__webpack_i__) === -1) {
69
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
70
+ }
71
+ }
72
+ Object.defineProperty(exports, '__esModule', { value: true });
package/dist/constant.mjs CHANGED
@@ -1,3 +1,5 @@
1
+
2
+ ;// CONCATENATED MODULE: ./src/constant.ts
1
3
  const DEFAULT_ASSET_PREFIX = '/';
2
4
  const DATA_FETCH_IDENTIFIER = 'data';
3
5
  const DATA_FETCH_CLIENT_SUFFIX = '.client';
@@ -6,5 +8,7 @@ const CALL_NAME_MAP = {
6
8
  RSLIB: 'rslib'
7
9
  };
8
10
  const RSPRESS_BUNDLER_CONFIG_NAME = 'node';
11
+ const RSPRESS_SSG_MD_ENV_NAME = 'node_md';
9
12
  const RSPRESS_SSR_DIR = 'ssr';
10
- export { CALL_NAME_MAP, DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER, DEFAULT_ASSET_PREFIX, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSR_DIR };
13
+
14
+ export { CALL_NAME_MAP, DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER, DEFAULT_ASSET_PREFIX, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSG_MD_ENV_NAME, RSPRESS_SSR_DIR };
@@ -0,0 +1 @@
1
+ export * from './cli/index';