@eggjs/core 7.0.2-beta.10 → 7.0.2-beta.12

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.
@@ -483,7 +483,7 @@ var EggLoader = class {
483
483
  getPluginPath(plugin) {
484
484
  if (plugin.path && !this.#isBundlePluginPathArtifact(plugin.path)) return plugin.path;
485
485
  if (plugin.package) assert(isValidatePackageName(plugin.package), `plugin ${plugin.name} invalid, use 'path' instead of package: "${plugin.package}"`);
486
- if (plugin.path && this.#isBundlePluginPathArtifact(plugin.path)) return this.#resolveBundlePluginPath(plugin);
486
+ if (this.#isBundleModeForThisApp() && (!plugin.path || this.#isBundlePluginPathArtifact(plugin.path))) return this.#resolveBundlePluginPath(plugin);
487
487
  return this.#resolvePluginPath(plugin);
488
488
  }
489
489
  /**
@@ -492,9 +492,17 @@ var EggLoader = class {
492
492
  * which does not contain the plugin's own files. Detect that case so the plugin is
493
493
  * re-resolved by package name instead.
494
494
  */
495
- #isBundlePluginPathArtifact(pluginPath) {
495
+ /**
496
+ * Whether an active bundle store belongs to THIS app. The store is shared via globalThis
497
+ * across @eggjs/core copies, so one registered for a different app must not reinterpret this
498
+ * app's plugin paths — mirror `ManifestStore.load()`'s `bundleStore.baseDir === baseDir` gate.
499
+ */
500
+ #isBundleModeForThisApp() {
496
501
  const bundleStore = ManifestStore.getBundleStore();
497
- if (!bundleStore || path.resolve(bundleStore.baseDir) !== path.resolve(this.options.baseDir)) return false;
502
+ return !!bundleStore && path.resolve(bundleStore.baseDir) === path.resolve(this.options.baseDir);
503
+ }
504
+ #isBundlePluginPathArtifact(pluginPath) {
505
+ if (!this.#isBundleModeForThisApp()) return false;
498
506
  return path.resolve(pluginPath) === path.resolve(this.options.baseDir);
499
507
  }
500
508
  /**
@@ -507,11 +515,18 @@ var EggLoader = class {
507
515
  const candidates = plugin.package ? [plugin.package] : plugin.name.includes("/") ? [plugin.name] : [plugin.name, `@eggjs/${plugin.name}`];
508
516
  let lastErr;
509
517
  for (const name$1 of candidates) try {
510
- const entry = utils_default.resolvePath(name$1, { paths: [...this.lookupDirs] });
511
- const realDir = path.dirname(entry);
518
+ let realDir;
519
+ try {
520
+ realDir = path.dirname(utils_default.resolvePath(name$1, { paths: [...this.lookupDirs] }));
521
+ } catch {
522
+ realDir = path.dirname(utils_default.resolvePath(`${name$1}/package.json`, { paths: [...this.lookupDirs] }));
523
+ }
512
524
  const segments = realDir.split(/[/\\]/);
513
525
  const nmIdx = segments.lastIndexOf("node_modules");
514
- if (nmIdx !== -1) return path.join(this.options.baseDir, ...segments.slice(nmIdx));
526
+ if (nmIdx !== -1) {
527
+ const rebased = path.join(this.options.baseDir, ...segments.slice(nmIdx));
528
+ if (fs.existsSync(rebased)) return rebased;
529
+ }
515
530
  return realDir;
516
531
  } catch (err) {
517
532
  lastErr = err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/core",
3
- "version": "7.0.2-beta.10",
3
+ "version": "7.0.2-beta.12",
4
4
  "description": "A core plugin framework based on @eggjs/koa",
5
5
  "keywords": [
6
6
  "egg",
@@ -42,13 +42,13 @@
42
42
  "ready-callback": "^4.0.0",
43
43
  "tsconfig-paths": "^4.2.0",
44
44
  "utility": "^2.5.0",
45
- "@eggjs/koa": "3.1.2-beta.10",
46
- "@eggjs/router": "4.0.2-beta.10",
47
- "@eggjs/path-matching": "3.0.2-beta.10",
48
- "@eggjs/loader-fs": "1.0.0-beta.10",
49
- "@eggjs/utils": "5.0.2-beta.10",
50
- "@eggjs/typings": "4.1.2-beta.10",
51
- "@eggjs/extend2": "5.0.2-beta.10"
45
+ "@eggjs/extend2": "5.0.2-beta.12",
46
+ "@eggjs/path-matching": "3.0.2-beta.12",
47
+ "@eggjs/loader-fs": "1.0.0-beta.12",
48
+ "@eggjs/router": "4.0.2-beta.12",
49
+ "@eggjs/typings": "4.1.2-beta.12",
50
+ "@eggjs/koa": "3.1.2-beta.12",
51
+ "@eggjs/utils": "5.0.2-beta.12"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/js-yaml": "^4.0.9",
@@ -60,9 +60,9 @@
60
60
  "mm": "^4.0.2",
61
61
  "typescript": "^5.9.3",
62
62
  "urllib": "^4.8.2",
63
- "@eggjs/mock": "7.0.2-beta.10",
64
- "@eggjs/supertest": "9.0.2-beta.10",
65
- "@eggjs/tsconfig": "3.1.2-beta.10"
63
+ "@eggjs/mock": "7.0.2-beta.12",
64
+ "@eggjs/tsconfig": "3.1.2-beta.12",
65
+ "@eggjs/supertest": "9.0.2-beta.12"
66
66
  },
67
67
  "engines": {
68
68
  "node": ">=22.18.0"