@module-federation/vite 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +9 -27
- package/lib/index.esm.js +8 -27
- package/lib/index.modern.js +21 -30
- package/lib/index.umd.js +12 -30
- package/package.json +17 -19
package/lib/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
var defu = require('defu');
|
|
1
2
|
var fs = require('fs');
|
|
2
3
|
var path = require('pathe');
|
|
3
4
|
var pluginutils = require('@rollup/pluginutils');
|
|
4
5
|
var estreeWalker = require('estree-walker');
|
|
5
6
|
var MagicString = require('magic-string');
|
|
6
|
-
var defu = require('defu');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
9
|
|
|
@@ -25,6 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
return n;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
var defu__default = /*#__PURE__*/_interopDefaultLegacy(defu);
|
|
28
29
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
29
30
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
30
31
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
@@ -65,14 +66,6 @@ var addEntry = function addEntry(_ref) {
|
|
|
65
66
|
devEntryPath = config.base + devEntryPath.replace(/\\\\?/g, '/').replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/^\//, '');
|
|
66
67
|
},
|
|
67
68
|
configureServer: function configureServer(server) {
|
|
68
|
-
var _server$httpServer;
|
|
69
|
-
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
70
|
-
var _server$config$server = server.config.server,
|
|
71
|
-
port = _server$config$server.port,
|
|
72
|
-
hostConfig = _server$config$server.host;
|
|
73
|
-
var host = typeof hostConfig === 'string' && hostConfig !== '0.0.0.0' ? hostConfig : 'localhost';
|
|
74
|
-
fetch("http://" + host + ":" + port + devEntryPath)["catch"](function (e) {});
|
|
75
|
-
});
|
|
76
69
|
server.middlewares.use(function (req, res, next) {
|
|
77
70
|
if (!fileName) {
|
|
78
71
|
next();
|
|
@@ -683,7 +676,7 @@ function generateRemoteEntry(options) {
|
|
|
683
676
|
var HOST_AUTO_INIT_TAG = '__H_A_I__';
|
|
684
677
|
var hostAutoInitModule = new VirtualModule('hostAutoInit', HOST_AUTO_INIT_TAG);
|
|
685
678
|
function writeHostAutoInit() {
|
|
686
|
-
hostAutoInitModule.writeSync("\n
|
|
679
|
+
hostAutoInitModule.writeSync("\n const remoteEntryPromise = import(\"" + REMOTE_ENTRY_ID + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
687
680
|
}
|
|
688
681
|
function getHostAutoInitImportId() {
|
|
689
682
|
return hostAutoInitModule.getImportId();
|
|
@@ -1106,7 +1099,7 @@ function pluginProxyRemoteEntry () {
|
|
|
1106
1099
|
if (_command === 'serve') {
|
|
1107
1100
|
var _viteConfig$server, _viteConfig$server2;
|
|
1108
1101
|
var host = typeof ((_viteConfig$server = viteConfig.server) == null ? void 0 : _viteConfig$server.host) === 'string' && viteConfig.server.host !== '0.0.0.0' ? viteConfig.server.host : 'localhost';
|
|
1109
|
-
return Promise.resolve("\n const
|
|
1102
|
+
return Promise.resolve("\n const origin = window ? window.origin : \"//" + host + ":" + ((_viteConfig$server2 = viteConfig.server) == null ? void 0 : _viteConfig$server2.port) + "\"\n const remoteEntryPromise = await import(origin + \"" + (viteConfig.base + options.filename) + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
1110
1103
|
}
|
|
1111
1104
|
return Promise.resolve(code);
|
|
1112
1105
|
}
|
|
@@ -1260,22 +1253,6 @@ function proxySharedModule(options) {
|
|
|
1260
1253
|
};
|
|
1261
1254
|
}));
|
|
1262
1255
|
}
|
|
1263
|
-
}, {
|
|
1264
|
-
name: 'watchLocalSharedImportMap',
|
|
1265
|
-
apply: 'serve',
|
|
1266
|
-
config: function config(_config3) {
|
|
1267
|
-
_config3.optimizeDeps = defu.defu(_config3.optimizeDeps, {
|
|
1268
|
-
exclude: [getLocalSharedImportMapPath()]
|
|
1269
|
-
});
|
|
1270
|
-
_config3.server = defu.defu(_config3.server, {
|
|
1271
|
-
watch: {
|
|
1272
|
-
ignored: []
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
var watch = _config3.server.watch;
|
|
1276
|
-
watch.ignored = [].concat(watch.ignored);
|
|
1277
|
-
watch.ignored.push("!**" + getLocalSharedImportMapPath() + "**");
|
|
1278
|
-
}
|
|
1279
1256
|
}];
|
|
1280
1257
|
}
|
|
1281
1258
|
|
|
@@ -1348,6 +1325,11 @@ function federation(mfUserOptions) {
|
|
|
1348
1325
|
find: '@module-federation/runtime',
|
|
1349
1326
|
replacement: options.implementation
|
|
1350
1327
|
});
|
|
1328
|
+
_config.build = defu__default["default"](_config.build || {}, {
|
|
1329
|
+
commonjsOptions: {
|
|
1330
|
+
strictRequires: 'auto'
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1351
1333
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1352
1334
|
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
|
|
1353
1335
|
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
|
package/lib/index.esm.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import defu from 'defu';
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
import { mkdirSync, writeFileSync, existsSync, writeFile } from 'fs';
|
|
3
4
|
import * as path from 'pathe';
|
|
@@ -5,7 +6,6 @@ import path__default, { parse, join, dirname, resolve, relative } from 'pathe';
|
|
|
5
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
6
7
|
import { walk } from 'estree-walker';
|
|
7
8
|
import MagicString from 'magic-string';
|
|
8
|
-
import { defu } from 'defu';
|
|
9
9
|
|
|
10
10
|
function getFirstHtmlEntryFile(entryFiles) {
|
|
11
11
|
return entryFiles.find(function (file) {
|
|
@@ -42,14 +42,6 @@ var addEntry = function addEntry(_ref) {
|
|
|
42
42
|
devEntryPath = config.base + devEntryPath.replace(/\\\\?/g, '/').replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/^\//, '');
|
|
43
43
|
},
|
|
44
44
|
configureServer: function configureServer(server) {
|
|
45
|
-
var _server$httpServer;
|
|
46
|
-
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
47
|
-
var _server$config$server = server.config.server,
|
|
48
|
-
port = _server$config$server.port,
|
|
49
|
-
hostConfig = _server$config$server.host;
|
|
50
|
-
var host = typeof hostConfig === 'string' && hostConfig !== '0.0.0.0' ? hostConfig : 'localhost';
|
|
51
|
-
fetch("http://" + host + ":" + port + devEntryPath)["catch"](function (e) {});
|
|
52
|
-
});
|
|
53
45
|
server.middlewares.use(function (req, res, next) {
|
|
54
46
|
if (!fileName) {
|
|
55
47
|
next();
|
|
@@ -660,7 +652,7 @@ function generateRemoteEntry(options) {
|
|
|
660
652
|
var HOST_AUTO_INIT_TAG = '__H_A_I__';
|
|
661
653
|
var hostAutoInitModule = new VirtualModule('hostAutoInit', HOST_AUTO_INIT_TAG);
|
|
662
654
|
function writeHostAutoInit() {
|
|
663
|
-
hostAutoInitModule.writeSync("\n
|
|
655
|
+
hostAutoInitModule.writeSync("\n const remoteEntryPromise = import(\"" + REMOTE_ENTRY_ID + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
664
656
|
}
|
|
665
657
|
function getHostAutoInitImportId() {
|
|
666
658
|
return hostAutoInitModule.getImportId();
|
|
@@ -1083,7 +1075,7 @@ function pluginProxyRemoteEntry () {
|
|
|
1083
1075
|
if (_command === 'serve') {
|
|
1084
1076
|
var _viteConfig$server, _viteConfig$server2;
|
|
1085
1077
|
var host = typeof ((_viteConfig$server = viteConfig.server) == null ? void 0 : _viteConfig$server.host) === 'string' && viteConfig.server.host !== '0.0.0.0' ? viteConfig.server.host : 'localhost';
|
|
1086
|
-
return Promise.resolve("\n const
|
|
1078
|
+
return Promise.resolve("\n const origin = window ? window.origin : \"//" + host + ":" + ((_viteConfig$server2 = viteConfig.server) == null ? void 0 : _viteConfig$server2.port) + "\"\n const remoteEntryPromise = await import(origin + \"" + (viteConfig.base + options.filename) + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
1087
1079
|
}
|
|
1088
1080
|
return Promise.resolve(code);
|
|
1089
1081
|
}
|
|
@@ -1237,22 +1229,6 @@ function proxySharedModule(options) {
|
|
|
1237
1229
|
};
|
|
1238
1230
|
}));
|
|
1239
1231
|
}
|
|
1240
|
-
}, {
|
|
1241
|
-
name: 'watchLocalSharedImportMap',
|
|
1242
|
-
apply: 'serve',
|
|
1243
|
-
config: function config(_config3) {
|
|
1244
|
-
_config3.optimizeDeps = defu(_config3.optimizeDeps, {
|
|
1245
|
-
exclude: [getLocalSharedImportMapPath()]
|
|
1246
|
-
});
|
|
1247
|
-
_config3.server = defu(_config3.server, {
|
|
1248
|
-
watch: {
|
|
1249
|
-
ignored: []
|
|
1250
|
-
}
|
|
1251
|
-
});
|
|
1252
|
-
var watch = _config3.server.watch;
|
|
1253
|
-
watch.ignored = [].concat(watch.ignored);
|
|
1254
|
-
watch.ignored.push("!**" + getLocalSharedImportMapPath() + "**");
|
|
1255
|
-
}
|
|
1256
1232
|
}];
|
|
1257
1233
|
}
|
|
1258
1234
|
|
|
@@ -1325,6 +1301,11 @@ function federation(mfUserOptions) {
|
|
|
1325
1301
|
find: '@module-federation/runtime',
|
|
1326
1302
|
replacement: options.implementation
|
|
1327
1303
|
});
|
|
1304
|
+
_config.build = defu(_config.build || {}, {
|
|
1305
|
+
commonjsOptions: {
|
|
1306
|
+
strictRequires: 'auto'
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1328
1309
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1329
1310
|
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
|
|
1330
1311
|
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
|
package/lib/index.modern.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import defu from 'defu';
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
import { mkdirSync, writeFileSync, existsSync, writeFile } from 'fs';
|
|
3
4
|
import * as path from 'pathe';
|
|
@@ -5,7 +6,6 @@ import path__default, { parse, join, dirname, resolve, relative } from 'pathe';
|
|
|
5
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
6
7
|
import { walk } from 'estree-walker';
|
|
7
8
|
import MagicString from 'magic-string';
|
|
8
|
-
import { defu } from 'defu';
|
|
9
9
|
|
|
10
10
|
function getFirstHtmlEntryFile(entryFiles) {
|
|
11
11
|
return entryFiles.find(file => file.endsWith('.html'));
|
|
@@ -41,15 +41,6 @@ const addEntry = ({
|
|
|
41
41
|
devEntryPath = config.base + devEntryPath.replace(/\\\\?/g, '/').replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/^\//, '');
|
|
42
42
|
},
|
|
43
43
|
configureServer(server) {
|
|
44
|
-
var _server$httpServer;
|
|
45
|
-
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', () => {
|
|
46
|
-
const {
|
|
47
|
-
port,
|
|
48
|
-
host: hostConfig
|
|
49
|
-
} = server.config.server;
|
|
50
|
-
const host = typeof hostConfig === 'string' && hostConfig !== '0.0.0.0' ? hostConfig : 'localhost';
|
|
51
|
-
fetch(`http://${host}:${port}${devEntryPath}`).catch(e => {});
|
|
52
|
-
});
|
|
53
44
|
server.middlewares.use((req, res, next) => {
|
|
54
45
|
if (!fileName) {
|
|
55
46
|
next();
|
|
@@ -753,8 +744,13 @@ const HOST_AUTO_INIT_TAG = '__H_A_I__';
|
|
|
753
744
|
const hostAutoInitModule = new VirtualModule('hostAutoInit', HOST_AUTO_INIT_TAG);
|
|
754
745
|
function writeHostAutoInit() {
|
|
755
746
|
hostAutoInitModule.writeSync(`
|
|
756
|
-
|
|
757
|
-
|
|
747
|
+
const remoteEntryPromise = import("${REMOTE_ENTRY_ID}")
|
|
748
|
+
// __tla only serves as a hack for vite-plugin-top-level-await.
|
|
749
|
+
Promise.resolve(remoteEntryPromise)
|
|
750
|
+
.then(remoteEntry => {
|
|
751
|
+
return Promise.resolve(remoteEntry.__tla)
|
|
752
|
+
.then(remoteEntry.init).catch(remoteEntry.init)
|
|
753
|
+
})
|
|
758
754
|
`);
|
|
759
755
|
}
|
|
760
756
|
function getHostAutoInitImportId() {
|
|
@@ -1150,8 +1146,14 @@ function pluginProxyRemoteEntry () {
|
|
|
1150
1146
|
var _viteConfig$server, _viteConfig$server2;
|
|
1151
1147
|
const host = typeof ((_viteConfig$server = viteConfig.server) == null ? void 0 : _viteConfig$server.host) === 'string' && viteConfig.server.host !== '0.0.0.0' ? viteConfig.server.host : 'localhost';
|
|
1152
1148
|
return `
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1149
|
+
const origin = window ? window.origin : "//${host}:${(_viteConfig$server2 = viteConfig.server) == null ? void 0 : _viteConfig$server2.port}"
|
|
1150
|
+
const remoteEntryPromise = await import(origin + "${viteConfig.base + options.filename}")
|
|
1151
|
+
// __tla only serves as a hack for vite-plugin-top-level-await.
|
|
1152
|
+
Promise.resolve(remoteEntryPromise)
|
|
1153
|
+
.then(remoteEntry => {
|
|
1154
|
+
return Promise.resolve(remoteEntry.__tla)
|
|
1155
|
+
.then(remoteEntry.init).catch(remoteEntry.init)
|
|
1156
|
+
})
|
|
1155
1157
|
`;
|
|
1156
1158
|
}
|
|
1157
1159
|
return code;
|
|
@@ -1290,22 +1292,6 @@ function proxySharedModule(options) {
|
|
|
1290
1292
|
};
|
|
1291
1293
|
}));
|
|
1292
1294
|
}
|
|
1293
|
-
}, {
|
|
1294
|
-
name: 'watchLocalSharedImportMap',
|
|
1295
|
-
apply: 'serve',
|
|
1296
|
-
config(config) {
|
|
1297
|
-
config.optimizeDeps = defu(config.optimizeDeps, {
|
|
1298
|
-
exclude: [getLocalSharedImportMapPath()]
|
|
1299
|
-
});
|
|
1300
|
-
config.server = defu(config.server, {
|
|
1301
|
-
watch: {
|
|
1302
|
-
ignored: []
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
const watch = config.server.watch;
|
|
1306
|
-
watch.ignored = [].concat(watch.ignored);
|
|
1307
|
-
watch.ignored.push(`!**${getLocalSharedImportMapPath()}**`);
|
|
1308
|
-
}
|
|
1309
1295
|
}];
|
|
1310
1296
|
}
|
|
1311
1297
|
|
|
@@ -1387,6 +1373,11 @@ function federation(mfUserOptions) {
|
|
|
1387
1373
|
find: '@module-federation/runtime',
|
|
1388
1374
|
replacement: options.implementation
|
|
1389
1375
|
});
|
|
1376
|
+
config.build = defu(config.build || {}, {
|
|
1377
|
+
commonjsOptions: {
|
|
1378
|
+
strictRequires: 'auto'
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1390
1381
|
(_config$optimizeDeps = config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1391
1382
|
(_config$optimizeDeps2 = config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
|
|
1392
1383
|
(_config$optimizeDeps3 = config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
|
package/lib/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs'), require('pathe'), require('@rollup/pluginutils'), require('estree-walker'), require('magic-string')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs', 'pathe', '@rollup/pluginutils', 'estree-walker', 'magic-string'
|
|
4
|
-
(global = global || self, factory(global.vite = {}, global.fs, global.pathe, global.pluginutils, global.estreeWalker, global.magicString
|
|
5
|
-
})(this, (function (exports, fs, path, pluginutils, estreeWalker, MagicString
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('defu'), require('fs'), require('pathe'), require('@rollup/pluginutils'), require('estree-walker'), require('magic-string')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'defu', 'fs', 'pathe', '@rollup/pluginutils', 'estree-walker', 'magic-string'], factory) :
|
|
4
|
+
(global = global || self, factory(global.vite = {}, global.defu, global.fs, global.pathe, global.pluginutils, global.estreeWalker, global.magicString));
|
|
5
|
+
})(this, (function (exports, defu, fs, path, pluginutils, estreeWalker, MagicString) {
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
8
8
|
function _interopNamespace(e) {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
return n;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
var defu__default = /*#__PURE__*/_interopDefaultLegacy(defu);
|
|
26
27
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
27
28
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
28
29
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
@@ -63,14 +64,6 @@
|
|
|
63
64
|
devEntryPath = config.base + devEntryPath.replace(/\\\\?/g, '/').replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/^\//, '');
|
|
64
65
|
},
|
|
65
66
|
configureServer: function configureServer(server) {
|
|
66
|
-
var _server$httpServer;
|
|
67
|
-
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
68
|
-
var _server$config$server = server.config.server,
|
|
69
|
-
port = _server$config$server.port,
|
|
70
|
-
hostConfig = _server$config$server.host;
|
|
71
|
-
var host = typeof hostConfig === 'string' && hostConfig !== '0.0.0.0' ? hostConfig : 'localhost';
|
|
72
|
-
fetch("http://" + host + ":" + port + devEntryPath)["catch"](function (e) {});
|
|
73
|
-
});
|
|
74
67
|
server.middlewares.use(function (req, res, next) {
|
|
75
68
|
if (!fileName) {
|
|
76
69
|
next();
|
|
@@ -681,7 +674,7 @@
|
|
|
681
674
|
var HOST_AUTO_INIT_TAG = '__H_A_I__';
|
|
682
675
|
var hostAutoInitModule = new VirtualModule('hostAutoInit', HOST_AUTO_INIT_TAG);
|
|
683
676
|
function writeHostAutoInit() {
|
|
684
|
-
hostAutoInitModule.writeSync("\n
|
|
677
|
+
hostAutoInitModule.writeSync("\n const remoteEntryPromise = import(\"" + REMOTE_ENTRY_ID + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
685
678
|
}
|
|
686
679
|
function getHostAutoInitImportId() {
|
|
687
680
|
return hostAutoInitModule.getImportId();
|
|
@@ -1104,7 +1097,7 @@
|
|
|
1104
1097
|
if (_command === 'serve') {
|
|
1105
1098
|
var _viteConfig$server, _viteConfig$server2;
|
|
1106
1099
|
var host = typeof ((_viteConfig$server = viteConfig.server) == null ? void 0 : _viteConfig$server.host) === 'string' && viteConfig.server.host !== '0.0.0.0' ? viteConfig.server.host : 'localhost';
|
|
1107
|
-
return Promise.resolve("\n const
|
|
1100
|
+
return Promise.resolve("\n const origin = window ? window.origin : \"//" + host + ":" + ((_viteConfig$server2 = viteConfig.server) == null ? void 0 : _viteConfig$server2.port) + "\"\n const remoteEntryPromise = await import(origin + \"" + (viteConfig.base + options.filename) + "\")\n // __tla only serves as a hack for vite-plugin-top-level-await. \n Promise.resolve(remoteEntryPromise)\n .then(remoteEntry => {\n return Promise.resolve(remoteEntry.__tla)\n .then(remoteEntry.init).catch(remoteEntry.init)\n })\n ");
|
|
1108
1101
|
}
|
|
1109
1102
|
return Promise.resolve(code);
|
|
1110
1103
|
}
|
|
@@ -1258,22 +1251,6 @@
|
|
|
1258
1251
|
};
|
|
1259
1252
|
}));
|
|
1260
1253
|
}
|
|
1261
|
-
}, {
|
|
1262
|
-
name: 'watchLocalSharedImportMap',
|
|
1263
|
-
apply: 'serve',
|
|
1264
|
-
config: function config(_config3) {
|
|
1265
|
-
_config3.optimizeDeps = defu.defu(_config3.optimizeDeps, {
|
|
1266
|
-
exclude: [getLocalSharedImportMapPath()]
|
|
1267
|
-
});
|
|
1268
|
-
_config3.server = defu.defu(_config3.server, {
|
|
1269
|
-
watch: {
|
|
1270
|
-
ignored: []
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
var watch = _config3.server.watch;
|
|
1274
|
-
watch.ignored = [].concat(watch.ignored);
|
|
1275
|
-
watch.ignored.push("!**" + getLocalSharedImportMapPath() + "**");
|
|
1276
|
-
}
|
|
1277
1254
|
}];
|
|
1278
1255
|
}
|
|
1279
1256
|
|
|
@@ -1346,6 +1323,11 @@
|
|
|
1346
1323
|
find: '@module-federation/runtime',
|
|
1347
1324
|
replacement: options.implementation
|
|
1348
1325
|
});
|
|
1326
|
+
_config.build = defu__default["default"](_config.build || {}, {
|
|
1327
|
+
commonjsOptions: {
|
|
1328
|
+
strictRequires: 'auto'
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1349
1331
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1350
1332
|
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
|
|
1351
1333
|
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Vite plugin for Module Federation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -9,22 +9,6 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"lib/**/*"
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"prepare": "husky install",
|
|
14
|
-
"fmt": "prettier --write src",
|
|
15
|
-
"fmt.check": "prettier --check src",
|
|
16
|
-
"format": "pretty-quick",
|
|
17
|
-
"dev": "microbundle watch --no-sourcemap --compress=false",
|
|
18
|
-
"build": "rimraf lib && microbundle --no-sourcemap --compress=false",
|
|
19
|
-
"dev-rv": "pnpm -filter 'examples-rust-vite*' run dev",
|
|
20
|
-
"preview-rv": "pnpm -filter 'examples-rust-vite*' run preview",
|
|
21
|
-
"dev-vv": "pnpm -filter 'examples-vite-vite*' run dev",
|
|
22
|
-
"dev-nv": "pnpm -filter 'examples-nuxt-vite-host' -filter 'examples-vite-vite-remote' run dev",
|
|
23
|
-
"preview-vv": "pnpm -filter 'examples-vite-vite*' run preview",
|
|
24
|
-
"multi-example": "pnpm --filter \"multi-example-*\" --parallel run start",
|
|
25
|
-
"test": "vitest",
|
|
26
|
-
"e2e": "playwright test"
|
|
27
|
-
},
|
|
28
12
|
"repository": {
|
|
29
13
|
"type": "git",
|
|
30
14
|
"url": "git+https://github.com/module-federation/vite.git"
|
|
@@ -44,7 +28,6 @@
|
|
|
44
28
|
"url": "https://github.com/module-federation/vite/issues"
|
|
45
29
|
},
|
|
46
30
|
"homepage": "https://github.com/module-federation/vite#readme",
|
|
47
|
-
"packageManager": "pnpm@9.1.3",
|
|
48
31
|
"dependencies": {
|
|
49
32
|
"@module-federation/runtime": "^0.8.0",
|
|
50
33
|
"@rollup/pluginutils": "^5.1.0",
|
|
@@ -65,5 +48,20 @@
|
|
|
65
48
|
"vite": "^5.4.3",
|
|
66
49
|
"vitest": "^2.1.1",
|
|
67
50
|
"wait-on": "^8.0.1"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"fmt": "prettier --write src",
|
|
54
|
+
"fmt.check": "prettier --check src",
|
|
55
|
+
"format": "pretty-quick",
|
|
56
|
+
"dev": "microbundle watch --no-sourcemap --compress=false",
|
|
57
|
+
"build": "rimraf lib && microbundle --no-sourcemap --compress=false",
|
|
58
|
+
"dev-rv": "pnpm -filter 'examples-rust-vite*' run dev",
|
|
59
|
+
"preview-rv": "pnpm -filter 'examples-rust-vite*' run preview",
|
|
60
|
+
"dev-vv": "pnpm -filter 'examples-vite-vite*' run dev",
|
|
61
|
+
"dev-nv": "pnpm -filter 'examples-nuxt-vite-host' -filter 'examples-vite-vite-remote' run dev",
|
|
62
|
+
"preview-vv": "pnpm -filter 'examples-vite-vite*' run preview",
|
|
63
|
+
"multi-example": "pnpm --filter \"multi-example-*\" --parallel run start",
|
|
64
|
+
"test": "vitest",
|
|
65
|
+
"e2e": "playwright test"
|
|
68
66
|
}
|
|
69
|
-
}
|
|
67
|
+
}
|