@mnci/cli 4.1.2 → 4.1.3
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/cli.js +31 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1419,10 +1419,13 @@ var ROLLUP_ARG_ONE_WITH_SOURCE_MAPS = [
|
|
|
1419
1419
|
""
|
|
1420
1420
|
].join("\n");
|
|
1421
1421
|
function hasRollupSourceMaps(config) {
|
|
1422
|
-
return
|
|
1422
|
+
return /sourceMap\s*:\s*true\b/.test(config);
|
|
1423
|
+
}
|
|
1424
|
+
function canRepairRollupConfig(config) {
|
|
1425
|
+
return config.includes(ROLLUP_ARG_ONE_BOUNDARY);
|
|
1423
1426
|
}
|
|
1424
1427
|
function withRollupSourceMaps(config) {
|
|
1425
|
-
if (hasRollupSourceMaps(config) || !config
|
|
1428
|
+
if (hasRollupSourceMaps(config) || !canRepairRollupConfig(config)) {
|
|
1426
1429
|
return config;
|
|
1427
1430
|
}
|
|
1428
1431
|
const withCompiler = config.replace(GENERATED_COMPILER, () => SOURCE_MAP_CAPABLE_COMPILER);
|
|
@@ -1451,6 +1454,28 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
1451
1454
|
}
|
|
1452
1455
|
return changed;
|
|
1453
1456
|
}
|
|
1457
|
+
function resolveRequireTarget(fromDir, specifier) {
|
|
1458
|
+
const base = (0, import_node_path3.join)(fromDir, specifier);
|
|
1459
|
+
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
1460
|
+
}
|
|
1461
|
+
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
1462
|
+
if (visited.has(configPath)) {
|
|
1463
|
+
return "";
|
|
1464
|
+
}
|
|
1465
|
+
visited.add(configPath);
|
|
1466
|
+
let text;
|
|
1467
|
+
try {
|
|
1468
|
+
text = (0, import_node_fs3.readFileSync)(configPath, "utf8");
|
|
1469
|
+
} catch {
|
|
1470
|
+
return "";
|
|
1471
|
+
}
|
|
1472
|
+
const specifiers = Array.from(
|
|
1473
|
+
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
1474
|
+
(match) => match[2]
|
|
1475
|
+
);
|
|
1476
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path3.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
1477
|
+
return [text, ...requiredText].join("\n");
|
|
1478
|
+
}
|
|
1454
1479
|
var SOURCEMAP_PATH_TRANSFORM = [
|
|
1455
1480
|
" // Added by MoNecromanCI. rollup hands sourcemapPathTransform an OS-NATIVE",
|
|
1456
1481
|
" // path with one parent segment too many, so `sources` resolve to nothing",
|
|
@@ -3457,18 +3482,19 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
3457
3482
|
cwd: workspaceRoot
|
|
3458
3483
|
}).map((config) => toPosix2(config));
|
|
3459
3484
|
return configs.flatMap((relativePath) => {
|
|
3485
|
+
const configPath = (0, import_node_path14.join)(workspaceRoot, relativePath);
|
|
3460
3486
|
let config;
|
|
3461
3487
|
try {
|
|
3462
|
-
config = (0, import_node_fs8.readFileSync)(
|
|
3488
|
+
config = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3463
3489
|
} catch {
|
|
3464
3490
|
return [];
|
|
3465
3491
|
}
|
|
3466
3492
|
return [
|
|
3467
3493
|
{
|
|
3468
3494
|
check: `source maps enabled in ${relativePath}`,
|
|
3469
|
-
ok: hasRollupSourceMaps(
|
|
3495
|
+
ok: hasRollupSourceMaps(resolveRollupConfigText(configPath)),
|
|
3470
3496
|
detail: "rollup emits no .js.map without it, so a breakpoint in a .ts file can never bind",
|
|
3471
|
-
remedy: "run `mnci upgrade`, which adds it to every rollup config"
|
|
3497
|
+
remedy: canRepairRollupConfig(config) ? "run `mnci upgrade`, which adds it to every rollup config" : "this config delegates via require() to a shared base mnci does not own \u2014 add `sourceMap: true` to withNx's first argument there by hand; `mnci upgrade` cannot repair a config in this shape"
|
|
3472
3498
|
}
|
|
3473
3499
|
];
|
|
3474
3500
|
});
|