@shijiu/jsview 2.1.362-test.0 → 2.1.363-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -21,7 +21,11 @@ async function main(argv)
|
|
|
21
21
|
const filter = argv.filter ?? '^jsview-';
|
|
22
22
|
const regex = new RegExp(filter);
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
var exportPrefix = 'export';
|
|
25
|
+
if(process.platform == 'win32') {
|
|
26
|
+
exportPrefix = 'set'
|
|
27
|
+
}
|
|
28
|
+
execCommand(exportPrefix + ' JSVIEW_KEEP_CHUNKNAME=true && npm run build');
|
|
25
29
|
|
|
26
30
|
const srcmapFileNames = fs.readdirSync(options.distDebugMapDir);
|
|
27
31
|
const needlessFileNames = srcmapFileNames.filter(it => !it.match(regex));
|
package/tools/jsview-common.mjs
CHANGED
|
@@ -444,7 +444,7 @@ function unzipFile(zipFilePath, toDir, workDir)
|
|
|
444
444
|
}
|
|
445
445
|
Logger.Info('Unzipping ' + zipFilePath + ' => ' + relativePath);
|
|
446
446
|
|
|
447
|
-
const cmdline = 'npx extract-zip ' + zipFilePath + ' ' + toDir;
|
|
447
|
+
const cmdline = 'npx -y extract-zip ' + zipFilePath + ' ' + toDir;
|
|
448
448
|
execCommand(cmdline);
|
|
449
449
|
}
|
|
450
450
|
|
|
@@ -137,7 +137,7 @@ function getChunkFileName(chunkInfo) {
|
|
|
137
137
|
if(chunkInfo.name == '__federation_expose_JsViewLoader') {
|
|
138
138
|
return 'js/JsViewLoader.js'
|
|
139
139
|
}
|
|
140
|
-
return 'js/chunk.jsv.[hash].js'
|
|
140
|
+
return (process.env['JSVIEW_KEEP_CHUNKNAME'] ? 'js/[name].[hash].js' : 'js/chunk.jsv.[hash].js')
|
|
141
141
|
}`;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -172,14 +172,14 @@ function setFederationHostConfig(config) {`;
|
|
|
172
172
|
content += '\n'
|
|
173
173
|
if(options.mode == 'remote') {
|
|
174
174
|
content += `
|
|
175
|
-
const
|
|
175
|
+
const federationConfig = getRemoteConfig()`;
|
|
176
176
|
} else if(options.mode == 'host') {
|
|
177
177
|
content += `
|
|
178
|
-
const
|
|
178
|
+
const federationConfig = getHostConfig()`;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
content += `
|
|
182
|
-
config.plugins.push(federation(
|
|
182
|
+
config.plugins.push(federation(federationConfig))
|
|
183
183
|
|
|
184
184
|
}`;
|
|
185
185
|
|
|
@@ -204,7 +204,7 @@ import federation from '@originjs/vite-plugin-federation'`;
|
|
|
204
204
|
|
|
205
205
|
federationConfigContent += `
|
|
206
206
|
export {
|
|
207
|
-
|
|
207
|
+
setFederationRemoteConfig,
|
|
208
208
|
}`;
|
|
209
209
|
|
|
210
210
|
fs.writeFileSync(path.resolve(options.projectDir, federationConfigName),
|
|
@@ -256,6 +256,7 @@ async function updateViteConfigFile(options)
|
|
|
256
256
|
viteConfigContent = viteConfigContent.replace(regex, 'const viteConfig = ');
|
|
257
257
|
|
|
258
258
|
// 开头添加
|
|
259
|
+
viteConfigContent = "import federation from '@originjs/vite-plugin-federation'\n" + viteConfigContent;
|
|
259
260
|
if(options.mode == 'remote') {
|
|
260
261
|
viteConfigContent = "import { setFederationRemoteConfig } from './federation.remote.config'\n" + viteConfigContent;
|
|
261
262
|
} else if(options.mode == 'host') {
|
|
@@ -265,9 +266,9 @@ async function updateViteConfigFile(options)
|
|
|
265
266
|
// 末尾添加
|
|
266
267
|
viteConfigContent += '\n';
|
|
267
268
|
if(options.mode == 'remote') {
|
|
268
|
-
viteConfigContent += 'setFederationRemoteConfig(viteConfig)\n';
|
|
269
|
+
viteConfigContent += 'setFederationRemoteConfig(viteConfig, federation)\n';
|
|
269
270
|
} else if(options.mode == 'host') {
|
|
270
|
-
viteConfigContent += 'setFederationHostConfig(viteConfig)\n';
|
|
271
|
+
viteConfigContent += 'setFederationHostConfig(viteConfig, federation)\n';
|
|
271
272
|
}
|
|
272
273
|
viteConfigContent += '\n';
|
|
273
274
|
viteConfigContent += 'export default defineConfig(viteConfig)\n';
|
|
@@ -295,6 +296,24 @@ function updateJsviewConfigFile(options)
|
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
|
|
299
|
+
function updateTsConfigFile(options)
|
|
300
|
+
{
|
|
301
|
+
const tsConfigName = 'tsconfig.json';
|
|
302
|
+
Logger.Info('Updating ' + tsConfigName + ' ...');
|
|
303
|
+
|
|
304
|
+
if(options.mode == 'host') {
|
|
305
|
+
if(options.jsviewMode == 'expose') {
|
|
306
|
+
const tsConfigPath = path.resolve(options.projectDir, tsConfigName);
|
|
307
|
+
var tsConfigContent = fs.readFileSync(tsConfigPath, 'utf-8');
|
|
308
|
+
const regex = /RemoteEntry/;
|
|
309
|
+
if(regex.test(tsConfigContent) == false) {
|
|
310
|
+
tsConfigContent = tsConfigContent.replace(/"jsview"/, '"RemoteEntry/JsViewVue": [ "./node_modules/@shijiu/jsview-vue" ],\n $&');
|
|
311
|
+
}
|
|
312
|
+
fs.writeFileSync(options.appJsviewConfigFile, tsConfigContent, 'utf-8');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
298
317
|
function updateToFederationRemote(options)
|
|
299
318
|
{
|
|
300
319
|
createFederationRemoteConfigFile(options);
|
|
@@ -309,6 +328,8 @@ function updateToFederationHost(options)
|
|
|
309
328
|
updateViteConfigFile(options);
|
|
310
329
|
|
|
311
330
|
updateJsviewConfigFile(options);
|
|
331
|
+
|
|
332
|
+
updateTsConfigFile(options);
|
|
312
333
|
}
|
|
313
334
|
|
|
314
335
|
|
|
@@ -346,8 +367,8 @@ async function main(argv)
|
|
|
346
367
|
}
|
|
347
368
|
Logger.Info('Success to update project to module federation.');
|
|
348
369
|
Logger.Info('Module federation info:');
|
|
349
|
-
Logger.Info('
|
|
350
|
-
Logger.Info('
|
|
370
|
+
Logger.Info(' Mode: ' + options.mode);
|
|
371
|
+
Logger.Info(' JsView: ' + options.jsviewMode);
|
|
351
372
|
if(options.mode == 'host') {
|
|
352
373
|
Logger.Info(' remote entry url: ' + options.remoteDomain + '/js/remoteEntry.js');
|
|
353
374
|
}
|