extension-develop 4.1.20 → 4.1.22
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/672~0.mjs +24 -1
- package/dist/747~0.mjs +4 -2
- package/dist/832~0.mjs +8 -19
- package/dist/840~0.mjs +434 -36
- package/dist/852~0.mjs +5 -1
- package/dist/950~0.mjs +45 -28
- package/dist/command-preview.d.ts +8 -0
- package/dist/dev-server/control-bridge/consumer-client.d.ts +10 -0
- package/dist/dev-server/control-bridge/contracts.d.ts +42 -0
- package/dist/dev-server/control-bridge/logs-query.d.ts +16 -0
- package/dist/dev-server~0.mjs +2 -0
- package/dist/lib/addon-lint.d.ts +4 -1
- package/dist/lib/build-summary.d.ts +11 -0
- package/dist/lib/chunk-dependency-provenance.d.ts +14 -0
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/manifest-utils.d.ts +2 -0
- package/dist/lib/messages.d.ts +3 -3
- package/dist/lib/messaging.d.ts +1 -0
- package/dist/lib/package-manager.d.ts +2 -0
- package/dist/lib/paths.d.ts +3 -0
- package/dist/plugin-browsers/index.d.ts +28 -0
- package/dist/plugin-compilation/env.d.ts +2 -0
- package/dist/plugin-js-frameworks/js-frameworks-lib/messages.d.ts +1 -0
- package/dist/plugin-js-frameworks/js-tools/solid.d.ts +3 -0
- package/dist/plugin-js-frameworks/js-tools/typescript.d.ts +16 -0
- package/dist/plugin-perf-budgets/categorize.d.ts +2 -1
- package/dist/plugin-perf-budgets/index.d.ts +1 -1
- package/dist/plugin-playwright/index.d.ts +1 -0
- package/dist/plugin-reload/classify-reload.d.ts +4 -0
- package/dist/plugin-reload/index.d.ts +18 -0
- package/dist/plugin-special-folders/folder-extensions/types.d.ts +13 -0
- package/dist/plugin-special-folders/messages.d.ts +2 -2
- package/dist/plugin-web-extension/feature-manifest/messages.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/emitted-evidence.d.ts +22 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-background.d.ts +9 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-web-resources.d.ts +7 -16
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults.d.ts +6 -2
- package/dist/plugin-web-extension/feature-manifest/steps/warn-gecko-unsupported-apis.d.ts +2 -13
- package/dist/plugin-web-extension/feature-scripts/messages.d.ts +5 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-page-context-worker.d.ts +5 -0
- package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/unreachable-resources.d.ts +9 -0
- package/dist/rspack-config.d.ts +1 -1
- package/dist/rspack-config~0.mjs +432 -465
- package/dist/types.d.ts +190 -0
- package/package.json +1 -1
package/dist/840~0.mjs
CHANGED
|
@@ -3,20 +3,21 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
4
|
import { spawn, sync } from "cross-spawn";
|
|
5
5
|
import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
|
|
6
|
-
import "pintor";
|
|
6
|
+
import pintor from "pintor";
|
|
7
|
+
import { DefinePlugin } from "@rspack/core";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
7
9
|
import { EventEmitter } from "node:events";
|
|
8
|
-
import {
|
|
10
|
+
import { humanWarn, browserRowValue, CODES, ENVELOPE, prefix as messaging_prefix, card, isDebug, claimCardKey, isMachineOutput } from "./852~0.mjs";
|
|
9
11
|
import { package_namespaceObject, loadCommandConfig, DEV_COMMAND_DEFAULTS, stampReadyDistExtensionId, loadProjectConfigDefaults, mergeOptionLayers, stampReadyKnownExtensionId, assertNoManagedDependencyConflicts, loadCustomConfig, START_BUILD_DEFAULTS, loadBrowserConfig, resolveCompanionExtensionsConfig, BUILD_COMMAND_DEFAULTS, getSpecialFoldersDataForProjectRoot, withDarkMode } from "./832~0.mjs";
|
|
10
12
|
import { stripBom, hasProjectDependency, parseJsonSafe, findNearestProjectManifestDirSync } from "./731~0.mjs";
|
|
11
13
|
import { isGeckoBasedBrowser } from "./331~0.mjs";
|
|
12
|
-
import { buildWarningsDetails, buildFailed, getDirs, zipArtifactReady, projectInstallFallbackToNpm, debugDirs, browserLaunchFailed,
|
|
14
|
+
import { buildWarningsDetails, buildFailed, getDirs, zipArtifactReady, projectInstallFallbackToNpm, debugDirs, addonLintDependencyAttribution, browserLaunchFailed, collapseHomeDir, addonLintMore, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, relativeToDir, projectInstallScriptsDisabled, authorInstallNotice, addonLintFailed, buildAssetsTree, addonLintSummary, addonLintFinding, configBrowserOrThrow, buildSummaryPath, needsInstall, projectInstallInWorkspaceRoot, buildCommandFailed, addonLintNotInstalled, writingTypeDefinitions, buildComplete, ensureSessionStateInProjectGitignore, displayPath, ensureSessionArtifactsIgnoreFile, debugBrowser, normalizeBrowser, debugOutputPath, devCommandFailed, buildShareHint, getDistPath, getProjectStructure, debugSplitChunksNarrowed } from "./950~0.mjs";
|
|
13
15
|
import { publicRootsFor } from "./105~0.mjs";
|
|
14
16
|
import { getCanonicalContentScriptEntryName } from "./640~0.mjs";
|
|
15
17
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
16
18
|
import { dirname as __rspack_dirname } from "node:path";
|
|
17
19
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
18
20
|
import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
|
|
19
|
-
import * as __rspack_external_node_os_4f3c9d58 from "node:os";
|
|
20
21
|
import * as __rspack_external_node_path_806ed179 from "node:path";
|
|
21
22
|
import * as __rspack_external_node_fs_promises_3b710708 from "node:fs/promises";
|
|
22
23
|
const MAX_OUTPUT_CHARS = 2000;
|
|
@@ -775,7 +776,7 @@ function readPnpmWorkspacePackages(workspaceRoot) {
|
|
|
775
776
|
for(let j = i + 1; j < lines.length; j++){
|
|
776
777
|
const line = lines[j];
|
|
777
778
|
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
778
|
-
const item = /^\s
|
|
779
|
+
const item = /^\s*-\s*(.+)$/.exec(line);
|
|
779
780
|
if (!item) break;
|
|
780
781
|
const value = cleanYamlListItem(item[1]);
|
|
781
782
|
if (value) patterns.push(value);
|
|
@@ -900,19 +901,21 @@ function buildSpawnInvocation(command, args) {
|
|
|
900
901
|
args
|
|
901
902
|
};
|
|
902
903
|
}
|
|
903
|
-
function
|
|
904
|
+
function spawnInstallCommand(command, args, options) {
|
|
904
905
|
const invocation = buildSpawnInvocation(command, args);
|
|
905
906
|
const env = buildExecEnv();
|
|
906
|
-
|
|
907
|
+
return spawn(invocation.command, invocation.args, {
|
|
908
|
+
cwd: options?.cwd,
|
|
909
|
+
stdio: options?.stdio ?? 'ignore',
|
|
910
|
+
env: {
|
|
911
|
+
...env || process.env,
|
|
912
|
+
...options?.env
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
function execInstallCommand(command, args, options) {
|
|
907
917
|
return new Promise((resolve, reject)=>{
|
|
908
|
-
const child =
|
|
909
|
-
cwd: options?.cwd,
|
|
910
|
-
stdio,
|
|
911
|
-
env: {
|
|
912
|
-
...env || process.env,
|
|
913
|
-
...options?.env
|
|
914
|
-
}
|
|
915
|
-
});
|
|
918
|
+
const child = spawnInstallCommand(command, args, options);
|
|
916
919
|
child.on('close', (code)=>{
|
|
917
920
|
if (0 !== code) reject(new Error(`Install failed with exit code ${code}`));
|
|
918
921
|
else resolve();
|
|
@@ -1340,7 +1343,14 @@ function collectAddonLintLines(output) {
|
|
|
1340
1343
|
...warnings.map((finding)=>toLine('warning', finding))
|
|
1341
1344
|
].filter((line)=>!DUPLICATED_BY_BUILD_WARNINGS.has(line.code));
|
|
1342
1345
|
}
|
|
1343
|
-
function
|
|
1346
|
+
function attributionFor(location, chunkProvenance) {
|
|
1347
|
+
if (!chunkProvenance || 0 === chunkProvenance.size) return '';
|
|
1348
|
+
const file = location.split(':')[0].replace(/\\/g, '/').replace(/^\.?\//, '');
|
|
1349
|
+
const provenance = chunkProvenance.get(file);
|
|
1350
|
+
if (!provenance) return '';
|
|
1351
|
+
return addonLintDependencyAttribution(provenance.packages, provenance.onlyDependencies);
|
|
1352
|
+
}
|
|
1353
|
+
function formatAddonLintFindings(output, distDisplay, maxPrinted = ADDON_LINT_MAX_PRINTED, chunkProvenance) {
|
|
1344
1354
|
const all = collectAddonLintLines(output);
|
|
1345
1355
|
if (0 === all.length) return {
|
|
1346
1356
|
findings: 0,
|
|
@@ -1351,7 +1361,7 @@ function formatAddonLintFindings(output, distDisplay, maxPrinted = ADDON_LINT_MA
|
|
|
1351
1361
|
const shown = all.slice(0, Math.max(0, maxPrinted));
|
|
1352
1362
|
const lines = [
|
|
1353
1363
|
addonLintSummary(errorCount, warningCount, distDisplay),
|
|
1354
|
-
...shown.map((line)=>addonLintFinding(line.level, line.code, line.message, line.location))
|
|
1364
|
+
...shown.map((line)=>addonLintFinding(line.level, line.code, line.message, line.location, attributionFor(line.location, chunkProvenance)))
|
|
1355
1365
|
];
|
|
1356
1366
|
if (all.length > shown.length) lines.push(addonLintMore(all.length - shown.length, distDisplay));
|
|
1357
1367
|
return {
|
|
@@ -1424,7 +1434,7 @@ async function runAddonLint(input) {
|
|
|
1424
1434
|
}), input.timeoutMs ?? ADDON_LINT_TIMEOUT_MS);
|
|
1425
1435
|
return {
|
|
1426
1436
|
status: 'linted',
|
|
1427
|
-
...formatAddonLintFindings(output, input.distDisplay)
|
|
1437
|
+
...formatAddonLintFindings(output, input.distDisplay, ADDON_LINT_MAX_PRINTED, input.chunkProvenance?.())
|
|
1428
1438
|
};
|
|
1429
1439
|
} catch (error) {
|
|
1430
1440
|
return {
|
|
@@ -1514,6 +1524,85 @@ function getBuildSummary(browser, info, outputPath) {
|
|
|
1514
1524
|
} : {}
|
|
1515
1525
|
};
|
|
1516
1526
|
}
|
|
1527
|
+
function packageNameFromPath(candidate) {
|
|
1528
|
+
const normalized = candidate.replace(/\\/g, '/');
|
|
1529
|
+
const marker = '/node_modules/';
|
|
1530
|
+
const at = normalized.lastIndexOf(marker);
|
|
1531
|
+
if (-1 === at) return null;
|
|
1532
|
+
const rest = normalized.slice(at + marker.length);
|
|
1533
|
+
const segments = rest.split('/').filter(Boolean);
|
|
1534
|
+
if (0 === segments.length) return null;
|
|
1535
|
+
if (segments[0].startsWith('@')) return segments.length > 1 ? `${segments[0]}/${segments[1]}` : null;
|
|
1536
|
+
if (segments[0].includes('@') && segments.length > 1) return packageNameFromPath(`/node_modules/${segments.slice(1).join('/')}`);
|
|
1537
|
+
return segments[0];
|
|
1538
|
+
}
|
|
1539
|
+
function isAbsoluteFilePath(candidate) {
|
|
1540
|
+
return /^([a-zA-Z]:[\\/]|[\\/])/.test(candidate);
|
|
1541
|
+
}
|
|
1542
|
+
function pathOfModule(moduleObj) {
|
|
1543
|
+
const candidate = moduleObj;
|
|
1544
|
+
if ('string' == typeof candidate?.resource && candidate.resource) return candidate.resource;
|
|
1545
|
+
if ('function' == typeof candidate?.identifier) {
|
|
1546
|
+
const identifier = candidate.identifier();
|
|
1547
|
+
if ('string' == typeof identifier && identifier) return identifier;
|
|
1548
|
+
}
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
function collectChunkDependencyProvenance(compilation) {
|
|
1552
|
+
const provenance = new Map();
|
|
1553
|
+
const chunkGraph = compilation?.chunkGraph;
|
|
1554
|
+
const chunks = compilation?.chunks;
|
|
1555
|
+
if (!chunkGraph?.getChunkModulesIterable || !chunks) return provenance;
|
|
1556
|
+
for (const chunk of chunks){
|
|
1557
|
+
const files = chunk?.files;
|
|
1558
|
+
if (!files) continue;
|
|
1559
|
+
let modules = [];
|
|
1560
|
+
try {
|
|
1561
|
+
modules = Array.from(chunkGraph.getChunkModulesIterable(chunk));
|
|
1562
|
+
} catch {
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
const packages = new Set();
|
|
1566
|
+
let counted = 0;
|
|
1567
|
+
let fromDependencies = 0;
|
|
1568
|
+
for (const moduleObj of modules){
|
|
1569
|
+
const modulePath = pathOfModule(moduleObj);
|
|
1570
|
+
if (!modulePath) continue;
|
|
1571
|
+
if (!isAbsoluteFilePath(modulePath)) continue;
|
|
1572
|
+
counted += 1;
|
|
1573
|
+
const packageName = packageNameFromPath(modulePath);
|
|
1574
|
+
if (packageName) {
|
|
1575
|
+
fromDependencies += 1;
|
|
1576
|
+
packages.add(packageName);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (0 === packages.size) continue;
|
|
1580
|
+
const entry = {
|
|
1581
|
+
packages: [
|
|
1582
|
+
...packages
|
|
1583
|
+
].sort(),
|
|
1584
|
+
onlyDependencies: counted > 0 && fromDependencies === counted
|
|
1585
|
+
};
|
|
1586
|
+
for (const file of files){
|
|
1587
|
+
if ('string' != typeof file || !file.endsWith('.js')) continue;
|
|
1588
|
+
const existing = provenance.get(file);
|
|
1589
|
+
if (!existing) {
|
|
1590
|
+
provenance.set(file, entry);
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
provenance.set(file, {
|
|
1594
|
+
packages: [
|
|
1595
|
+
...new Set([
|
|
1596
|
+
...existing.packages,
|
|
1597
|
+
...entry.packages
|
|
1598
|
+
])
|
|
1599
|
+
].sort(),
|
|
1600
|
+
onlyDependencies: existing.onlyDependencies && entry.onlyDependencies
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
return provenance;
|
|
1605
|
+
}
|
|
1517
1606
|
async function ensureUserProjectDependencies(packageJsonDir) {
|
|
1518
1607
|
const member = findPnpmWorkspaceMember(packageJsonDir);
|
|
1519
1608
|
if (!needsInstall(packageJsonDir, member?.root)) return;
|
|
@@ -1805,6 +1894,9 @@ function isUsingJSFramework(projectPath) {
|
|
|
1805
1894
|
function isUsingIntegration(name) {
|
|
1806
1895
|
return `integration use=${name}`;
|
|
1807
1896
|
}
|
|
1897
|
+
function solidIsNotSupported() {
|
|
1898
|
+
return `${messaging_prefix('warn')} Solid is not a supported framework, so this project compiles through the JSX runtime only.\nA signal read in a child position, like ${pintor.yellow('{count()}')}, renders once and does not update.\nOnly Solid's own compiler makes that expression reactive, and the JSX runtime cannot recover it.`;
|
|
1899
|
+
}
|
|
1808
1900
|
function creatingTSConfig() {
|
|
1809
1901
|
return `${messaging_prefix('info')} Creating a default tsconfig.json…`;
|
|
1810
1902
|
}
|
|
@@ -1824,6 +1916,319 @@ function jsFrameworksHmrSummary(enabled, frameworks) {
|
|
|
1824
1916
|
const names = frameworks.length > 0 ? frameworks.join(',') : 'none';
|
|
1825
1917
|
return `${messaging_prefix('debug')} js hmr=${enabled ? 'enabled' : 'disabled'} frameworks=${names}`;
|
|
1826
1918
|
}
|
|
1919
|
+
let userMessageDelivered = false;
|
|
1920
|
+
function isUsingPreact(projectPath) {
|
|
1921
|
+
if (hasDependency(projectPath, 'preact')) {
|
|
1922
|
+
if (!userMessageDelivered) {
|
|
1923
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('Preact')}`);
|
|
1924
|
+
userMessageDelivered = true;
|
|
1925
|
+
}
|
|
1926
|
+
return true;
|
|
1927
|
+
}
|
|
1928
|
+
return false;
|
|
1929
|
+
}
|
|
1930
|
+
async function maybeUsePreact(projectPath) {
|
|
1931
|
+
if (!isUsingPreact(projectPath)) return;
|
|
1932
|
+
const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
|
|
1933
|
+
const resolveFromProject = (id)=>{
|
|
1934
|
+
try {
|
|
1935
|
+
return requireFromProject.resolve(id);
|
|
1936
|
+
} catch {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
const preactPkgJson = resolveFromProject('preact/package.json');
|
|
1941
|
+
const preactDir = preactPkgJson ? __rspack_external_node_path_806ed179.dirname(preactPkgJson) : void 0;
|
|
1942
|
+
const preactCompat = resolveFromProject('preact/compat');
|
|
1943
|
+
const preactTestUtils = resolveFromProject('preact/test-utils');
|
|
1944
|
+
const preactJsxRuntime = resolveFromProject('preact/jsx-runtime');
|
|
1945
|
+
const preactJsxDevRuntime = resolveFromProject('preact/jsx-dev-runtime');
|
|
1946
|
+
const alias = {};
|
|
1947
|
+
if (preactJsxRuntime) alias['preact/jsx-runtime'] = preactJsxRuntime;
|
|
1948
|
+
if (preactJsxDevRuntime) alias['preact/jsx-dev-runtime'] = preactJsxDevRuntime;
|
|
1949
|
+
if (preactDir) alias.preact = preactDir;
|
|
1950
|
+
if (preactCompat) {
|
|
1951
|
+
alias.react = preactCompat;
|
|
1952
|
+
alias['react-dom'] = preactCompat;
|
|
1953
|
+
}
|
|
1954
|
+
if (preactTestUtils) alias['react-dom/test-utils'] = preactTestUtils;
|
|
1955
|
+
if (preactJsxRuntime) alias['react/jsx-runtime'] = preactJsxRuntime;
|
|
1956
|
+
if (preactJsxDevRuntime) alias['react/jsx-dev-runtime'] = preactJsxDevRuntime;
|
|
1957
|
+
return {
|
|
1958
|
+
plugins: [],
|
|
1959
|
+
loaders: void 0,
|
|
1960
|
+
alias
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
let react_userMessageDelivered = false;
|
|
1964
|
+
function isUsingReact(projectPath) {
|
|
1965
|
+
if (hasDependency(projectPath, 'react')) {
|
|
1966
|
+
if (!react_userMessageDelivered) {
|
|
1967
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('React')}`);
|
|
1968
|
+
react_userMessageDelivered = true;
|
|
1969
|
+
}
|
|
1970
|
+
return true;
|
|
1971
|
+
}
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
async function maybeUseReact(projectPath, options = {}) {
|
|
1975
|
+
if (!isUsingReact(projectPath)) return;
|
|
1976
|
+
const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
|
|
1977
|
+
let reactPath;
|
|
1978
|
+
let reactDomPath;
|
|
1979
|
+
let reactDomClientPath;
|
|
1980
|
+
let jsxRuntimePath;
|
|
1981
|
+
let jsxDevRuntimePath;
|
|
1982
|
+
try {
|
|
1983
|
+
reactPath = requireFromProject.resolve('react');
|
|
1984
|
+
} catch {}
|
|
1985
|
+
try {
|
|
1986
|
+
reactDomPath = requireFromProject.resolve('react-dom');
|
|
1987
|
+
} catch {}
|
|
1988
|
+
try {
|
|
1989
|
+
reactDomClientPath = requireFromProject.resolve('react-dom/client');
|
|
1990
|
+
} catch {}
|
|
1991
|
+
try {
|
|
1992
|
+
jsxRuntimePath = requireFromProject.resolve('react/jsx-runtime');
|
|
1993
|
+
} catch {}
|
|
1994
|
+
try {
|
|
1995
|
+
jsxDevRuntimePath = requireFromProject.resolve('react/jsx-dev-runtime');
|
|
1996
|
+
} catch {}
|
|
1997
|
+
const alias = {};
|
|
1998
|
+
if (reactPath) alias.react$ = reactPath;
|
|
1999
|
+
if (reactDomPath) alias['react-dom$'] = reactDomPath;
|
|
2000
|
+
if (reactDomClientPath) alias['react-dom/client'] = reactDomClientPath;
|
|
2001
|
+
if (jsxRuntimePath) alias['react/jsx-runtime'] = jsxRuntimePath;
|
|
2002
|
+
if (jsxDevRuntimePath) alias['react/jsx-dev-runtime'] = jsxDevRuntimePath;
|
|
2003
|
+
if (true === options.disableRefresh) return {
|
|
2004
|
+
plugins: [],
|
|
2005
|
+
loaders: void 0,
|
|
2006
|
+
alias
|
|
2007
|
+
};
|
|
2008
|
+
resolveOptionalContractPackageWithoutInstall({
|
|
2009
|
+
contractId: 'react-refresh',
|
|
2010
|
+
projectPath,
|
|
2011
|
+
dependencyId: 'react-refresh'
|
|
2012
|
+
});
|
|
2013
|
+
const ReactRefreshPlugin = loadOptionalContractModuleWithoutInstall({
|
|
2014
|
+
contractId: 'react-refresh',
|
|
2015
|
+
projectPath,
|
|
2016
|
+
dependencyId: '@rspack/plugin-react-refresh',
|
|
2017
|
+
moduleAdapter: (mod)=>mod && (mod.default || mod.ReactRefreshRspackPlugin) || mod
|
|
2018
|
+
});
|
|
2019
|
+
const reactPlugins = [
|
|
2020
|
+
new ReactRefreshPlugin({
|
|
2021
|
+
overlay: false,
|
|
2022
|
+
...void 0 === options.refreshExclude ? {} : {
|
|
2023
|
+
exclude: options.refreshExclude
|
|
2024
|
+
}
|
|
2025
|
+
})
|
|
2026
|
+
];
|
|
2027
|
+
return {
|
|
2028
|
+
plugins: reactPlugins,
|
|
2029
|
+
loaders: void 0,
|
|
2030
|
+
alias
|
|
2031
|
+
};
|
|
2032
|
+
}
|
|
2033
|
+
let solid_userMessageDelivered = false;
|
|
2034
|
+
function isUsingSolid(projectPath) {
|
|
2035
|
+
if (hasDependency(projectPath, 'solid-js')) {
|
|
2036
|
+
if (!solid_userMessageDelivered) {
|
|
2037
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('Solid')}`);
|
|
2038
|
+
humanWarn(solidIsNotSupported());
|
|
2039
|
+
solid_userMessageDelivered = true;
|
|
2040
|
+
}
|
|
2041
|
+
return true;
|
|
2042
|
+
}
|
|
2043
|
+
return false;
|
|
2044
|
+
}
|
|
2045
|
+
function pickEsmCondition(entry) {
|
|
2046
|
+
if ('string' == typeof entry) return entry;
|
|
2047
|
+
if (!entry || 'object' != typeof entry) return;
|
|
2048
|
+
const conditions = entry;
|
|
2049
|
+
for (const name of [
|
|
2050
|
+
'browser',
|
|
2051
|
+
'import',
|
|
2052
|
+
'module',
|
|
2053
|
+
'default'
|
|
2054
|
+
]){
|
|
2055
|
+
const picked = pickEsmCondition(conditions[name]);
|
|
2056
|
+
if (picked) return picked;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
function resolveSolidHyperscript(resolveFromProject) {
|
|
2060
|
+
const packageJsonPath = resolveFromProject('solid-js/package.json');
|
|
2061
|
+
if (packageJsonPath) try {
|
|
2062
|
+
const packageJson = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(packageJsonPath, 'utf-8'));
|
|
2063
|
+
const subpath = pickEsmCondition(packageJson?.exports?.['./h']);
|
|
2064
|
+
if (subpath) {
|
|
2065
|
+
const esmPath = __rspack_external_node_path_806ed179.resolve(__rspack_external_node_path_806ed179.dirname(packageJsonPath), subpath);
|
|
2066
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(esmPath)) return esmPath;
|
|
2067
|
+
}
|
|
2068
|
+
} catch {}
|
|
2069
|
+
return resolveFromProject('solid-js/h/dist/h.js') || resolveFromProject('solid-js/h');
|
|
2070
|
+
}
|
|
2071
|
+
async function maybeUseSolid(projectPath) {
|
|
2072
|
+
if (!isUsingSolid(projectPath)) return;
|
|
2073
|
+
const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
|
|
2074
|
+
const resolveFromProject = (id)=>{
|
|
2075
|
+
try {
|
|
2076
|
+
return requireFromProject.resolve(id);
|
|
2077
|
+
} catch {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2080
|
+
};
|
|
2081
|
+
const adapter = resolveDevelopDistFile('solid-jsx-runtime');
|
|
2082
|
+
const hyperscript = resolveSolidHyperscript(resolveFromProject);
|
|
2083
|
+
const alias = {
|
|
2084
|
+
'solid-js/jsx-runtime$': adapter,
|
|
2085
|
+
'solid-js/jsx-dev-runtime$': adapter
|
|
2086
|
+
};
|
|
2087
|
+
if (hyperscript) alias['solid-js/h$'] = hyperscript;
|
|
2088
|
+
return {
|
|
2089
|
+
plugins: [],
|
|
2090
|
+
loaders: void 0,
|
|
2091
|
+
alias
|
|
2092
|
+
};
|
|
2093
|
+
}
|
|
2094
|
+
let load_loader_options_userMessageDelivered = false;
|
|
2095
|
+
function resolveLoaderConfigPath(projectPath, framework) {
|
|
2096
|
+
const candidates = [
|
|
2097
|
+
__rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.ts`),
|
|
2098
|
+
__rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.mts`),
|
|
2099
|
+
__rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.js`),
|
|
2100
|
+
__rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.mjs`)
|
|
2101
|
+
];
|
|
2102
|
+
return candidates.find((p)=>__rspack_external_node_fs_1b05aee1.existsSync(p)) || null;
|
|
2103
|
+
}
|
|
2104
|
+
async function loadLoaderOptions(projectPath, framework) {
|
|
2105
|
+
const configPath = resolveLoaderConfigPath(projectPath, framework);
|
|
2106
|
+
if (configPath) {
|
|
2107
|
+
if (!load_loader_options_userMessageDelivered && isDebug()) {
|
|
2108
|
+
const display = __rspack_external_node_path_806ed179.basename(configPath);
|
|
2109
|
+
console.log(isUsingCustomLoader(display));
|
|
2110
|
+
load_loader_options_userMessageDelivered = true;
|
|
2111
|
+
}
|
|
2112
|
+
try {
|
|
2113
|
+
const module = await import(pathToFileURL(configPath).href);
|
|
2114
|
+
return module.default || module;
|
|
2115
|
+
} catch (err) {
|
|
2116
|
+
const error = err;
|
|
2117
|
+
console.error(`Error loading ${framework} loader options: ${error.message}`);
|
|
2118
|
+
throw err;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
let vue_userMessageDelivered = false;
|
|
2124
|
+
function isUsingVue(projectPath) {
|
|
2125
|
+
const using = hasDependency(projectPath, 'vue');
|
|
2126
|
+
if (using && !vue_userMessageDelivered) {
|
|
2127
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('Vue')}`);
|
|
2128
|
+
vue_userMessageDelivered = true;
|
|
2129
|
+
}
|
|
2130
|
+
return using;
|
|
2131
|
+
}
|
|
2132
|
+
function resolveVueBundlerEntry(requireFromProject, id) {
|
|
2133
|
+
try {
|
|
2134
|
+
const manifestPath = requireFromProject.resolve(`${id}/package.json`);
|
|
2135
|
+
const manifest = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(manifestPath, 'utf8'));
|
|
2136
|
+
if ('string' == typeof manifest.module && manifest.module) {
|
|
2137
|
+
const entry = __rspack_external_node_path_806ed179.join(__rspack_external_node_path_806ed179.dirname(manifestPath), manifest.module);
|
|
2138
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(entry)) return entry;
|
|
2139
|
+
}
|
|
2140
|
+
} catch {}
|
|
2141
|
+
try {
|
|
2142
|
+
return requireFromProject.resolve(id);
|
|
2143
|
+
} catch {
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
async function maybeUseVue(projectPath, mode = 'development') {
|
|
2148
|
+
if (!isUsingVue(projectPath)) return;
|
|
2149
|
+
const vueLoaderPath = await ensureOptionalContractPackageResolved({
|
|
2150
|
+
contractId: 'vue',
|
|
2151
|
+
projectPath,
|
|
2152
|
+
dependencyId: 'vue-loader'
|
|
2153
|
+
});
|
|
2154
|
+
const VueLoaderPlugin = await ensureOptionalContractModuleLoaded({
|
|
2155
|
+
contractId: 'vue',
|
|
2156
|
+
projectPath,
|
|
2157
|
+
dependencyId: 'vue-loader',
|
|
2158
|
+
moduleAdapter: (mod)=>mod?.VueLoaderPlugin || mod?.default?.VueLoaderPlugin
|
|
2159
|
+
});
|
|
2160
|
+
const customOptions = await loadLoaderOptions(projectPath, 'vue');
|
|
2161
|
+
const defaultLoaders = [
|
|
2162
|
+
{
|
|
2163
|
+
test: /\.vue$/,
|
|
2164
|
+
loader: vueLoaderPath,
|
|
2165
|
+
options: {
|
|
2166
|
+
experimentalInlineMatchResource: true,
|
|
2167
|
+
...customOptions || {}
|
|
2168
|
+
},
|
|
2169
|
+
include: projectPath,
|
|
2170
|
+
exclude: /node_modules/
|
|
2171
|
+
}
|
|
2172
|
+
];
|
|
2173
|
+
const isProd = 'production' === mode;
|
|
2174
|
+
const defaultPlugins = [
|
|
2175
|
+
new VueLoaderPlugin(),
|
|
2176
|
+
new DefinePlugin({
|
|
2177
|
+
__VUE_OPTIONS_API__: JSON.stringify(true),
|
|
2178
|
+
__VUE_PROD_DEVTOOLS__: JSON.stringify(!isProd),
|
|
2179
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(!isProd)
|
|
2180
|
+
})
|
|
2181
|
+
];
|
|
2182
|
+
const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
|
|
2183
|
+
const resolveFromProject = (id)=>resolveVueBundlerEntry(requireFromProject, id);
|
|
2184
|
+
const alias = {};
|
|
2185
|
+
const vuePath = resolveFromProject('vue');
|
|
2186
|
+
const vueRuntimeDom = resolveFromProject('@vue/runtime-dom');
|
|
2187
|
+
const vueRuntimeCore = resolveFromProject('@vue/runtime-core');
|
|
2188
|
+
const vueShared = resolveFromProject('@vue/shared');
|
|
2189
|
+
if (vuePath) alias.vue$ = vuePath;
|
|
2190
|
+
if (vueRuntimeDom) alias['@vue/runtime-dom'] = vueRuntimeDom;
|
|
2191
|
+
if (vueRuntimeCore) alias['@vue/runtime-core'] = vueRuntimeCore;
|
|
2192
|
+
if (vueShared) alias['@vue/shared'] = vueShared;
|
|
2193
|
+
return {
|
|
2194
|
+
plugins: defaultPlugins,
|
|
2195
|
+
loaders: defaultLoaders,
|
|
2196
|
+
alias
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
function isUsingJsxFramework(projectPath) {
|
|
2200
|
+
return isUsingReact(projectPath) || isUsingPreact(projectPath) || isUsingSolid(projectPath) || isUsingVue(projectPath);
|
|
2201
|
+
}
|
|
2202
|
+
function getJsxImportSource(projectPath) {
|
|
2203
|
+
if (isUsingSolid(projectPath)) return 'solid-js';
|
|
2204
|
+
if (isUsingPreact(projectPath) && !isUsingReact(projectPath)) return 'preact';
|
|
2205
|
+
if (isUsingVue(projectPath) && !isUsingReact(projectPath) && !isUsingPreact(projectPath)) return 'vue';
|
|
2206
|
+
return 'react';
|
|
2207
|
+
}
|
|
2208
|
+
function swcParserForFile(resourcePath, jsxInPlainJs) {
|
|
2209
|
+
const clean = String(resourcePath || '').split('?')[0];
|
|
2210
|
+
const ext = __rspack_external_node_path_806ed179.extname(clean).toLowerCase();
|
|
2211
|
+
if ('.tsx' === ext || '.mtsx' === ext) return {
|
|
2212
|
+
syntax: "typescript",
|
|
2213
|
+
tsx: true,
|
|
2214
|
+
dynamicImport: true
|
|
2215
|
+
};
|
|
2216
|
+
if ('.ts' === ext || '.mts' === ext || '.cts' === ext) return {
|
|
2217
|
+
syntax: "typescript",
|
|
2218
|
+
tsx: false,
|
|
2219
|
+
dynamicImport: true
|
|
2220
|
+
};
|
|
2221
|
+
if ('.jsx' === ext || '.mjsx' === ext) return {
|
|
2222
|
+
syntax: "ecmascript",
|
|
2223
|
+
jsx: true,
|
|
2224
|
+
dynamicImport: true
|
|
2225
|
+
};
|
|
2226
|
+
return {
|
|
2227
|
+
syntax: "ecmascript",
|
|
2228
|
+
jsx: jsxInPlainJs,
|
|
2229
|
+
dynamicImport: true
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
1827
2232
|
let hasShownUserMessage = false;
|
|
1828
2233
|
function findNearestPackageJsonDirectory(startPath) {
|
|
1829
2234
|
return findNearestProjectManifestDirSync(startPath, 6);
|
|
@@ -1884,13 +2289,18 @@ function ensureTypeScriptConfig(projectPath) {
|
|
|
1884
2289
|
}
|
|
1885
2290
|
}
|
|
1886
2291
|
function defaultTypeScriptConfig(projectPath, _opts) {
|
|
2292
|
+
const usesJsFramework = isUsingJSFramework(projectPath);
|
|
2293
|
+
const jsxImportSource = usesJsFramework ? {
|
|
2294
|
+
jsxImportSource: getJsxImportSource(projectPath)
|
|
2295
|
+
} : {};
|
|
1887
2296
|
return {
|
|
1888
2297
|
compilerOptions: {
|
|
1889
2298
|
allowJs: true,
|
|
1890
2299
|
allowSyntheticDefaultImports: true,
|
|
1891
2300
|
esModuleInterop: true,
|
|
1892
2301
|
forceConsistentCasingInFileNames: true,
|
|
1893
|
-
jsx:
|
|
2302
|
+
jsx: usesJsFramework ? 'react-jsx' : 'preserve',
|
|
2303
|
+
...jsxImportSource,
|
|
1894
2304
|
lib: [
|
|
1895
2305
|
'dom',
|
|
1896
2306
|
'dom.iterable',
|
|
@@ -1927,19 +2337,6 @@ function writeTsConfig(projectPath) {
|
|
|
1927
2337
|
mode: 'development'
|
|
1928
2338
|
}), null, 2));
|
|
1929
2339
|
}
|
|
1930
|
-
function collapseHomeDir(value) {
|
|
1931
|
-
const home = __rspack_external_node_os_4f3c9d58.homedir();
|
|
1932
|
-
if (!home || !value.startsWith(home)) return value;
|
|
1933
|
-
const rest = value.slice(home.length);
|
|
1934
|
-
if ('' === rest) return '~';
|
|
1935
|
-
if (rest.startsWith(__rspack_external_node_path_806ed179.sep) || rest.startsWith('/')) return `~${rest}`;
|
|
1936
|
-
return value;
|
|
1937
|
-
}
|
|
1938
|
-
function relativeToCwd(target) {
|
|
1939
|
-
const relative = __rspack_external_node_path_806ed179.relative(process.cwd(), target);
|
|
1940
|
-
if (relative && !relative.startsWith('..') && !__rspack_external_node_path_806ed179.isAbsolute(relative)) return relative;
|
|
1941
|
-
return null;
|
|
1942
|
-
}
|
|
1943
2340
|
const reportedBuildFailures = new WeakSet();
|
|
1944
2341
|
function printBuildCard(manifestPath, browser, distPath) {
|
|
1945
2342
|
if (!claimCardKey(`${browser}::${__rspack_external_node_path_806ed179.resolve(distPath)}`)) return;
|
|
@@ -2113,7 +2510,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
|
|
|
2113
2510
|
errors: true
|
|
2114
2511
|
});
|
|
2115
2512
|
summary = getBuildSummary(browser, info, displayDistPath);
|
|
2116
|
-
const distDisplay =
|
|
2513
|
+
const distDisplay = displayPath(displayDistPath);
|
|
2117
2514
|
const lintLines = [];
|
|
2118
2515
|
try {
|
|
2119
2516
|
const lint = await runAddonLint({
|
|
@@ -2122,7 +2519,8 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
|
|
|
2122
2519
|
distDisplay,
|
|
2123
2520
|
browser,
|
|
2124
2521
|
mode: resolvedMode,
|
|
2125
|
-
enabled: mergedBuildOptions.addonLint
|
|
2522
|
+
enabled: mergedBuildOptions.addonLint,
|
|
2523
|
+
chunkProvenance: ()=>collectChunkDependencyProvenance(stats.compilation)
|
|
2126
2524
|
});
|
|
2127
2525
|
if ('missing' === lint.status && lint.hint) lintLines.push(lint.hint);
|
|
2128
2526
|
else if ('failed' === lint.status && isDebug()) lintLines.push(lint.debugLine);
|
|
@@ -2155,7 +2553,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
|
|
|
2155
2553
|
humanLine(buildComplete(browser, distDisplay, summary.total_bytes, resolvedMode));
|
|
2156
2554
|
for (const artifact of getZipArtifacts(stats.compilation)){
|
|
2157
2555
|
const artifactPath = useStagingSwap && artifact.path.startsWith(stagingDistPath) ? distPath + artifact.path.slice(stagingDistPath.length) : artifact.path;
|
|
2158
|
-
const zipDisplay =
|
|
2556
|
+
const zipDisplay = relativeToDir(artifactPath, process.cwd()) || artifactPath;
|
|
2159
2557
|
humanLine(zipArtifactReady(zipDisplay, artifact.size));
|
|
2160
2558
|
}
|
|
2161
2559
|
const shareHint = buildShareHint();
|
|
@@ -2907,4 +3305,4 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
|
|
|
2907
3305
|
process.exit(1);
|
|
2908
3306
|
}
|
|
2909
3307
|
}
|
|
2910
|
-
export { BuildEmitter, applySplitChunksGuard, attachLifecycleStream, buildSourceFeatureIndex, classifyEntrySurface, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, defaultSplitChunks, dispatchReload,
|
|
3308
|
+
export { BuildEmitter, applySplitChunksGuard, attachLifecycleStream, buildSourceFeatureIndex, classifyEntrySurface, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, defaultSplitChunks, dispatchReload, ensureOptionalContractPackageResolved, ensureTypeScriptConfig, extensionBuild, extensionDev, getJsxImportSource, getUserTypeScriptConfigFile, hasDependency, humanLine, isUsingIntegration, isUsingJsxFramework, isUsingReact, isUsingTypeScript, isUsingVue, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadLoaderOptions, maybeUsePreact, maybeUseReact, maybeUseSolid, maybeUseVue, readContentScriptCount, recordZipArtifact, resolveDevelopDistFile, resolveDevelopInstallRoot, swcParserForFile };
|
package/dist/852~0.mjs
CHANGED
|
@@ -22,6 +22,10 @@ function prefix(type) {
|
|
|
22
22
|
if ('debug' === type) return pintor.dim(pintor.gray(DEBUG_GLYPH));
|
|
23
23
|
return pintor.gray(GLYPH);
|
|
24
24
|
}
|
|
25
|
+
const ANSI_PATTERN = /\[[0-9;]*m/g;
|
|
26
|
+
function hasChannelPrefix(text) {
|
|
27
|
+
return String(text || '').replace(ANSI_PATTERN, '').trimStart().startsWith(GLYPH);
|
|
28
|
+
}
|
|
25
29
|
const MACHINE_OUTPUT_VALUES = new Set([
|
|
26
30
|
'json',
|
|
27
31
|
'ndjson'
|
|
@@ -272,4 +276,4 @@ const ENVELOPE = {
|
|
|
272
276
|
}, extras);
|
|
273
277
|
}
|
|
274
278
|
};
|
|
275
|
-
export { CODES, ENVELOPE, artifactNoun, browserRowValue, card, claimCardKey, fmt, humanLine, humanWarn, isDebug, isMachineOutput, prefix };
|
|
279
|
+
export { CODES, ENVELOPE, artifactNoun, browserRowValue, card, claimCardKey, fmt, hasChannelPrefix, humanLine, humanWarn, isDebug, isMachineOutput, prefix };
|