extension-develop 4.1.17 → 4.1.18-canary.1789403792.e514b06c
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/dist/832~0.mjs +5 -3
- package/dist/840~0.mjs +773 -85
- package/dist/950~0.mjs +24 -1
- package/dist/lib/addon-lint.d.ts +71 -0
- package/dist/lib/merge-options.d.ts +2 -0
- package/dist/lib/messages.d.ts +5 -0
- package/dist/lib/optional-deps-resolver.d.ts +1 -0
- package/dist/rspack-config~0.mjs +3 -516
- package/dist/types.d.ts +7 -1
- package/package.json +2 -1
package/dist/950~0.mjs
CHANGED
|
@@ -89,6 +89,29 @@ function buildComplete(browser, distDisplayPath, totalBytes) {
|
|
|
89
89
|
function platformDocsUrl() {
|
|
90
90
|
return String(process.env.EXTENSION_DEV_DOCS_URL || '').trim().replace(/\/+$/, '');
|
|
91
91
|
}
|
|
92
|
+
function pluralize(count, noun) {
|
|
93
|
+
return `${count} ${noun}${1 === count ? '' : 's'}`;
|
|
94
|
+
}
|
|
95
|
+
function addonLintSummary(errorCount, warningCount, distDisplay) {
|
|
96
|
+
const parts = [];
|
|
97
|
+
if (errorCount > 0) parts.push(pluralize(errorCount, 'error'));
|
|
98
|
+
if (warningCount > 0) parts.push(pluralize(warningCount, 'warning'));
|
|
99
|
+
return `${getLoggingPrefix('warn')} Store check for addons.mozilla.org: addons-linter found ${parts.join(' and ')} in ${pintor.underline(distDisplay)}`;
|
|
100
|
+
}
|
|
101
|
+
function addonLintFinding(level, code, message, location) {
|
|
102
|
+
const glyph = getLoggingPrefix('error' === level ? 'warn' : 'info');
|
|
103
|
+
const where = location ? ` ${pintor.gray(`(${location})`)}` : '';
|
|
104
|
+
return `${glyph} AMO ${level} ${pintor.yellow(code)}: ${message}${where}`;
|
|
105
|
+
}
|
|
106
|
+
function addonLintMore(hiddenCount, distDisplay) {
|
|
107
|
+
return `${getLoggingPrefix('info')} ${pluralize(hiddenCount, 'more finding')} not shown. Run ${pintor.blue(`npx addons-linter ${distDisplay}`)} for the full report.`;
|
|
108
|
+
}
|
|
109
|
+
function addonLintNotInstalled(installHint) {
|
|
110
|
+
return `${getLoggingPrefix('info')} Skipped the addons.mozilla.org lint: addons-linter is not installed. Install it with: ${pintor.blue(installHint)} or pass ${pintor.blue('--no-addon-lint')} to silence this.`;
|
|
111
|
+
}
|
|
112
|
+
function addonLintFailed(reason) {
|
|
113
|
+
return `${getLoggingPrefix('debug')} addon-lint skipped=true reason="${reason}"`;
|
|
114
|
+
}
|
|
92
115
|
function buildShareHint() {
|
|
93
116
|
const docs = platformDocsUrl();
|
|
94
117
|
if (!docs) return '';
|
|
@@ -932,4 +955,4 @@ function actionsPath(projectPath, browser) {
|
|
|
932
955
|
function buildSummaryPath(projectPath, browser) {
|
|
933
956
|
return __rspack_external_node_path_806ed179.join(browserArtifactsDir(projectPath, browser), 'build-summary.json');
|
|
934
957
|
}
|
|
935
|
-
export { actionsPath, anotherDevSessionActive, asAbsolute, authorInstallNotice, browserArtifactsDir, browserDistDir, browserLaunchFailed, browserProfileRootDir, buildAssetsTree, buildCommandFailed, buildComplete, buildFailed, buildShareHint, buildSummaryPath, buildWarningsDetails, computePreviewOutputPath, configBrowserOrThrow, configLoadingError, controlPortFilePath, controlTokenPath, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, debugPreviewOutput, debugSplitChunksNarrowed, devCommandFailed, devtoolsEngineFor, downloadingText, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore, eventsPath, extensionLoadRecovered, extensionLoadStillRefused, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, invalidRemoteZip, isUsingExperimentalConfig, legacyControlPortFilePath, legacyControlTokenPath, localZipNotFound, logsPath, managedDependencyConflict, manifestInvalidJson, needsInstall, noCompanionExtensionsResolved, normalizeBrowser, notAZipArchive, packagingDistributionFiles, packagingSourceFiles, previewing, previewingCustomOutput, previewingSourceFallback, projectInstallFallbackToNpm, projectInstallScriptsDisabled, readyContractPath, resolveProjectStructureSync, sessionArtifactsRootDir, sessionStateDir, starting, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError, zipArtifactReady };
|
|
958
|
+
export { actionsPath, addonLintFailed, addonLintFinding, addonLintMore, addonLintNotInstalled, addonLintSummary, anotherDevSessionActive, asAbsolute, authorInstallNotice, browserArtifactsDir, browserDistDir, browserLaunchFailed, browserProfileRootDir, buildAssetsTree, buildCommandFailed, buildComplete, buildFailed, buildShareHint, buildSummaryPath, buildWarningsDetails, computePreviewOutputPath, configBrowserOrThrow, configLoadingError, controlPortFilePath, controlTokenPath, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, debugPreviewOutput, debugSplitChunksNarrowed, devCommandFailed, devtoolsEngineFor, downloadingText, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore, eventsPath, extensionLoadRecovered, extensionLoadStillRefused, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, invalidRemoteZip, isUsingExperimentalConfig, legacyControlPortFilePath, legacyControlTokenPath, localZipNotFound, logsPath, managedDependencyConflict, manifestInvalidJson, needsInstall, noCompanionExtensionsResolved, normalizeBrowser, notAZipArchive, packagingDistributionFiles, packagingSourceFiles, previewing, previewingCustomOutput, previewingSourceFallback, projectInstallFallbackToNpm, projectInstallScriptsDisabled, readyContractPath, resolveProjectStructureSync, sessionArtifactsRootDir, sessionStateDir, starting, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError, zipArtifactReady };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const ADDON_LINT_DEFAULT = true;
|
|
2
|
+
export declare const ADDON_LINT_TIMEOUT_MS = 10000;
|
|
3
|
+
export declare const ADDON_LINT_MAX_PRINTED = 20;
|
|
4
|
+
export declare const ADDON_LINT_PACKAGE = "addons-linter";
|
|
5
|
+
export interface AddonLintFinding {
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
file?: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface AddonLintOutput {
|
|
14
|
+
errors?: AddonLintFinding[];
|
|
15
|
+
warnings?: AddonLintFinding[];
|
|
16
|
+
notices?: AddonLintFinding[];
|
|
17
|
+
}
|
|
18
|
+
export type AddonLintLevel = 'error' | 'warning';
|
|
19
|
+
export interface AddonLintLine {
|
|
20
|
+
level: AddonLintLevel;
|
|
21
|
+
code: string;
|
|
22
|
+
message: string;
|
|
23
|
+
location: string;
|
|
24
|
+
}
|
|
25
|
+
export type AddonLintResult = {
|
|
26
|
+
status: 'skipped';
|
|
27
|
+
reason: 'disabled' | 'mode' | 'browser';
|
|
28
|
+
} | {
|
|
29
|
+
status: 'missing';
|
|
30
|
+
hint: string | null;
|
|
31
|
+
} | {
|
|
32
|
+
status: 'failed';
|
|
33
|
+
debugLine: string;
|
|
34
|
+
} | {
|
|
35
|
+
status: 'linted';
|
|
36
|
+
findings: number;
|
|
37
|
+
lines: string[];
|
|
38
|
+
};
|
|
39
|
+
type LinterModule = {
|
|
40
|
+
createInstance: (options: {
|
|
41
|
+
config: Record<string, unknown>;
|
|
42
|
+
runAsBinary: boolean;
|
|
43
|
+
}) => {
|
|
44
|
+
run: (deps?: Record<string, unknown>) => Promise<AddonLintOutput>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type LoadAddonLinter = (projectPath: string) => Promise<LinterModule>;
|
|
48
|
+
export interface RunAddonLintInput {
|
|
49
|
+
projectPath: string;
|
|
50
|
+
distPath: string;
|
|
51
|
+
distDisplay: string;
|
|
52
|
+
browser: string;
|
|
53
|
+
mode: 'development' | 'production' | 'none';
|
|
54
|
+
enabled?: boolean;
|
|
55
|
+
loadLinter?: LoadAddonLinter;
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
}
|
|
58
|
+
export declare function shouldRunAddonLint(input: {
|
|
59
|
+
browser: string;
|
|
60
|
+
mode: RunAddonLintInput['mode'];
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
}): Extract<AddonLintResult, {
|
|
63
|
+
status: 'skipped';
|
|
64
|
+
}> | null;
|
|
65
|
+
export declare function collectAddonLintLines(output: AddonLintOutput | null | undefined): AddonLintLine[];
|
|
66
|
+
export declare function formatAddonLintFindings(output: AddonLintOutput | null | undefined, distDisplay: string, maxPrinted?: number): {
|
|
67
|
+
findings: number;
|
|
68
|
+
lines: string[];
|
|
69
|
+
};
|
|
70
|
+
export declare function runAddonLint(input: RunAddonLintInput): Promise<AddonLintResult>;
|
|
71
|
+
export {};
|
|
@@ -18,6 +18,7 @@ export declare const BUILD_COMMAND_DEFAULTS: {
|
|
|
18
18
|
zip: boolean;
|
|
19
19
|
zipSource: boolean;
|
|
20
20
|
silent: boolean;
|
|
21
|
+
addonLint: boolean;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
24
|
* Stock defaults for the `extension start` / `extension preview` browser
|
|
@@ -37,6 +38,7 @@ export declare const SERVE_COMMAND_DEFAULTS: {
|
|
|
37
38
|
export declare const START_BUILD_DEFAULTS: {
|
|
38
39
|
polyfill: boolean;
|
|
39
40
|
silent: boolean;
|
|
41
|
+
addonLint: boolean;
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
42
44
|
* Array-valued option keys that concatenate across layers (browser config,
|
package/dist/lib/messages.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare function projectInstallScriptsDisabled(pmName: string): string;
|
|
|
19
19
|
export declare function anotherDevSessionActive(browser: string, pid: number, runId: string): string;
|
|
20
20
|
export declare function buildAssetsTree(stats: Stats | undefined): string;
|
|
21
21
|
export declare function buildComplete(browser: DevOptions['browser'], distDisplayPath: string, totalBytes?: number): string;
|
|
22
|
+
export declare function addonLintSummary(errorCount: number, warningCount: number, distDisplay: string): string;
|
|
23
|
+
export declare function addonLintFinding(level: 'error' | 'warning', code: string, message: string, location: string): string;
|
|
24
|
+
export declare function addonLintMore(hiddenCount: number, distDisplay: string): string;
|
|
25
|
+
export declare function addonLintNotInstalled(installHint: string): string;
|
|
26
|
+
export declare function addonLintFailed(reason: string): string;
|
|
22
27
|
export declare function buildShareHint(): string;
|
|
23
28
|
export declare function buildFailed(errorCount: number): string;
|
|
24
29
|
type LooseBuildWarning = string | null | undefined | {
|
package/dist/rspack-config~0.mjs
CHANGED
|
@@ -14,10 +14,10 @@ import node_path from "node:path";
|
|
|
14
14
|
import { utils_isUrl, getBaseNode, parseHtml, manifestJsonOutputTarget, getExtname, getBaseHref, isResourceUnderDirs, getAssetsFromHtml, normalizeManifestOutputPath, manifestPageOutputTarget, canonicalizeDir, iconOutputPath, isFromIncludeList, htmlStaticAssetOutputName, isSpecialScheme, resolveStaticAttributeName, getHtmlPageDeclaredAssetPath, themeImageOutputPath, themeIconOutputPath, applyRewrittenStaticUrl, toResourceKey, cleanLeading, getFilePath, resolveAbsoluteFsPath, cleanAssetUrl, isHttpLike, resolveHtmlRefPath } from "./938~0.mjs";
|
|
15
15
|
import { prefix as messaging_prefix, isDebug } from "./852~0.mjs";
|
|
16
16
|
import { isChromiumBasedBrowser, CHROMIUM_FAMILY_ALIASES, GECKO_FAMILY_ALIASES, isWebkitBasedBrowser, isGeckoBasedBrowser } from "./331~0.mjs";
|
|
17
|
-
import { isUsingTypeScript,
|
|
18
|
-
import {
|
|
17
|
+
import { isUsingTypeScript, jsFrameworksIntegrationsEnabled, classifyEntrySurface, ensureTypeScriptConfig, ensureOptionalContractModuleLoaded, resolveDevelopInstallRoot, isUsingCustomLoader, getUserTypeScriptConfigFile, loadOptionalContractModuleWithoutInstall, isUsingIntegration as messages_isUsingIntegration, resolveOptionalContractPackageWithoutInstall, jsFrameworksHmrSummary, humanLine, ensureOptionalContractPackageResolved, jsFrameworksConfigsDetected, recordZipArtifact, hasDependency, resolveDevelopDistFile, defaultSplitChunks } from "./840~0.mjs";
|
|
18
|
+
import { bundlerFatalError, bundlerRecompiling, browserRunnerDisabled, PlaywrightPlugin, publicFolderShadowed, resolveCompanionExtensionDirs, specialFoldersSetupSummary, noEntrypointsDetected, serverRestartRequiredFromSpecialFolderMessageOnly, specialFolderChangeDetected, spacerLine, messages_ready, getPreloadedEnvKeys, publicMustBeAtProjectRoot, computeExtensionsToLoad, getSpecialFoldersDataForCompiler } from "./832~0.mjs";
|
|
19
19
|
import { renderStatsBlocks, makeSanitizedConsole } from "./stats-handler~0.mjs";
|
|
20
|
-
import { stripBom,
|
|
20
|
+
import { stripBom, findNearestProjectManifestSync, PROJECT_MANIFEST_FILENAMES, parseJsonSafe, readProjectDependencies } from "./731~0.mjs";
|
|
21
21
|
import { EXTENSIONJS_CONTENT_SCRIPT_LAYER, getCanonicalContentScriptEntryName, parseCanonicalContentScriptAsset, CONTENT_SCRIPT_CSS_PROBE_MARKER_PREFIX, createContentScriptCssProbeMarkerPattern, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName, isCanonicalContentScriptAsset } from "./640~0.mjs";
|
|
22
22
|
import { getURLDependencyMissing, entrySplitAcrossInitialFiles, isStaticThemeSource, fetchedFileDependencyMissing, isStaticTheme, importScriptsDependencyMissing, filterKeysForThisBrowser, injectedCompiledSourceLiteral, injectedFileDependencyMissing, staticImportDependencyMissing, runtimeSetSurfaceDependencyMissing } from "./672~0.mjs";
|
|
23
23
|
import { packagingSourceFiles, debugBrowser, debugExtensionsToLoad, treeWithSourceFiles, debugOutputPath, manifestInvalidJson, getDirs, asAbsolute, treeWithDistFilesBrowser, packagingDistributionFiles, treeWithSourceAndDistFiles, toPosixPath as paths_toPosixPath, debugContextPath, noCompanionExtensionsResolved } from "./950~0.mjs";
|
|
@@ -1558,519 +1558,6 @@ class CompilationPlugin {
|
|
|
1558
1558
|
if ('build' !== this.command && 'start' !== this.command) setupCompilerDoneDiagnostics(compiler, this.port);
|
|
1559
1559
|
}
|
|
1560
1560
|
}
|
|
1561
|
-
const BUNDLED_DEPENDENCY_VERSIONS = {
|
|
1562
|
-
...package_namespaceObject.El || {}
|
|
1563
|
-
};
|
|
1564
|
-
function optional_deps_contracts_spec(packageId) {
|
|
1565
|
-
const version = BUNDLED_DEPENDENCY_VERSIONS[packageId];
|
|
1566
|
-
return version ? `${packageId}@${version}` : packageId;
|
|
1567
|
-
}
|
|
1568
|
-
function specs(packageIds) {
|
|
1569
|
-
return packageIds.map(optional_deps_contracts_spec);
|
|
1570
|
-
}
|
|
1571
|
-
function installRootRules(packageIds) {
|
|
1572
|
-
return packageIds.map((packageId)=>({
|
|
1573
|
-
type: 'install-root',
|
|
1574
|
-
packageId
|
|
1575
|
-
}));
|
|
1576
|
-
}
|
|
1577
|
-
function defineContract(contract) {
|
|
1578
|
-
return contract;
|
|
1579
|
-
}
|
|
1580
|
-
const OPTIONAL_DEPENDENCY_CONTRACTS = {
|
|
1581
|
-
'react-refresh': defineContract({
|
|
1582
|
-
id: 'react-refresh',
|
|
1583
|
-
integration: 'React',
|
|
1584
|
-
installPackages: specs([
|
|
1585
|
-
'react-refresh',
|
|
1586
|
-
'@rspack/plugin-react-refresh'
|
|
1587
|
-
]),
|
|
1588
|
-
verificationRules: [
|
|
1589
|
-
...installRootRules([
|
|
1590
|
-
'react-refresh',
|
|
1591
|
-
'@rspack/plugin-react-refresh'
|
|
1592
|
-
]),
|
|
1593
|
-
{
|
|
1594
|
-
type: 'module-context-resolve',
|
|
1595
|
-
fromPackage: '@rspack/plugin-react-refresh',
|
|
1596
|
-
packageId: 'react-refresh'
|
|
1597
|
-
}
|
|
1598
|
-
]
|
|
1599
|
-
}),
|
|
1600
|
-
'preact-refresh': defineContract({
|
|
1601
|
-
id: 'preact-refresh',
|
|
1602
|
-
integration: 'Preact',
|
|
1603
|
-
installPackages: specs([
|
|
1604
|
-
'@prefresh/core',
|
|
1605
|
-
'@prefresh/utils',
|
|
1606
|
-
'@rspack/plugin-preact-refresh',
|
|
1607
|
-
'preact'
|
|
1608
|
-
]),
|
|
1609
|
-
verificationRules: [
|
|
1610
|
-
...installRootRules([
|
|
1611
|
-
'@prefresh/core',
|
|
1612
|
-
'@prefresh/utils',
|
|
1613
|
-
'@rspack/plugin-preact-refresh',
|
|
1614
|
-
'preact'
|
|
1615
|
-
]),
|
|
1616
|
-
{
|
|
1617
|
-
type: 'module-context-resolve',
|
|
1618
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
1619
|
-
packageId: '@prefresh/core'
|
|
1620
|
-
},
|
|
1621
|
-
{
|
|
1622
|
-
type: 'module-context-resolve',
|
|
1623
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
1624
|
-
packageId: '@prefresh/utils'
|
|
1625
|
-
},
|
|
1626
|
-
{
|
|
1627
|
-
type: 'module-context-resolve',
|
|
1628
|
-
fromPackage: '@rspack/plugin-preact-refresh',
|
|
1629
|
-
packageId: 'preact'
|
|
1630
|
-
}
|
|
1631
|
-
]
|
|
1632
|
-
}),
|
|
1633
|
-
vue: defineContract({
|
|
1634
|
-
id: 'vue',
|
|
1635
|
-
integration: 'Vue',
|
|
1636
|
-
installPackages: specs([
|
|
1637
|
-
'vue-loader',
|
|
1638
|
-
'@vue/compiler-sfc',
|
|
1639
|
-
'vue'
|
|
1640
|
-
]),
|
|
1641
|
-
verificationRules: [
|
|
1642
|
-
...installRootRules([
|
|
1643
|
-
'vue-loader',
|
|
1644
|
-
'@vue/compiler-sfc',
|
|
1645
|
-
'vue'
|
|
1646
|
-
]),
|
|
1647
|
-
{
|
|
1648
|
-
type: 'module-context-load',
|
|
1649
|
-
fromPackage: 'vue-loader',
|
|
1650
|
-
packageId: '@vue/compiler-sfc'
|
|
1651
|
-
}
|
|
1652
|
-
]
|
|
1653
|
-
}),
|
|
1654
|
-
svelte: defineContract({
|
|
1655
|
-
id: 'svelte',
|
|
1656
|
-
integration: 'Svelte',
|
|
1657
|
-
installPackages: specs([
|
|
1658
|
-
'svelte-loader'
|
|
1659
|
-
]),
|
|
1660
|
-
verificationRules: installRootRules([
|
|
1661
|
-
'svelte-loader'
|
|
1662
|
-
])
|
|
1663
|
-
}),
|
|
1664
|
-
less: defineContract({
|
|
1665
|
-
id: 'less',
|
|
1666
|
-
integration: 'LESS',
|
|
1667
|
-
installPackages: specs([
|
|
1668
|
-
'less',
|
|
1669
|
-
'less-loader'
|
|
1670
|
-
]),
|
|
1671
|
-
verificationRules: installRootRules([
|
|
1672
|
-
'less',
|
|
1673
|
-
'less-loader'
|
|
1674
|
-
])
|
|
1675
|
-
}),
|
|
1676
|
-
postcss: defineContract({
|
|
1677
|
-
id: 'postcss',
|
|
1678
|
-
integration: 'PostCSS',
|
|
1679
|
-
installPackages: specs([
|
|
1680
|
-
'postcss',
|
|
1681
|
-
'postcss-loader'
|
|
1682
|
-
]),
|
|
1683
|
-
verificationRules: installRootRules([
|
|
1684
|
-
'postcss',
|
|
1685
|
-
'postcss-loader'
|
|
1686
|
-
])
|
|
1687
|
-
}),
|
|
1688
|
-
sass: defineContract({
|
|
1689
|
-
id: 'sass',
|
|
1690
|
-
integration: 'SASS',
|
|
1691
|
-
installPackages: specs([
|
|
1692
|
-
'postcss-loader',
|
|
1693
|
-
'postcss-scss',
|
|
1694
|
-
'postcss-preset-env',
|
|
1695
|
-
'sass-loader'
|
|
1696
|
-
]),
|
|
1697
|
-
verificationRules: installRootRules([
|
|
1698
|
-
'postcss-loader',
|
|
1699
|
-
'postcss-scss',
|
|
1700
|
-
'postcss-preset-env',
|
|
1701
|
-
'sass-loader'
|
|
1702
|
-
])
|
|
1703
|
-
})
|
|
1704
|
-
};
|
|
1705
|
-
function getOptionalDependencyContract(contractId) {
|
|
1706
|
-
const contract = OPTIONAL_DEPENDENCY_CONTRACTS[contractId];
|
|
1707
|
-
if (!contract) throw new Error(`Unknown optional dependency contract: ${contractId}`);
|
|
1708
|
-
return contract;
|
|
1709
|
-
}
|
|
1710
|
-
function debugSwallowed(step, error) {
|
|
1711
|
-
if (!isVerboseMode()) return;
|
|
1712
|
-
console.log(`${messaging_prefix('debug')} optional-deps ${step}: ${String(error?.message || error)}`);
|
|
1713
|
-
}
|
|
1714
|
-
function isVerboseMode() {
|
|
1715
|
-
return '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
|
|
1716
|
-
}
|
|
1717
|
-
function installVerbForPackageManager(name) {
|
|
1718
|
-
if ('npm' === name) return 'install -D';
|
|
1719
|
-
if ('deno' === name) return 'add --dev';
|
|
1720
|
-
return 'add -D';
|
|
1721
|
-
}
|
|
1722
|
-
function formatInstallHint(projectPath, packageSpecs) {
|
|
1723
|
-
const { name } = resolvePackageManager({
|
|
1724
|
-
cwd: projectPath
|
|
1725
|
-
});
|
|
1726
|
-
const verb = installVerbForPackageManager(name);
|
|
1727
|
-
return `${name} ${verb} ${packageSpecs.join(' ')}`;
|
|
1728
|
-
}
|
|
1729
|
-
function formatResolverError(args) {
|
|
1730
|
-
const hint = formatInstallHint(args.projectPath, args.installSpecs);
|
|
1731
|
-
const readableLine = `[${args.integration}] ${args.headline} Install it with: ${hint}`;
|
|
1732
|
-
if (!isVerboseMode()) return readableLine;
|
|
1733
|
-
return `${readableLine}\n${JSON.stringify(args.diagnostics, null, 2)}`;
|
|
1734
|
-
}
|
|
1735
|
-
function toInstallRootContract(integration, contractId, installDependencies, verifyPackageIds) {
|
|
1736
|
-
return {
|
|
1737
|
-
id: contractId,
|
|
1738
|
-
integration,
|
|
1739
|
-
installPackages: installDependencies,
|
|
1740
|
-
verificationRules: verifyPackageIds.map((packageId)=>({
|
|
1741
|
-
type: 'install-root',
|
|
1742
|
-
packageId
|
|
1743
|
-
}))
|
|
1744
|
-
};
|
|
1745
|
-
}
|
|
1746
|
-
function getVerificationContract(input) {
|
|
1747
|
-
if (input.contract) return input.contract;
|
|
1748
|
-
const installDependencies = input.installDependencies || [
|
|
1749
|
-
input.dependencyId
|
|
1750
|
-
];
|
|
1751
|
-
const verifyPackageIds = input.verifyPackageIds || installDependencies;
|
|
1752
|
-
return toInstallRootContract(input.integration, input.integration, installDependencies, verifyPackageIds);
|
|
1753
|
-
}
|
|
1754
|
-
function getResolutionBases(projectPath) {
|
|
1755
|
-
const extensionRoot = resolveDevelopInstallRoot();
|
|
1756
|
-
const bases = [
|
|
1757
|
-
projectPath,
|
|
1758
|
-
extensionRoot || void 0,
|
|
1759
|
-
process.cwd()
|
|
1760
|
-
].filter(Boolean);
|
|
1761
|
-
if (extensionRoot?.includes('.pnpm')) bases.push(__rspack_external_node_path_806ed179.join(extensionRoot, '..', '..'));
|
|
1762
|
-
return Array.from(new Set(bases));
|
|
1763
|
-
}
|
|
1764
|
-
function optional_deps_resolver_packageJsonPath(basePath) {
|
|
1765
|
-
return __rspack_external_node_path_806ed179.join(basePath, 'package.json');
|
|
1766
|
-
}
|
|
1767
|
-
function tryResolveWithBase(dependencyId, basePath) {
|
|
1768
|
-
try {
|
|
1769
|
-
const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
|
|
1770
|
-
return req.resolve(dependencyId);
|
|
1771
|
-
} catch (error) {
|
|
1772
|
-
debugSwallowed(`resolve ${dependencyId} from ${basePath}`, error);
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
function resolveDependency(dependencyId, projectPath) {
|
|
1777
|
-
const bases = getResolutionBases(projectPath);
|
|
1778
|
-
for (const basePath of bases){
|
|
1779
|
-
const resolvedPath = tryResolveWithBase(dependencyId, basePath);
|
|
1780
|
-
if (resolvedPath) return {
|
|
1781
|
-
resolvedPath,
|
|
1782
|
-
basePath
|
|
1783
|
-
};
|
|
1784
|
-
}
|
|
1785
|
-
try {
|
|
1786
|
-
const resolvedPath = require.resolve(dependencyId, {
|
|
1787
|
-
paths: bases
|
|
1788
|
-
});
|
|
1789
|
-
return {
|
|
1790
|
-
resolvedPath,
|
|
1791
|
-
basePath: projectPath
|
|
1792
|
-
};
|
|
1793
|
-
} catch (error) {
|
|
1794
|
-
debugSwallowed(`resolve ${dependencyId} from the project bases`, error);
|
|
1795
|
-
return;
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
function resolveFromKnownLocations(dependencyId, projectPath) {
|
|
1799
|
-
const direct = resolveDependency(dependencyId, projectPath)?.resolvedPath;
|
|
1800
|
-
if (direct) return direct;
|
|
1801
|
-
if (declaresDependency(projectPath, dependencyId)) return projectPath;
|
|
1802
|
-
}
|
|
1803
|
-
function declaresDependency(projectPath, dependencyId) {
|
|
1804
|
-
try {
|
|
1805
|
-
return hasProjectDependency(projectPath, dependencyId);
|
|
1806
|
-
} catch (error) {
|
|
1807
|
-
debugSwallowed(`read the project manifest for ${dependencyId}`, error);
|
|
1808
|
-
return false;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
function dedupeFailures(packageIds) {
|
|
1812
|
-
return Array.from(new Set(packageIds));
|
|
1813
|
-
}
|
|
1814
|
-
function resolveRealPathSafe(targetPath) {
|
|
1815
|
-
try {
|
|
1816
|
-
return __rspack_external_node_fs_1b05aee1.realpathSync(targetPath);
|
|
1817
|
-
} catch (error) {
|
|
1818
|
-
debugSwallowed(`realpath ${targetPath}`, error);
|
|
1819
|
-
return __rspack_external_node_path_806ed179.resolve(targetPath);
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
function findOwningPackageDir(resolvedPath) {
|
|
1823
|
-
let currentPath = __rspack_external_node_path_806ed179.dirname(resolvedPath);
|
|
1824
|
-
for(let depth = 0; depth < 8; depth++){
|
|
1825
|
-
const packageJson = __rspack_external_node_path_806ed179.join(currentPath, 'package.json');
|
|
1826
|
-
if (__rspack_external_node_fs_1b05aee1.existsSync(packageJson)) return currentPath;
|
|
1827
|
-
const parent = __rspack_external_node_path_806ed179.dirname(currentPath);
|
|
1828
|
-
if (parent === currentPath) break;
|
|
1829
|
-
currentPath = parent;
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
function isSameInstalledPackage(resolvedPath, expectedInstalledPath) {
|
|
1833
|
-
const resolvedPackageDir = findOwningPackageDir(resolvedPath);
|
|
1834
|
-
const expectedPackageDir = findOwningPackageDir(expectedInstalledPath);
|
|
1835
|
-
if (resolvedPackageDir && expectedPackageDir) return resolveRealPathSafe(resolvedPackageDir) === resolveRealPathSafe(expectedPackageDir);
|
|
1836
|
-
return resolveRealPathSafe(resolvedPath) === resolveRealPathSafe(expectedInstalledPath);
|
|
1837
|
-
}
|
|
1838
|
-
function evaluateModuleContextRule(rule, fromPackagePath, options) {
|
|
1839
|
-
try {
|
|
1840
|
-
const req = createRequire(fromPackagePath);
|
|
1841
|
-
const resolvedPeer = req.resolve(rule.packageId);
|
|
1842
|
-
if (options?.expectedInstalledPath && !isSameInstalledPackage(resolvedPeer, options.expectedInstalledPath)) return rule.packageId;
|
|
1843
|
-
if ('module-context-load' === rule.type) req(rule.packageId);
|
|
1844
|
-
return;
|
|
1845
|
-
} catch (error) {
|
|
1846
|
-
debugSwallowed(`verify ${rule.packageId}`, error);
|
|
1847
|
-
return rule.packageId;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
function getContractVerificationFailuresFromKnownLocations(contract, projectPath) {
|
|
1851
|
-
const resolvedByPackage = new Map();
|
|
1852
|
-
const resolvePackage = (packageId)=>{
|
|
1853
|
-
if (!resolvedByPackage.has(packageId)) resolvedByPackage.set(packageId, resolveFromKnownLocations(packageId, projectPath));
|
|
1854
|
-
return resolvedByPackage.get(packageId);
|
|
1855
|
-
};
|
|
1856
|
-
const failures = [];
|
|
1857
|
-
for (const rule of contract.verificationRules){
|
|
1858
|
-
if ('install-root' === rule.type) {
|
|
1859
|
-
if (!resolvePackage(rule.packageId)) failures.push(rule.packageId);
|
|
1860
|
-
continue;
|
|
1861
|
-
}
|
|
1862
|
-
const fromPackagePath = resolvePackage(rule.fromPackage);
|
|
1863
|
-
if (!fromPackagePath) {
|
|
1864
|
-
failures.push(rule.fromPackage);
|
|
1865
|
-
continue;
|
|
1866
|
-
}
|
|
1867
|
-
const failure = evaluateModuleContextRule(rule, fromPackagePath);
|
|
1868
|
-
if (!(failure && declaresDependency(projectPath, failure))) {
|
|
1869
|
-
if (failure) failures.push(failure);
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
return dedupeFailures(failures);
|
|
1873
|
-
}
|
|
1874
|
-
function buildDiagnostics(input) {
|
|
1875
|
-
const bases = getResolutionBases(input.projectPath);
|
|
1876
|
-
return {
|
|
1877
|
-
contractId: input.contract?.id || null,
|
|
1878
|
-
integration: input.integration,
|
|
1879
|
-
dependencyId: input.dependencyId,
|
|
1880
|
-
projectPath: input.projectPath,
|
|
1881
|
-
installDependencies: input.installDependencies,
|
|
1882
|
-
verifyPackageIds: input.verifyPackageIds,
|
|
1883
|
-
resolutionBases: bases
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
async function ensureOptionalPackageResolved(input) {
|
|
1887
|
-
const contract = getVerificationContract(input);
|
|
1888
|
-
const missing = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
|
|
1889
|
-
const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
|
|
1890
|
-
if (resolved && 0 === missing.length) return resolved;
|
|
1891
|
-
const diagnostics = buildDiagnostics({
|
|
1892
|
-
integration: input.integration,
|
|
1893
|
-
dependencyId: input.dependencyId,
|
|
1894
|
-
projectPath: input.projectPath,
|
|
1895
|
-
contract,
|
|
1896
|
-
installDependencies: contract.installPackages,
|
|
1897
|
-
verifyPackageIds: contract.installPackages
|
|
1898
|
-
});
|
|
1899
|
-
const headline = `${input.dependencyId} could not be resolved.` + (missing.length > 0 ? ` Missing or invalid packages: ${missing.join(', ')}.` : '');
|
|
1900
|
-
throw new Error(formatResolverError({
|
|
1901
|
-
integration: input.integration,
|
|
1902
|
-
dependencyId: input.dependencyId,
|
|
1903
|
-
headline,
|
|
1904
|
-
installSpecs: missing.length > 0 ? missing : contract.installPackages,
|
|
1905
|
-
projectPath: input.projectPath,
|
|
1906
|
-
diagnostics: {
|
|
1907
|
-
...diagnostics,
|
|
1908
|
-
missing
|
|
1909
|
-
}
|
|
1910
|
-
}));
|
|
1911
|
-
}
|
|
1912
|
-
function resolveOptionalPackageWithoutInstall(input) {
|
|
1913
|
-
const contract = getVerificationContract(input);
|
|
1914
|
-
const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
|
|
1915
|
-
const missingPeerDeps = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
|
|
1916
|
-
if (resolved && 0 === missingPeerDeps.length) return resolved;
|
|
1917
|
-
const diagnostics = buildDiagnostics({
|
|
1918
|
-
integration: input.integration,
|
|
1919
|
-
dependencyId: input.dependencyId,
|
|
1920
|
-
projectPath: input.projectPath,
|
|
1921
|
-
contract,
|
|
1922
|
-
installDependencies: contract.installPackages,
|
|
1923
|
-
verifyPackageIds: contract.installPackages
|
|
1924
|
-
});
|
|
1925
|
-
throw new Error(formatResolverError({
|
|
1926
|
-
integration: input.integration,
|
|
1927
|
-
dependencyId: input.dependencyId,
|
|
1928
|
-
headline: `${input.dependencyId} could not be resolved from the project or extension-develop.`,
|
|
1929
|
-
installSpecs: missingPeerDeps.length > 0 ? missingPeerDeps : contract.installPackages,
|
|
1930
|
-
projectPath: input.projectPath,
|
|
1931
|
-
diagnostics: {
|
|
1932
|
-
...diagnostics,
|
|
1933
|
-
missingPeerDeps,
|
|
1934
|
-
expectation: 'Run optional dependency preflight or reinstall extension-develop.'
|
|
1935
|
-
}
|
|
1936
|
-
}));
|
|
1937
|
-
}
|
|
1938
|
-
async function ensureOptionalModuleLoaded(input) {
|
|
1939
|
-
const resolvedPath = await ensureOptionalPackageResolved(input);
|
|
1940
|
-
const candidateBases = getResolutionBases(input.projectPath);
|
|
1941
|
-
let loaded;
|
|
1942
|
-
let didLoad = false;
|
|
1943
|
-
let lastLoadError;
|
|
1944
|
-
for (const basePath of candidateBases){
|
|
1945
|
-
const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
|
|
1946
|
-
const candidateModuleIds = [
|
|
1947
|
-
input.dependencyId,
|
|
1948
|
-
resolvedPath
|
|
1949
|
-
];
|
|
1950
|
-
for (const candidateModuleId of candidateModuleIds)try {
|
|
1951
|
-
loaded = req(candidateModuleId);
|
|
1952
|
-
didLoad = true;
|
|
1953
|
-
break;
|
|
1954
|
-
} catch (error) {
|
|
1955
|
-
lastLoadError = error;
|
|
1956
|
-
}
|
|
1957
|
-
if (didLoad) break;
|
|
1958
|
-
}
|
|
1959
|
-
if (!didLoad) try {
|
|
1960
|
-
loaded = require(resolvedPath);
|
|
1961
|
-
didLoad = true;
|
|
1962
|
-
} catch (directRequireError) {
|
|
1963
|
-
lastLoadError = directRequireError;
|
|
1964
|
-
}
|
|
1965
|
-
if (!didLoad) {
|
|
1966
|
-
const diagnostics = {
|
|
1967
|
-
...buildDiagnostics({
|
|
1968
|
-
integration: input.integration,
|
|
1969
|
-
dependencyId: input.dependencyId,
|
|
1970
|
-
projectPath: input.projectPath,
|
|
1971
|
-
installDependencies: input.installDependencies || [
|
|
1972
|
-
input.dependencyId
|
|
1973
|
-
],
|
|
1974
|
-
verifyPackageIds: input.verifyPackageIds || input.installDependencies || [
|
|
1975
|
-
input.dependencyId
|
|
1976
|
-
]
|
|
1977
|
-
}),
|
|
1978
|
-
resolvedPath,
|
|
1979
|
-
loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
|
|
1980
|
-
};
|
|
1981
|
-
throw new Error(formatResolverError({
|
|
1982
|
-
integration: input.integration,
|
|
1983
|
-
dependencyId: input.dependencyId,
|
|
1984
|
-
headline: `${input.dependencyId} could not be loaded after it resolved.`,
|
|
1985
|
-
installSpecs: input.installDependencies || [
|
|
1986
|
-
input.dependencyId
|
|
1987
|
-
],
|
|
1988
|
-
projectPath: input.projectPath,
|
|
1989
|
-
diagnostics
|
|
1990
|
-
}));
|
|
1991
|
-
}
|
|
1992
|
-
return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
|
|
1993
|
-
}
|
|
1994
|
-
function loadOptionalModuleWithoutInstall(input) {
|
|
1995
|
-
const resolvedPath = resolveOptionalPackageWithoutInstall(input);
|
|
1996
|
-
const candidateBases = getResolutionBases(input.projectPath);
|
|
1997
|
-
let loaded;
|
|
1998
|
-
let didLoad = false;
|
|
1999
|
-
let lastLoadError;
|
|
2000
|
-
for (const basePath of candidateBases){
|
|
2001
|
-
const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
|
|
2002
|
-
const candidateModuleIds = [
|
|
2003
|
-
input.dependencyId,
|
|
2004
|
-
resolvedPath
|
|
2005
|
-
];
|
|
2006
|
-
for (const candidateModuleId of candidateModuleIds)try {
|
|
2007
|
-
loaded = req(candidateModuleId);
|
|
2008
|
-
didLoad = true;
|
|
2009
|
-
break;
|
|
2010
|
-
} catch (error) {
|
|
2011
|
-
lastLoadError = error;
|
|
2012
|
-
}
|
|
2013
|
-
if (didLoad) break;
|
|
2014
|
-
}
|
|
2015
|
-
if (!didLoad) try {
|
|
2016
|
-
loaded = require(resolvedPath);
|
|
2017
|
-
didLoad = true;
|
|
2018
|
-
} catch (directRequireError) {
|
|
2019
|
-
lastLoadError = directRequireError;
|
|
2020
|
-
}
|
|
2021
|
-
if (!didLoad) throw new Error(formatResolverError({
|
|
2022
|
-
integration: input.integration,
|
|
2023
|
-
dependencyId: input.dependencyId,
|
|
2024
|
-
headline: `${input.dependencyId} could not be loaded after resolving.`,
|
|
2025
|
-
installSpecs: input.installDependencies || [
|
|
2026
|
-
input.dependencyId
|
|
2027
|
-
],
|
|
2028
|
-
projectPath: input.projectPath,
|
|
2029
|
-
diagnostics: {
|
|
2030
|
-
resolvedPath,
|
|
2031
|
-
loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
|
|
2032
|
-
}
|
|
2033
|
-
}));
|
|
2034
|
-
return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
|
|
2035
|
-
}
|
|
2036
|
-
async function ensureOptionalContractPackageResolved(input) {
|
|
2037
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
2038
|
-
return ensureOptionalPackageResolved({
|
|
2039
|
-
integration: contract.integration,
|
|
2040
|
-
projectPath: input.projectPath,
|
|
2041
|
-
dependencyId: input.dependencyId,
|
|
2042
|
-
contract
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
async function ensureOptionalContractModuleLoaded(input) {
|
|
2046
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
2047
|
-
return ensureOptionalModuleLoaded({
|
|
2048
|
-
integration: contract.integration,
|
|
2049
|
-
projectPath: input.projectPath,
|
|
2050
|
-
dependencyId: input.dependencyId,
|
|
2051
|
-
contract,
|
|
2052
|
-
moduleAdapter: input.moduleAdapter
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
function resolveOptionalContractPackageWithoutInstall(input) {
|
|
2056
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
2057
|
-
return resolveOptionalPackageWithoutInstall({
|
|
2058
|
-
integration: contract.integration,
|
|
2059
|
-
projectPath: input.projectPath,
|
|
2060
|
-
dependencyId: input.dependencyId,
|
|
2061
|
-
contract
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
|
-
function loadOptionalContractModuleWithoutInstall(input) {
|
|
2065
|
-
const contract = getOptionalDependencyContract(input.contractId);
|
|
2066
|
-
return loadOptionalModuleWithoutInstall({
|
|
2067
|
-
integration: contract.integration,
|
|
2068
|
-
projectPath: input.projectPath,
|
|
2069
|
-
dependencyId: input.dependencyId,
|
|
2070
|
-
contract,
|
|
2071
|
-
moduleAdapter: input.moduleAdapter
|
|
2072
|
-
});
|
|
2073
|
-
}
|
|
2074
1561
|
let userMessageDelivered = false;
|
|
2075
1562
|
function isUsingLess(projectPath) {
|
|
2076
1563
|
if (hasDependency(projectPath, 'less')) {
|