@module-federation/vite 1.2.1 → 1.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/lib/index.cjs +23 -1
- package/lib/index.esm.js +23 -1
- package/lib/index.modern.js +23 -1
- package/lib/index.umd.js +23 -1
- package/package.json +17 -19
package/lib/index.cjs
CHANGED
|
@@ -330,12 +330,34 @@ function removePathFromNpmPackage(packageString) {
|
|
|
330
330
|
// 返回匹配到的包名,如果没有匹配到则返回原字符串
|
|
331
331
|
return match ? match[0] : packageString;
|
|
332
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Tries to find the package.json's version of a shared package
|
|
335
|
+
* if `package.json` is not declared in `exports`
|
|
336
|
+
* @param {string} sharedName
|
|
337
|
+
* @returns {string | undefined}
|
|
338
|
+
*/
|
|
339
|
+
function searchPackageVersion(sharedName) {
|
|
340
|
+
try {
|
|
341
|
+
var sharedPath = require.resolve(sharedName);
|
|
342
|
+
var potentialPackageJsonDir = path__namespace.dirname(sharedPath);
|
|
343
|
+
var rootDir = path__namespace.parse(potentialPackageJsonDir).root;
|
|
344
|
+
while (path__namespace.parse(potentialPackageJsonDir).base !== 'node_modules' && potentialPackageJsonDir !== rootDir) {
|
|
345
|
+
var potentialPackageJson = path__namespace.join(potentialPackageJsonDir, 'package.json');
|
|
346
|
+
if (fs__namespace.existsSync(potentialPackageJson)) {
|
|
347
|
+
return require(potentialPackageJson).version;
|
|
348
|
+
}
|
|
349
|
+
potentialPackageJsonDir = path__namespace.dirname(potentialPackageJsonDir);
|
|
350
|
+
}
|
|
351
|
+
} catch (_) {}
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
333
354
|
function normalizeShareItem(key, shareItem) {
|
|
334
355
|
var version;
|
|
335
356
|
try {
|
|
336
357
|
version = require(path__namespace.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
337
358
|
} catch (e) {
|
|
338
|
-
|
|
359
|
+
version = searchPackageVersion(key);
|
|
360
|
+
if (!version) console.error(e);
|
|
339
361
|
}
|
|
340
362
|
if (typeof shareItem === 'string') {
|
|
341
363
|
return {
|
package/lib/index.esm.js
CHANGED
|
@@ -306,12 +306,34 @@ function removePathFromNpmPackage(packageString) {
|
|
|
306
306
|
// 返回匹配到的包名,如果没有匹配到则返回原字符串
|
|
307
307
|
return match ? match[0] : packageString;
|
|
308
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Tries to find the package.json's version of a shared package
|
|
311
|
+
* if `package.json` is not declared in `exports`
|
|
312
|
+
* @param {string} sharedName
|
|
313
|
+
* @returns {string | undefined}
|
|
314
|
+
*/
|
|
315
|
+
function searchPackageVersion(sharedName) {
|
|
316
|
+
try {
|
|
317
|
+
var sharedPath = require.resolve(sharedName);
|
|
318
|
+
var potentialPackageJsonDir = path.dirname(sharedPath);
|
|
319
|
+
var rootDir = path.parse(potentialPackageJsonDir).root;
|
|
320
|
+
while (path.parse(potentialPackageJsonDir).base !== 'node_modules' && potentialPackageJsonDir !== rootDir) {
|
|
321
|
+
var potentialPackageJson = path.join(potentialPackageJsonDir, 'package.json');
|
|
322
|
+
if (fs.existsSync(potentialPackageJson)) {
|
|
323
|
+
return require(potentialPackageJson).version;
|
|
324
|
+
}
|
|
325
|
+
potentialPackageJsonDir = path.dirname(potentialPackageJsonDir);
|
|
326
|
+
}
|
|
327
|
+
} catch (_) {}
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
309
330
|
function normalizeShareItem(key, shareItem) {
|
|
310
331
|
var version;
|
|
311
332
|
try {
|
|
312
333
|
version = require(path.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
313
334
|
} catch (e) {
|
|
314
|
-
|
|
335
|
+
version = searchPackageVersion(key);
|
|
336
|
+
if (!version) console.error(e);
|
|
315
337
|
}
|
|
316
338
|
if (typeof shareItem === 'string') {
|
|
317
339
|
return {
|
package/lib/index.modern.js
CHANGED
|
@@ -279,12 +279,34 @@ function removePathFromNpmPackage(packageString) {
|
|
|
279
279
|
// 返回匹配到的包名,如果没有匹配到则返回原字符串
|
|
280
280
|
return match ? match[0] : packageString;
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Tries to find the package.json's version of a shared package
|
|
284
|
+
* if `package.json` is not declared in `exports`
|
|
285
|
+
* @param {string} sharedName
|
|
286
|
+
* @returns {string | undefined}
|
|
287
|
+
*/
|
|
288
|
+
function searchPackageVersion(sharedName) {
|
|
289
|
+
try {
|
|
290
|
+
const sharedPath = require.resolve(sharedName);
|
|
291
|
+
let potentialPackageJsonDir = path.dirname(sharedPath);
|
|
292
|
+
const rootDir = path.parse(potentialPackageJsonDir).root;
|
|
293
|
+
while (path.parse(potentialPackageJsonDir).base !== 'node_modules' && potentialPackageJsonDir !== rootDir) {
|
|
294
|
+
const potentialPackageJson = path.join(potentialPackageJsonDir, 'package.json');
|
|
295
|
+
if (fs.existsSync(potentialPackageJson)) {
|
|
296
|
+
return require(potentialPackageJson).version;
|
|
297
|
+
}
|
|
298
|
+
potentialPackageJsonDir = path.dirname(potentialPackageJsonDir);
|
|
299
|
+
}
|
|
300
|
+
} catch (_) {}
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
282
303
|
function normalizeShareItem(key, shareItem) {
|
|
283
304
|
let version;
|
|
284
305
|
try {
|
|
285
306
|
version = require(path.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
286
307
|
} catch (e) {
|
|
287
|
-
|
|
308
|
+
version = searchPackageVersion(key);
|
|
309
|
+
if (!version) console.error(e);
|
|
288
310
|
}
|
|
289
311
|
if (typeof shareItem === 'string') {
|
|
290
312
|
return {
|
package/lib/index.umd.js
CHANGED
|
@@ -328,12 +328,34 @@
|
|
|
328
328
|
// 返回匹配到的包名,如果没有匹配到则返回原字符串
|
|
329
329
|
return match ? match[0] : packageString;
|
|
330
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Tries to find the package.json's version of a shared package
|
|
333
|
+
* if `package.json` is not declared in `exports`
|
|
334
|
+
* @param {string} sharedName
|
|
335
|
+
* @returns {string | undefined}
|
|
336
|
+
*/
|
|
337
|
+
function searchPackageVersion(sharedName) {
|
|
338
|
+
try {
|
|
339
|
+
var sharedPath = require.resolve(sharedName);
|
|
340
|
+
var potentialPackageJsonDir = path__namespace.dirname(sharedPath);
|
|
341
|
+
var rootDir = path__namespace.parse(potentialPackageJsonDir).root;
|
|
342
|
+
while (path__namespace.parse(potentialPackageJsonDir).base !== 'node_modules' && potentialPackageJsonDir !== rootDir) {
|
|
343
|
+
var potentialPackageJson = path__namespace.join(potentialPackageJsonDir, 'package.json');
|
|
344
|
+
if (fs__namespace.existsSync(potentialPackageJson)) {
|
|
345
|
+
return require(potentialPackageJson).version;
|
|
346
|
+
}
|
|
347
|
+
potentialPackageJsonDir = path__namespace.dirname(potentialPackageJsonDir);
|
|
348
|
+
}
|
|
349
|
+
} catch (_) {}
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
331
352
|
function normalizeShareItem(key, shareItem) {
|
|
332
353
|
var version;
|
|
333
354
|
try {
|
|
334
355
|
version = require(path__namespace.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
335
356
|
} catch (e) {
|
|
336
|
-
|
|
357
|
+
version = searchPackageVersion(key);
|
|
358
|
+
if (!version) console.error(e);
|
|
337
359
|
}
|
|
338
360
|
if (typeof shareItem === 'string') {
|
|
339
361
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/vite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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
|
+
}
|