@savvy-web/tsdown-plugins 2.11.1 → 2.11.2
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/build/strip-maps.js +17 -18
- package/build/sync-public.js +18 -11
- package/index.d.ts +4 -0
- package/meta/scrub-declaration-maps.js +15 -12
- package/package.json +10 -10
- package/report/services/EnvironmentDetector.js +19 -9
package/build/strip-maps.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rmSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { Result } from "effect";
|
|
4
|
+
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
5
|
+
import { descendSync } from "@effected/walker";
|
|
6
|
+
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
3
7
|
|
|
4
8
|
// src/build/strip-maps.ts
|
|
9
|
+
/** `.d.ts.map` / `.d.cts.map` at any depth, dot-directories included. */
|
|
10
|
+
const STRIPPABLE_MAPS = Result.getOrThrow(GlobPattern.compileResult("**/*.d.{ts,cts}.map", GlobPatternOptions.make({ dot: true })));
|
|
5
11
|
/**
|
|
6
12
|
* Remove declaration source-map files (`.d.ts.map` / `.d.cts.map`) from a built `pkg`
|
|
7
13
|
* directory, returning the removed paths.
|
|
@@ -18,23 +24,16 @@ import { join } from "node:path";
|
|
|
18
24
|
* @public
|
|
19
25
|
*/
|
|
20
26
|
function removeDeclarationMaps(pkgDir) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (entry.isDirectory()) removed.push(...removeDeclarationMaps(full));
|
|
32
|
-
else if (entry.name.endsWith(".d.ts.map") || entry.name.endsWith(".d.cts.map")) {
|
|
33
|
-
rmSync(full, { force: true });
|
|
34
|
-
removed.push(full);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return removed;
|
|
27
|
+
return Result.getOrThrow(descendSync(STRIPPABLE_MAPS, {
|
|
28
|
+
cwd: pkgDir,
|
|
29
|
+
prune: ["node_modules"],
|
|
30
|
+
onUnreadable: "skip",
|
|
31
|
+
...nodeWalkerSyncOps
|
|
32
|
+
})).map((rel) => {
|
|
33
|
+
const full = join(pkgDir, rel);
|
|
34
|
+
rmSync(full, { force: true });
|
|
35
|
+
return full;
|
|
36
|
+
});
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export { removeDeclarationMaps };
|
package/build/sync-public.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { ConfigValidationError } from "../errors.js";
|
|
2
2
|
import { findRelativeSpecifiers } from "../dts/relative-imports.js";
|
|
3
|
-
import { copyFileSync, existsSync, mkdirSync, readFileSync,
|
|
4
|
-
import { dirname, join
|
|
3
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { Result } from "effect";
|
|
6
|
+
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
7
|
+
import { descendSync } from "@effected/walker";
|
|
8
|
+
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
5
9
|
|
|
6
10
|
// src/build/sync-public.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
/** Every file at any depth, dotfiles included. */
|
|
12
|
+
const EVERY_FILE = Result.getOrThrow(GlobPattern.compileResult("**", GlobPatternOptions.make({ dot: true })));
|
|
13
|
+
/**
|
|
14
|
+
* Every file path under `dir`, relative to it (POSIX separators, sorted). Nothing is pruned, so a
|
|
15
|
+
* `public/.well-known/` or `public/node_modules/` asset still copies; symlinked directories are not entered.
|
|
16
|
+
*/
|
|
17
|
+
function listFilesRel(dir) {
|
|
18
|
+
return Result.getOrThrow(descendSync(EVERY_FILE, {
|
|
19
|
+
cwd: dir,
|
|
20
|
+
prune: [],
|
|
21
|
+
...nodeWalkerSyncOps
|
|
22
|
+
}));
|
|
16
23
|
}
|
|
17
24
|
/** True when both files exist with identical size and bytes. Size is checked first so the byte read is skipped for the common changed case. */
|
|
18
25
|
function sameBytes(a, b) {
|
package/index.d.ts
CHANGED
|
@@ -2023,6 +2023,10 @@ declare const EnvironmentDetector_base: Context.ServiceClass<EnvironmentDetector
|
|
|
2023
2023
|
}>;
|
|
2024
2024
|
/** @public */
|
|
2025
2025
|
export declare class EnvironmentDetector extends EnvironmentDetector_base {
|
|
2026
|
+
/**
|
|
2027
|
+
* Detects from `@effected/env`'s `CurrentRuntimeEnv`, read through the ambient `ConfigProvider` (the process
|
|
2028
|
+
* environment by default) once, when the layer is built.
|
|
2029
|
+
*/
|
|
2026
2030
|
static readonly layer: Layer.Layer<EnvironmentDetector>;
|
|
2027
2031
|
}
|
|
2028
2032
|
/** @public */
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { readFileSync,
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { Result } from "effect";
|
|
4
|
+
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
5
|
+
import { descendSync } from "@effected/walker";
|
|
6
|
+
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
3
7
|
import { decode, encode } from "@jridgewell/sourcemap-codec";
|
|
4
8
|
|
|
5
9
|
// src/meta/scrub-declaration-maps.ts
|
|
10
|
+
/** Every declaration map, at any depth, dot-directories included. */
|
|
11
|
+
const DECLARATION_MAPS = Result.getOrThrow(GlobPattern.compileResult("**/*.d.{ts,cts,mts}.map", GlobPatternOptions.make({ dot: true })));
|
|
6
12
|
/**
|
|
7
13
|
* Drop every source-less segment (a generated position with no original position) from a
|
|
8
14
|
* declaration map, in place. Returns the number of segments removed.
|
|
@@ -42,18 +48,15 @@ function scrubSourcelessMappings(mapPath) {
|
|
|
42
48
|
* @internal
|
|
43
49
|
*/
|
|
44
50
|
function scrubDeclarationMapsUnder(dir) {
|
|
51
|
+
const maps = Result.getOrThrow(descendSync(DECLARATION_MAPS, {
|
|
52
|
+
cwd: dir,
|
|
53
|
+
prune: [],
|
|
54
|
+
followSymlinks: true,
|
|
55
|
+
onUnreadable: "skip",
|
|
56
|
+
...nodeWalkerSyncOps
|
|
57
|
+
}));
|
|
45
58
|
let removed = 0;
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
entries = readdirSync(dir);
|
|
49
|
-
} catch {
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
for (const name of entries) {
|
|
53
|
-
const p = join(dir, name);
|
|
54
|
-
if (statSync(p).isDirectory()) removed += scrubDeclarationMapsUnder(p);
|
|
55
|
-
else if (/\.d\.[cm]?ts\.map$/.test(name)) removed += scrubSourcelessMappings(p);
|
|
56
|
-
}
|
|
59
|
+
for (const rel of maps) removed += scrubSourcelessMappings(join(dir, rel));
|
|
57
60
|
return removed;
|
|
58
61
|
}
|
|
59
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/tsdown-plugins",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interface-only tsdown/rolldown plugin pack powering @savvy-web/bundler",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/tsdown-plugins",
|
|
@@ -31,15 +31,16 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@changesets/get-release-plan": "^5.0.2",
|
|
33
33
|
"@effect/platform-node": "^4.0.6",
|
|
34
|
-
"@effected/
|
|
35
|
-
"@effected/
|
|
36
|
-
"@effected/
|
|
37
|
-
"@effected/
|
|
38
|
-
"@effected/
|
|
34
|
+
"@effected/env": "^0.6.0",
|
|
35
|
+
"@effected/glob": "^0.15.0",
|
|
36
|
+
"@effected/images": "^0.6.2",
|
|
37
|
+
"@effected/jsonc": "^0.20.1",
|
|
38
|
+
"@effected/npm": "^0.27.1",
|
|
39
|
+
"@effected/package-json": "^0.26.1",
|
|
39
40
|
"@effected/semver": "^0.18.0",
|
|
40
|
-
"@effected/tsconfig-json": "^0.17.
|
|
41
|
-
"@effected/walker": "^0.
|
|
42
|
-
"@effected/workspaces": "^0.39.
|
|
41
|
+
"@effected/tsconfig-json": "^0.17.4",
|
|
42
|
+
"@effected/walker": "^0.21.0",
|
|
43
|
+
"@effected/workspaces": "^0.39.1",
|
|
43
44
|
"@jridgewell/sourcemap-codec": "^1.6.0",
|
|
44
45
|
"@microsoft/api-extractor": "^7.59.4",
|
|
45
46
|
"@microsoft/tsdoc": "~0.17.1",
|
|
@@ -47,7 +48,6 @@
|
|
|
47
48
|
"@tsdoctor/manifest": "^0.2.10",
|
|
48
49
|
"effect": "^4.0.6",
|
|
49
50
|
"picocolors": "^1.1.1",
|
|
50
|
-
"std-env": "^4.3.0",
|
|
51
51
|
"tsdown": "^0.23.2",
|
|
52
52
|
"typescript": "7.1.0-beta"
|
|
53
53
|
}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import {
|
|
1
|
+
import { Context, Effect, Layer, Option } from "effect";
|
|
2
|
+
import { CurrentRuntimeEnv } from "@effected/env";
|
|
3
3
|
|
|
4
4
|
// src/report/services/EnvironmentDetector.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Classify a runtime snapshot: an agent wins over CI, GitHub Actions is told apart from every other CI, and the
|
|
7
|
+
* human terminal is the default.
|
|
8
|
+
*/
|
|
9
|
+
const classify = (env) => {
|
|
10
|
+
if (Option.isSome(env.agent)) return "agent-shell";
|
|
11
|
+
if (Option.isSome(env.ci)) return env.ci.value === "github-actions" ? "ci-github" : "ci-generic";
|
|
12
|
+
return "terminal";
|
|
13
|
+
};
|
|
6
14
|
/** @public */
|
|
7
15
|
var EnvironmentDetector = class extends Context.Service()("@savvy-web/tsdown-plugins/EnvironmentDetector") {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Detects from `@effected/env`'s `CurrentRuntimeEnv`, read through the ambient `ConfigProvider` (the process
|
|
18
|
+
* environment by default) once, when the layer is built.
|
|
19
|
+
*/
|
|
20
|
+
static layer = Layer.effect(this, Effect.map(CurrentRuntimeEnv, (env) => {
|
|
21
|
+
const environment = classify(env);
|
|
22
|
+
return { detect: () => Effect.succeed(environment) };
|
|
23
|
+
})).pipe(Layer.provide(CurrentRuntimeEnv.layer));
|
|
14
24
|
};
|
|
15
25
|
|
|
16
26
|
export { EnvironmentDetector };
|