@@ -626,6 +626,31 @@ function shouldPreferPackageLocalDistRuntimeArtifact(source: string): boolean {
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | |
| 629 | +function resolvePackageLocalDistRuntimeArtifact(params: { |
| 630 | +source: string; |
| 631 | +rootDir: string; |
| 632 | +}): string | null { |
| 633 | +const relativeSource = path.relative(params.rootDir, params.source); |
| 634 | +if ( |
| 635 | +!shouldPreferPackageLocalDistRuntimeArtifact(relativeSource) || |
| 636 | +relativeSource === "" || |
| 637 | +relativeSource.startsWith("..") || |
| 638 | +path.isAbsolute(relativeSource) |
| 639 | +) { |
| 640 | +return null; |
| 641 | +} |
| 642 | +const artifactRoot = path.join(params.rootDir, "dist"); |
| 643 | +for (const artifactRelativePath of listPackageLocalDistRuntimeArtifactRelativePaths( |
| 644 | +relativeSource, |
| 645 | +)) { |
| 646 | +const artifactSource = path.join(artifactRoot, artifactRelativePath); |
| 647 | +if (fs.existsSync(artifactSource)) { |
| 648 | +return safeRealpathOrResolve(artifactSource); |
| 649 | +} |
| 650 | +} |
| 651 | +return null; |
| 652 | +} |
| 653 | + |
629 | 654 | function resolvePreferredBuiltRuntimeArtifact(params: { |
630 | 655 | source: string; |
631 | 656 | rootDir: string; |
@@ -638,28 +663,16 @@ function resolvePreferredBuiltRuntimeArtifact(params: {
|
638 | 663 | return { source, rootDir }; |
639 | 664 | } |
640 | 665 | if (params.origin !== "bundled") { |
641 | | -const relativeSource = path.relative(rootDir, source); |
642 | | -if ( |
643 | | -shouldPreferPackageLocalDistRuntimeArtifact(relativeSource) && |
644 | | -relativeSource !== "" && |
645 | | -!relativeSource.startsWith("..") && |
646 | | -!path.isAbsolute(relativeSource) |
647 | | -) { |
648 | | -const artifactRoot = path.join(rootDir, "dist"); |
649 | | -for (const artifactRelativePath of listPackageLocalDistRuntimeArtifactRelativePaths( |
650 | | -relativeSource, |
651 | | -)) { |
652 | | -const artifactSource = path.join(artifactRoot, artifactRelativePath); |
653 | | -if (fs.existsSync(artifactSource)) { |
654 | | -return { |
655 | | -source: safeRealpathOrResolve(artifactSource), |
656 | | - rootDir, |
657 | | -}; |
658 | | -} |
659 | | -} |
| 666 | +const artifactSource = resolvePackageLocalDistRuntimeArtifact({ source, rootDir }); |
| 667 | +if (artifactSource) { |
| 668 | +return { source: artifactSource, rootDir }; |
660 | 669 | } |
661 | 670 | return { source, rootDir }; |
662 | 671 | } |
| 672 | +const packageLocalArtifactSource = resolvePackageLocalDistRuntimeArtifact({ source, rootDir }); |
| 673 | +if (packageLocalArtifactSource) { |
| 674 | +return { source: packageLocalArtifactSource, rootDir }; |
| 675 | +} |
663 | 676 | const extensionsDir = path.dirname(rootDir); |
664 | 677 | if (path.basename(extensionsDir) !== "extensions") { |
665 | 678 | return { source, rootDir }; |
|