@effected/bundler 0.4.1 → 0.5.0
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/Bundler.js +30 -27
- package/catalog/resolve-catalogs.js +6 -13
- package/changesets/next-versions.js +16 -22
- package/dts/bundled-siblings.js +38 -42
- package/dts/resolved-tsconfig.js +44 -53
- package/entries/package-json-entries.js +2 -5
- package/index.d.ts +56 -28
- package/internal/exists.js +14 -0
- package/internal/native-realpath.js +15 -0
- package/manifest/emit-manifest.js +53 -28
- package/meta/api-extractor.js +42 -32
- package/meta/bundle-source.js +42 -58
- package/meta/generate.js +92 -101
- package/meta/og-image.js +29 -35
- package/meta/og-satori.js +10 -4
- package/meta/run-pass.js +44 -40
- package/meta/scrub-declaration-maps.js +16 -18
- package/meta/tsconfig-resolver.js +9 -16
- package/meta/tsdoc-config.js +6 -10
- package/package.json +2 -2
- package/passes/build-target-groups.js +97 -75
- package/passes/bundled-deps.js +62 -0
- package/passes/stamp-versions.js +121 -0
- package/passes/sync-public.js +52 -53
- package/passes/third-party-licenses.js +102 -0
- package/tsconfig/sync-options.js +0 -20
package/index.d.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
import { BUNDLE_MANIFEST_FILENAME, BundleManifest, BundleManifest as BundleManifest$1, BundleManifestError, KNOWN_REGISTRY_TYPES, KnownRegistryType, MANIFEST_SPEC, ManifestSource, ManifestSource as ManifestSource$1, OpenGraphConfig, OpenGraphImage, OpenGraphImage as OpenGraphImage$1, ProjectIdentity, RegistryRef, RegistryRef as RegistryRef$1, SbomRef, decodeBundleManifest, decodeManifestSource, encodeBundleManifest, isKnownRegistryType } from "@effected/manifest";
|
|
10
|
-
import { Context, Effect, FileSystem, Layer, Path, PlatformError, Schema } from "effect";
|
|
10
|
+
import { Cause, Context, Effect, FileSystem, Layer, Path, PlatformError, Schema } from "effect";
|
|
11
11
|
import { Plugin } from "rolldown";
|
|
12
|
+
import { DescendError } from "@effected/walker";
|
|
13
|
+
import { CatalogAssemblyError, DependencyResolutionError, ManifestDecodeError, UnresolvedDependencyError } from "@effected/npm";
|
|
12
14
|
import { WorkspaceDiscovery } from "@effected/workspaces";
|
|
13
15
|
import { AppendError, JournalWatcher, JsonlEvent } from "@effected/jsonl";
|
|
14
|
-
import { DescendError } from "@effected/walker";
|
|
15
16
|
declare const ActionWorker_base: Schema.Class<ActionWorker, Schema.Struct<{
|
|
16
17
|
/** The worker's source, relative to the package. */
|
|
17
18
|
readonly source: Schema.String;
|
|
@@ -1659,7 +1660,7 @@ interface MetaResult {
|
|
|
1659
1660
|
readonly apiJsonPath: string;
|
|
1660
1661
|
readonly apiJsonFilename: string;
|
|
1661
1662
|
}
|
|
1662
|
-
declare const BundleManifestSourceError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) =>
|
|
1663
|
+
declare const BundleManifestSourceError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
1663
1664
|
readonly _tag: "BundleManifestSourceError";
|
|
1664
1665
|
} & Readonly<A>;
|
|
1665
1666
|
/**
|
|
@@ -1696,13 +1697,13 @@ interface BundleManifestSources {
|
|
|
1696
1697
|
}
|
|
1697
1698
|
/**
|
|
1698
1699
|
* Read the leaf (`<cwd>/bundle.json`) and project (`<workspaceRoot>/bundle.json`)
|
|
1699
|
-
* source tiers. Absence is normal; a present file that does not decode
|
|
1700
|
+
* source tiers. Absence is normal; a present file that does not decode fails
|
|
1700
1701
|
* {@link BundleManifestSourceError}. A package that IS the workspace root reads its file once, as the
|
|
1701
1702
|
* leaf, and has no project tier.
|
|
1702
1703
|
*
|
|
1703
1704
|
* @public
|
|
1704
1705
|
*/
|
|
1705
|
-
export declare
|
|
1706
|
+
export declare const loadBundleManifestSources: (cwd: string) => Effect.Effect<BundleManifestSources, BundleManifestSourceError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
1706
1707
|
/**
|
|
1707
1708
|
* Options for the meta-pass orchestrator.
|
|
1708
1709
|
*
|
|
@@ -2357,9 +2358,12 @@ interface BuildTargetGroupsOptions {
|
|
|
2357
2358
|
* node_modules dependency to its own sibling file (mirroring its `node_modules/...` path),
|
|
2358
2359
|
* which `npm pack` then strips, breaking the "self-contained" promise `bundleNodeModules`
|
|
2359
2360
|
* already makes. Scoped to that flag alone; every other build's JS pass is unaffected.
|
|
2361
|
+
*
|
|
2362
|
+
* The bundler's own reads and writes (the manifest, the tsconfigs, the stubs, `public/`) go through `FileSystem` and
|
|
2363
|
+
* `Path`; tsdown always works on the host disk. A tsdown rejection is a defect, carrying the thrown value.
|
|
2360
2364
|
* @public
|
|
2361
2365
|
*/
|
|
2362
|
-
export declare
|
|
2366
|
+
export declare const buildTargetGroups: (options: BuildTargetGroupsOptions) => Effect.Effect<void, ConfigValidationError | PlatformError.PlatformError | DescendError, FileSystem.FileSystem | Path.Path>;
|
|
2363
2367
|
/**
|
|
2364
2368
|
* Which release versions a target receives: every version, only final versions, or only prereleases.
|
|
2365
2369
|
*
|
|
@@ -2583,6 +2587,12 @@ interface ManifestLike {
|
|
|
2583
2587
|
optionalDependencies?: Record<string, string>;
|
|
2584
2588
|
[k: string]: unknown;
|
|
2585
2589
|
}
|
|
2590
|
+
/**
|
|
2591
|
+
* The failures of {@link resolveManifest}.
|
|
2592
|
+
*
|
|
2593
|
+
* @public
|
|
2594
|
+
*/
|
|
2595
|
+
type ResolveManifestError = ManifestDecodeError | CatalogAssemblyError | DependencyResolutionError | UnresolvedDependencyError;
|
|
2586
2596
|
/**
|
|
2587
2597
|
* Resolve every `catalog:`/`workspace:` specifier in a manifest to a concrete spec,
|
|
2588
2598
|
* delegating to `@effected/workspaces`' one-shot `Workspaces.resolveManifest`. The
|
|
@@ -2591,13 +2601,13 @@ interface ManifestLike {
|
|
|
2591
2601
|
* config-dependency hook-replay + lockfile), so no transient
|
|
2592
2602
|
* `.pnpm-workspace-state-v1.json` is required.
|
|
2593
2603
|
*
|
|
2594
|
-
*
|
|
2604
|
+
* Fails with `ManifestDecodeError` when a dependency field is not a string-to-string
|
|
2595
2605
|
* record, `UnresolvedDependencyError` on a specifier the workspace cannot answer, or
|
|
2596
2606
|
* `CatalogAssemblyError`/`DependencyResolutionError` when catalog assembly or the
|
|
2597
2607
|
* resolution mechanism itself fails.
|
|
2598
2608
|
* @public
|
|
2599
2609
|
*/
|
|
2600
|
-
export declare
|
|
2610
|
+
export declare const resolveManifest: (pkg: ManifestLike, cwd: string) => Effect.Effect<ManifestLike, ResolveManifestError, FileSystem.FileSystem | Path.Path>;
|
|
2601
2611
|
/**
|
|
2602
2612
|
* Result of resolving next release versions for a workspace.
|
|
2603
2613
|
*
|
|
@@ -2615,12 +2625,12 @@ interface NextVersions {
|
|
|
2615
2625
|
* Walks up from `cwd` to the monorepo root via `@effected/workspaces`' `WorkspaceDiscovery`,
|
|
2616
2626
|
* seeds the map with each package's CURRENT version, then overlays `newVersion` for
|
|
2617
2627
|
* changeset-affected packages via `ReleasePlan.read`, including pre-release versions in pre
|
|
2618
|
-
* mode and fixed or linked groups. Never
|
|
2628
|
+
* mode and fixed or linked groups. Never fails: any failure (not a workspace, missing
|
|
2619
2629
|
* `.changeset/config.json`, an invalid config or `pre.json`, parse error) degrades to current
|
|
2620
2630
|
* versions (or an empty map).
|
|
2621
2631
|
* @public
|
|
2622
2632
|
*/
|
|
2623
|
-
export declare
|
|
2633
|
+
export declare const resolveNextVersions: (cwd: string) => Effect.Effect<NextVersions, never, FileSystem.FileSystem | Path.Path>;
|
|
2624
2634
|
declare const EffectedConfigError_base: Schema.Class<EffectedConfigError, Schema.TaggedStruct<"EffectedConfigError", {
|
|
2625
2635
|
/** The file at fault. */
|
|
2626
2636
|
readonly path: Schema.String;
|
|
@@ -2851,7 +2861,7 @@ interface ResolvedTsconfig {
|
|
|
2851
2861
|
*
|
|
2852
2862
|
* @remarks
|
|
2853
2863
|
* Resolves the package's own `<cwd>/tsconfig.json` (which extends the shared
|
|
2854
|
-
* `ecma.json` base) through `@effected/tsconfig-json`'s `
|
|
2864
|
+
* `ecma.json` base) through `@effected/tsconfig-json`'s `TsconfigLoader`, so the
|
|
2855
2865
|
* result carries the package's real effective options — target, module, lib, strict,
|
|
2856
2866
|
* jsx — with `${configDir}` already substituted to absolute paths. Only the dts-pass
|
|
2857
2867
|
* overlay (composite/incremental/tsBuildInfoFile forced off, declarationMap forced on)
|
|
@@ -2863,13 +2873,13 @@ interface ResolvedTsconfig {
|
|
|
2863
2873
|
*
|
|
2864
2874
|
* @public
|
|
2865
2875
|
*/
|
|
2866
|
-
export declare
|
|
2876
|
+
export declare const buildResolvedTsconfig: (options: ResolvedTsconfigOptions) => Effect.Effect<ResolvedTsconfig, Error, FileSystem.FileSystem | Path.Path>;
|
|
2867
2877
|
/**
|
|
2868
2878
|
* Write the resolved tsconfig to a temp file and return its absolute path.
|
|
2869
2879
|
*
|
|
2870
2880
|
* @public
|
|
2871
2881
|
*/
|
|
2872
|
-
export declare
|
|
2882
|
+
export declare const writeResolvedTsconfig: (options: ResolvedTsconfigOptions) => Effect.Effect<string, Error | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
2873
2883
|
/**
|
|
2874
2884
|
* What a dts-emit tsconfig adds for one partition.
|
|
2875
2885
|
*
|
|
@@ -2907,7 +2917,7 @@ interface DtsEmitTsconfigOptions {
|
|
|
2907
2917
|
* manifest says, never through a typecheck-only condition or path alias that would pull source files into the
|
|
2908
2918
|
* emitted declarations. The one exception is `options.paths`, the bundled workspace siblings resolved to their built
|
|
2909
2919
|
* declarations, which is the only `paths` map this file ever carries. The only reader of this file is the tsgo
|
|
2910
|
-
* declaration generator; nothing in the bundler reads it back through the kit's `
|
|
2920
|
+
* declaration generator; nothing in the bundler reads it back through the kit's `TsconfigLoader`, which rejects
|
|
2911
2921
|
* `null` compiler options.
|
|
2912
2922
|
*
|
|
2913
2923
|
* Best-effort: if the base tsconfig cannot be read or parsed (e.g. a synthetic test path that was
|
|
@@ -2916,7 +2926,7 @@ interface DtsEmitTsconfigOptions {
|
|
|
2916
2926
|
*
|
|
2917
2927
|
* @public
|
|
2918
2928
|
*/
|
|
2919
|
-
export declare
|
|
2929
|
+
export declare const writeDtsEmitTsconfig: (resolvedTsconfigPath: string, options?: DtsEmitTsconfigOptions) => Effect.Effect<string, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
2920
2930
|
/** @public */
|
|
2921
2931
|
interface PackageJsonLike {
|
|
2922
2932
|
readonly exports?: unknown;
|
|
@@ -3010,17 +3020,15 @@ export declare function assertNoEntryCollisions(jsEntryNames: ReadonlyArray<stri
|
|
|
3010
3020
|
export declare function deriveExportPaths(entries: Record<string, string>, exportsMap: Record<string, string> | undefined): Record<string, string>;
|
|
3011
3021
|
/** @public */
|
|
3012
3022
|
interface PackageJsonEntriesOptions extends ExtractOptions {
|
|
3013
|
-
/**
|
|
3014
|
-
readonly pkg
|
|
3015
|
-
/** Working directory for reading package.json. Defaults to process.cwd(). */
|
|
3016
|
-
readonly cwd?: string;
|
|
3023
|
+
/** The package.json to derive entries from, already read. */
|
|
3024
|
+
readonly pkg: PackageJsonLike;
|
|
3017
3025
|
}
|
|
3018
3026
|
/**
|
|
3019
3027
|
* Derive a tsdown `entry` record (name to source path) from a package.json.
|
|
3020
3028
|
*
|
|
3021
3029
|
* @public
|
|
3022
3030
|
*/
|
|
3023
|
-
export declare function packageJsonEntries(options
|
|
3031
|
+
export declare function packageJsonEntries(options: PackageJsonEntriesOptions): Record<string, string>;
|
|
3024
3032
|
/**
|
|
3025
3033
|
* The exact filename `@tsdown/exe` emits for a SEA target, mirroring tsdown's
|
|
3026
3034
|
* `resolveOutputFileName`: base fileName + `-<platform>-<arch>` + `.exe` on win.
|
|
@@ -3279,6 +3287,11 @@ interface BuildEmittedManifestOptions {
|
|
|
3279
3287
|
readonly exeRewrite?: ExeRewrite | undefined;
|
|
3280
3288
|
/** Whether the dts pass ran; `false` omits `types` conditions from the emitted manifest (issue #198). Defaults to `true`. */
|
|
3281
3289
|
readonly emitDts?: boolean | undefined;
|
|
3290
|
+
/**
|
|
3291
|
+
* Whether the JS pass inlined a package by `bundle` in every partition. Such a package is removed from the emitted
|
|
3292
|
+
* `dependencies` and `optionalDependencies`, since the published files already hold its code.
|
|
3293
|
+
*/
|
|
3294
|
+
readonly bundled?: ((name: string) => boolean) | undefined;
|
|
3282
3295
|
}
|
|
3283
3296
|
/**
|
|
3284
3297
|
* Whether any of `pkg`'s four dependency fields carries at least one `catalog:`/`workspace:`
|
|
@@ -3293,7 +3306,7 @@ export declare function manifestNeedsCatalogResolution(pkg: Json): boolean;
|
|
|
3293
3306
|
*
|
|
3294
3307
|
* @public
|
|
3295
3308
|
*/
|
|
3296
|
-
export declare
|
|
3309
|
+
export declare const buildEmittedManifest: (options: BuildEmittedManifestOptions) => Effect.Effect<Json, ConfigValidationError | ResolveManifestError, FileSystem.FileSystem | Path.Path>;
|
|
3297
3310
|
/** @public */
|
|
3298
3311
|
interface EmitManifestOptions {
|
|
3299
3312
|
readonly targetGroup: TargetGroupRef;
|
|
@@ -3312,13 +3325,22 @@ interface EmitManifestOptions {
|
|
|
3312
3325
|
readonly exeRewrite?: ExeRewrite | undefined;
|
|
3313
3326
|
/** Whether the dts pass ran; `false` omits `types` conditions from the emitted manifest (issue #198). Defaults to `true`. */
|
|
3314
3327
|
readonly emitDts?: boolean | undefined;
|
|
3328
|
+
/**
|
|
3329
|
+
* Whether the JS pass inlined a package by `bundle` in every partition. Such a package is removed from the emitted
|
|
3330
|
+
* `dependencies` and `optionalDependencies`, since the published files already hold its code.
|
|
3331
|
+
*/
|
|
3332
|
+
readonly bundled?: ((name: string) => boolean) | undefined;
|
|
3315
3333
|
}
|
|
3316
3334
|
/**
|
|
3317
3335
|
* Rolldown plugin: emit the transformed package.json + LICENSE/README into the output pkg/ root.
|
|
3318
3336
|
*
|
|
3337
|
+
* @remarks
|
|
3338
|
+
* rolldown calls `generateBundle` as a plain async hook, so the plugin captures the `FileSystem` and `Path` it is
|
|
3339
|
+
* built under and runs its reads with them.
|
|
3340
|
+
*
|
|
3319
3341
|
* @public
|
|
3320
3342
|
*/
|
|
3321
|
-
export declare
|
|
3343
|
+
export declare const emitManifest: (options: EmitManifestOptions) => Effect.Effect<Plugin, never, FileSystem.FileSystem | Path.Path>;
|
|
3322
3344
|
declare const OgGenerateError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3323
3345
|
readonly _tag: "OgGenerateError";
|
|
3324
3346
|
} & Readonly<A>;
|
|
@@ -3385,7 +3407,7 @@ interface WriteGeneratedOgImageOptions {
|
|
|
3385
3407
|
*
|
|
3386
3408
|
* @public
|
|
3387
3409
|
*/
|
|
3388
|
-
export declare
|
|
3410
|
+
export declare const writeGeneratedOgImage: (options: WriteGeneratedOgImageOptions) => Effect.Effect<OpenGraphImage$1, OgGenerateError, FileSystem.FileSystem | Path.Path>;
|
|
3389
3411
|
/**
|
|
3390
3412
|
* Rewrite a meta `package.json` so the package's own `version` and any workspace-sibling
|
|
3391
3413
|
* dependency version reflect their NEXT release version from `versions`. Pure: returns a new
|
|
@@ -3428,7 +3450,7 @@ interface PortableTsconfig {
|
|
|
3428
3450
|
* @remarks
|
|
3429
3451
|
* Resolves the package's own `<cwd>/tsconfig.json` (which extends the shared
|
|
3430
3452
|
* `@effected/plugin/tsconfig/ecma.json` base) via `@effected/tsconfig-json`'s
|
|
3431
|
-
*
|
|
3453
|
+
* `TsconfigLoader` (tsc-parity `extends` resolution) so the
|
|
3432
3454
|
* result carries the full effective options (target/module/strict/jsx/lib),
|
|
3433
3455
|
* then projects them through the kit's `PortableTsconfig.make` allow-list
|
|
3434
3456
|
* filter to a portable, compilerOptions-only shape with no absolute paths or
|
|
@@ -3445,7 +3467,7 @@ interface PortableTsconfig {
|
|
|
3445
3467
|
*
|
|
3446
3468
|
* @public
|
|
3447
3469
|
*/
|
|
3448
|
-
export declare
|
|
3470
|
+
export declare const resolvePortableTsconfig: (cwd: string, fallbackConfigPath?: string) => Effect.Effect<PortableTsconfig, Error, FileSystem.FileSystem | Path.Path>;
|
|
3449
3471
|
/**
|
|
3450
3472
|
* Rolldown plugin: append the CJS default-interop footer to ENTRY chunks of the
|
|
3451
3473
|
* `cjs` format that export a default alongside named exports.
|
|
@@ -3527,6 +3549,12 @@ export declare function nodeBuiltinDefaultInterop(): Plugin;
|
|
|
3527
3549
|
* @public
|
|
3528
3550
|
*/
|
|
3529
3551
|
export declare const removeDeclarationMaps: (pkgDir: string) => Effect.Effect<ReadonlyArray<string>, DescendError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
3552
|
+
/**
|
|
3553
|
+
* The failures of {@link copyPublicDir}: a collision, a walk failure, or an IO failure the guard does not own.
|
|
3554
|
+
*
|
|
3555
|
+
* @public
|
|
3556
|
+
*/
|
|
3557
|
+
type CopyPublicDirError = ConfigValidationError | DescendError | PlatformError.PlatformError;
|
|
3530
3558
|
/**
|
|
3531
3559
|
* Copy the CONTENTS of `sourceDir` into `outDir`, additively.
|
|
3532
3560
|
*
|
|
@@ -3543,7 +3571,7 @@ export declare const removeDeclarationMaps: (pkgDir: string) => Effect.Effect<Re
|
|
|
3543
3571
|
* {@link ConfigValidationError} rather than clobbering it or surfacing a raw fs error.
|
|
3544
3572
|
* @public
|
|
3545
3573
|
*/
|
|
3546
|
-
export declare
|
|
3574
|
+
export declare const copyPublicDir: (sourceDir: string, outDir: string) => Effect.Effect<void, CopyPublicDirError, FileSystem.FileSystem | Path.Path>;
|
|
3547
3575
|
/** @public */
|
|
3548
3576
|
interface CopyAmbientDtsOptions {
|
|
3549
3577
|
/** The ambient exports to copy (from `extractAmbientDts`). */
|
|
@@ -3562,7 +3590,7 @@ interface CopyAmbientDtsOptions {
|
|
|
3562
3590
|
* Throws {@link ConfigValidationError} on a missing source or any relative specifier.
|
|
3563
3591
|
* @public
|
|
3564
3592
|
*/
|
|
3565
|
-
export declare
|
|
3593
|
+
export declare const copyAmbientDts: (options: CopyAmbientDtsOptions) => Effect.Effect<void, ConfigValidationError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
3566
3594
|
/**
|
|
3567
3595
|
* Render a build report as GitHub Actions workflow-command annotations, one `::error` or `::warning`
|
|
3568
3596
|
* line per diagnostic. Suppressed diagnostics are never annotated. Pure.
|
|
@@ -3648,5 +3676,5 @@ export declare function resolveTargets(options: {
|
|
|
3648
3676
|
* @public
|
|
3649
3677
|
*/
|
|
3650
3678
|
export declare function releaseWarnings(resolution: TargetResolution): ReadonlyArray<string>;
|
|
3651
|
-
export { type ActionBuilderError, type ActionBuilderOptions, type ActionValidationRunOptions, type AmbientDtsEntry, BUNDLE_MANIFEST_FILENAME, type BuildEmittedManifestOptions, type BuildFormat$1 as BuildFormatOption, type BuildGroupSpec, type BuildIssues, type BuildPlatform$1 as BuildPlatformOption, type BuildTargetGroupsOptions, BundleManifest, BundleManifestError, type BundleManifestSources, type BundleMetaOptions, type BundlerBuildOptions, type BundlerPackageJson, type BundlerSeams, type ComposeManifestInput, type CopyAmbientDtsOptions, type CssOptions, type DeriveOptions, type DerivedDeclarationsPassOptions, type DerivedDtsPassOptions, type DerivedTsdownOptions, type DiagnosticInput, type DtsEmitTsconfigOptions, type DtsExportClass, type DtsPassDtsOptions, type DualExports, type EmitManifestOptions, type EntryOverride$1 as EntryOverrideOptions, type ExeBuild, type ExeConfig$1 as ExeOptions, type ExeRewrite, type ExeSeaConfig$1 as ExeSeaOptions, type ExeTarget, type ExeTargetInput, type ExtractAmbientOptions, type ExtractOptions, type ExtractResult, type GenerateMetaOptions, type Json, KNOWN_REGISTRY_TYPES, type KnownRegistryType, type LooseFileSpec as LooseFileOptions, LooseFileSpec$1 as LooseFileSpec, type LooseFiles, MANIFEST_SPEC, type ManifestLike, type ManifestRepository, ManifestSource, type ManifestTarget, type MetaOptions, type MetaResult, type TsdocTagDefinition as MetaTsdocTagDefinition, type WarningSuppressionRule as MetaWarningSuppressionRule, type ModuleExportNames, type NextVersions, type NormalizedExe, type NormalizedLooseFile, type NormalizedMeta, type OgImageCacheOptions, type OgImageGenerator, type OgImageInfo, OpenGraphConfig, OpenGraphImage, type PackageJsonEntriesOptions, type PackageJsonLike, type PassKind, type PkgOsCpu, type PlainDiagnostic, type PortableTsconfig, ProjectIdentity, type PublishTargetObject, type PublishTargetValue, type PublishTargets, type ReexportBarrelAnalysis, RegistryRef, type ReleaseChannel, type ResolvedCompilerOptions, type ResolvedGroup, type JsxConfig$1 as ResolvedJsxConfig, type ResolvedTarget, type ResolvedTsconfig, type ResolvedTsconfigOptions, type RunExeBuildOptions, type RunMetaPassOptions, SbomRef, type TargetGroupId, type TargetGroupRef, type TargetResolution, type Timer, type TransformManifestOptions, type TsconfigJsx, type TsdocOptions, TsdocTagDefinition$1 as TsdocTagDefinition, type TsdownBuild, type TsdownLogger, type ValidationInput, WarningSuppressionRule$1 as WarningSuppressionRule, type WriteGeneratedOgImageOptions, decodeBundleManifest, decodeManifestSource, encodeBundleManifest, isKnownRegistryType };
|
|
3679
|
+
export { type ActionBuilderError, type ActionBuilderOptions, type ActionValidationRunOptions, type AmbientDtsEntry, BUNDLE_MANIFEST_FILENAME, type BuildEmittedManifestOptions, type BuildFormat$1 as BuildFormatOption, type BuildGroupSpec, type BuildIssues, type BuildPlatform$1 as BuildPlatformOption, type BuildTargetGroupsOptions, BundleManifest, BundleManifestError, type BundleManifestSources, type BundleMetaOptions, type BundlerBuildOptions, type BundlerPackageJson, type BundlerSeams, type ComposeManifestInput, type CopyAmbientDtsOptions, type CopyPublicDirError, type CssOptions, type DeriveOptions, type DerivedDeclarationsPassOptions, type DerivedDtsPassOptions, type DerivedTsdownOptions, type DiagnosticInput, type DtsEmitTsconfigOptions, type DtsExportClass, type DtsPassDtsOptions, type DualExports, type EmitManifestOptions, type EntryOverride$1 as EntryOverrideOptions, type ExeBuild, type ExeConfig$1 as ExeOptions, type ExeRewrite, type ExeSeaConfig$1 as ExeSeaOptions, type ExeTarget, type ExeTargetInput, type ExtractAmbientOptions, type ExtractOptions, type ExtractResult, type GenerateMetaOptions, type Json, KNOWN_REGISTRY_TYPES, type KnownRegistryType, type LooseFileSpec as LooseFileOptions, LooseFileSpec$1 as LooseFileSpec, type LooseFiles, MANIFEST_SPEC, type ManifestLike, type ManifestRepository, ManifestSource, type ManifestTarget, type MetaOptions, type MetaResult, type TsdocTagDefinition as MetaTsdocTagDefinition, type WarningSuppressionRule as MetaWarningSuppressionRule, type ModuleExportNames, type NextVersions, type NormalizedExe, type NormalizedLooseFile, type NormalizedMeta, type OgImageCacheOptions, type OgImageGenerator, type OgImageInfo, OpenGraphConfig, OpenGraphImage, type PackageJsonEntriesOptions, type PackageJsonLike, type PassKind, type PkgOsCpu, type PlainDiagnostic, type PortableTsconfig, ProjectIdentity, type PublishTargetObject, type PublishTargetValue, type PublishTargets, type ReexportBarrelAnalysis, RegistryRef, type ReleaseChannel, type ResolveManifestError, type ResolvedCompilerOptions, type ResolvedGroup, type JsxConfig$1 as ResolvedJsxConfig, type ResolvedTarget, type ResolvedTsconfig, type ResolvedTsconfigOptions, type RunExeBuildOptions, type RunMetaPassOptions, SbomRef, type TargetGroupId, type TargetGroupRef, type TargetResolution, type Timer, type TransformManifestOptions, type TsconfigJsx, type TsdocOptions, TsdocTagDefinition$1 as TsdocTagDefinition, type TsdownBuild, type TsdownLogger, type ValidationInput, WarningSuppressionRule$1 as WarningSuppressionRule, type WriteGeneratedOgImageOptions, decodeBundleManifest, decodeManifestSource, encodeBundleManifest, isKnownRegistryType };
|
|
3652
3680
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect, FileSystem } from "effect";
|
|
2
|
+
|
|
3
|
+
// src/internal/exists.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether a path exists, with `existsSync`'s semantics: every error reads as absent. `FileSystem.exists` answers
|
|
6
|
+
* `false` only for `NotFound` and fails on the rest, so a parent segment that is a file (`ENOTDIR`, a `BadResource`)
|
|
7
|
+
* or a denied `access` (`EACCES`) would surface where the ported code read "not there". The one place that rule
|
|
8
|
+
* lives; a site that wants the stricter answer calls `FileSystem.exists` itself.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const existsLikeNode = (path) => Effect.flatMap(FileSystem.FileSystem, (fs) => fs.exists(path)).pipe(Effect.orElseSucceed(() => false));
|
|
13
|
+
|
|
14
|
+
export { existsLikeNode };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
// src/internal/native-realpath.ts
|
|
5
|
+
/**
|
|
6
|
+
* The host's realpath(3) of `path`, failing with whatever `realpathSync.native` throws.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const nativeRealPath = (path) => Effect.try({
|
|
11
|
+
try: () => realpathSync.native(path),
|
|
12
|
+
catch: (cause) => cause
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { nativeRealPath };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { resolveManifest } from "../catalog/resolve-catalogs.js";
|
|
2
|
+
import { pruneBundled } from "../passes/bundled-deps.js";
|
|
2
3
|
import { stripBuiltCondition } from "./built-condition.js";
|
|
3
4
|
import { applyManifestSet, validateManifestSet } from "./manifest-set.js";
|
|
4
5
|
import { defaultManifestTransform, transformManifest } from "./transform.js";
|
|
5
|
-
import {
|
|
6
|
-
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
7
7
|
import { DependencySpecifier } from "@effected/npm";
|
|
8
8
|
|
|
9
9
|
// src/manifest/emit-manifest.ts
|
|
@@ -32,13 +32,17 @@ function manifestNeedsCatalogResolution(pkg) {
|
|
|
32
32
|
*
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
const buildEmittedManifest = Effect.fnUntraced(function* (options) {
|
|
36
36
|
const { cwd, targetGroup, devManifest, drop, set } = options;
|
|
37
|
-
if (set !== void 0)
|
|
37
|
+
if (set !== void 0) yield* Effect.try({
|
|
38
|
+
try: () => validateManifestSet(set, drop ?? []),
|
|
39
|
+
catch: (error) => error
|
|
40
|
+
});
|
|
38
41
|
const pkg = stripBuiltCondition(options.pkg);
|
|
39
42
|
const shouldResolve = (targetGroup.isProd || devManifest === "resolve") && manifestNeedsCatalogResolution(pkg);
|
|
40
43
|
let base = pkg;
|
|
41
|
-
if (shouldResolve) base =
|
|
44
|
+
if (shouldResolve) base = yield* resolveManifest(pkg, cwd);
|
|
45
|
+
if (options.bundled !== void 0) base = pruneBundled(base, options.bundled);
|
|
42
46
|
base = {
|
|
43
47
|
...base,
|
|
44
48
|
name: targetGroup.name
|
|
@@ -50,44 +54,65 @@ async function buildEmittedManifest(options) {
|
|
|
50
54
|
exeRewrite: options.exeRewrite,
|
|
51
55
|
emitDts: options.emitDts ?? true
|
|
52
56
|
});
|
|
53
|
-
}
|
|
57
|
+
});
|
|
54
58
|
/**
|
|
55
59
|
* Rolldown plugin: emit the transformed package.json + LICENSE/README into the output pkg/ root.
|
|
56
60
|
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* rolldown calls `generateBundle` as a plain async hook, so the plugin captures the `FileSystem` and `Path` it is
|
|
63
|
+
* built under and runs its reads with them.
|
|
64
|
+
*
|
|
57
65
|
* @public
|
|
58
66
|
*/
|
|
59
|
-
|
|
67
|
+
const emitManifest = (options) => Effect.map(Effect.context(), (services) => emitManifestWith(options, services));
|
|
68
|
+
const emitManifestWith = (options, services) => {
|
|
69
|
+
const run = Effect.runPromiseWith(services);
|
|
60
70
|
const sourceDir = options.sourceDir;
|
|
61
71
|
return {
|
|
62
72
|
name: "savvy:emit-manifest",
|
|
63
73
|
async generateBundle() {
|
|
64
|
-
const manifest = await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const { manifest, extras } = await run(Effect.gen(function* () {
|
|
75
|
+
const fs = yield* FileSystem.FileSystem;
|
|
76
|
+
const { join } = yield* Path.Path;
|
|
77
|
+
const pkg = JSON.parse(yield* fs.readFileString(join(sourceDir, "package.json")));
|
|
78
|
+
const manifest = yield* buildEmittedManifest({
|
|
79
|
+
pkg,
|
|
80
|
+
cwd: sourceDir,
|
|
81
|
+
targetGroup: options.targetGroup,
|
|
82
|
+
devManifest: options.devManifest ?? "preserve",
|
|
83
|
+
drop: options.drop,
|
|
84
|
+
set: options.set,
|
|
85
|
+
dual: options.dual,
|
|
86
|
+
subdirExports: options.subdirExports,
|
|
87
|
+
exeRewrite: options.exeRewrite,
|
|
88
|
+
emitDts: options.emitDts,
|
|
89
|
+
bundled: options.bundled
|
|
90
|
+
});
|
|
91
|
+
const extras = [];
|
|
92
|
+
for (const name of ["LICENSE", "README.md"]) {
|
|
93
|
+
const content = yield* fs.readFileString(join(sourceDir, name)).pipe(Effect.option);
|
|
94
|
+
if (content._tag === "Some") extras.push({
|
|
95
|
+
name,
|
|
96
|
+
content: content.value
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
manifest,
|
|
101
|
+
extras
|
|
102
|
+
};
|
|
103
|
+
}));
|
|
76
104
|
this.emitFile({
|
|
77
105
|
type: "asset",
|
|
78
106
|
fileName: "package.json",
|
|
79
107
|
source: `${JSON.stringify(manifest, null, " ")}\n`
|
|
80
108
|
});
|
|
81
|
-
for (const name of
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
source: content
|
|
87
|
-
});
|
|
88
|
-
} catch {}
|
|
109
|
+
for (const { name, content } of extras) this.emitFile({
|
|
110
|
+
type: "asset",
|
|
111
|
+
fileName: name,
|
|
112
|
+
source: content
|
|
113
|
+
});
|
|
89
114
|
}
|
|
90
115
|
};
|
|
91
|
-
}
|
|
116
|
+
};
|
|
92
117
|
|
|
93
118
|
export { buildEmittedManifest, emitManifest, manifestNeedsCatalogResolution };
|
package/meta/api-extractor.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MetaGenerationError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { existsLikeNode } from "../internal/exists.js";
|
|
3
3
|
import { createMessageSuppressor } from "./message-suppressor.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
5
|
+
import { realpathSync } from "node:fs";
|
|
5
6
|
import { tmpdir } from "node:os";
|
|
6
7
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
|
-
import {
|
|
9
|
+
import { TsconfigLoader } from "@effected/tsconfig-json";
|
|
9
10
|
import { Extractor, ExtractorConfig, ExtractorLogLevel } from "@microsoft/api-extractor";
|
|
10
11
|
import { TSDocConfigFile } from "@microsoft/tsdoc-config";
|
|
11
12
|
|
|
@@ -36,26 +37,28 @@ const CI_FATAL_MESSAGE_IDS = /* @__PURE__ */ new Set(["ae-forgotten-export"]);
|
|
|
36
37
|
* calls within a process overwrite the same file; cross-process temp files are left for the OS to
|
|
37
38
|
* reap, consistent with the other tmpdir tsconfig writers.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
40
|
+
const writeApiExtractorTsconfig = Effect.fnUntraced(function* (options) {
|
|
41
|
+
const fs = yield* FileSystem.FileSystem;
|
|
42
|
+
const path = yield* Path.Path;
|
|
43
|
+
const absBase = path.isAbsolute(options.tsconfigPath) ? options.tsconfigPath : path.resolve(options.tsconfigPath);
|
|
44
|
+
if (!(yield* existsLikeNode(absBase))) return options.tsconfigPath;
|
|
45
|
+
const entryDts = path.isAbsolute(options.entryDtsPath) ? options.entryDtsPath : path.resolve(options.cwd, options.entryDtsPath);
|
|
43
46
|
const ownPaths = options.paths ?? {};
|
|
44
47
|
const hasPaths = Object.keys(ownPaths).length > 0;
|
|
45
48
|
const cfg = {
|
|
46
49
|
extends: absBase,
|
|
47
50
|
files: [entryDts],
|
|
48
|
-
include: [join(options.cwd, "types/*.d.ts")],
|
|
51
|
+
include: [path.join(options.cwd, "types/*.d.ts")],
|
|
49
52
|
...hasPaths ? { compilerOptions: { paths: {
|
|
50
|
-
...readBasePaths(absBase),
|
|
53
|
+
...yield* readBasePaths(absBase),
|
|
51
54
|
...ownPaths
|
|
52
55
|
} } } : {}
|
|
53
56
|
};
|
|
54
57
|
const hash = createHash("sha256").update(`${absBase}\0${entryDts}${hasPaths ? `\0${JSON.stringify(ownPaths)}` : ""}`).digest("hex").slice(0, 16);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
}
|
|
58
|
+
const out = path.join(tmpdir(), `tsconfig-api-extractor-${process.pid}-${hash}.json`);
|
|
59
|
+
yield* fs.writeFileString(out, `${JSON.stringify(cfg, null, " ")}\n`);
|
|
60
|
+
return out;
|
|
61
|
+
});
|
|
59
62
|
/**
|
|
60
63
|
* The base tsconfig's effective `compilerOptions.paths`, with every relative target made absolute.
|
|
61
64
|
*
|
|
@@ -68,18 +71,15 @@ function writeApiExtractorTsconfig(options) {
|
|
|
68
71
|
* so `paths` inherited from further up the chain are kept too. Best-effort: a base that cannot be
|
|
69
72
|
* resolved contributes no paths.
|
|
70
73
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return {};
|
|
77
|
-
}
|
|
78
|
-
const paths = resolved.compilerOptions.paths;
|
|
74
|
+
const readBasePaths = (absBase) => Effect.gen(function* () {
|
|
75
|
+
const path = yield* Path.Path;
|
|
76
|
+
const resolved = yield* TsconfigLoader.resolve(absBase).pipe(Effect.option);
|
|
77
|
+
if (resolved._tag === "None") return {};
|
|
78
|
+
const paths = resolved.value.compilerOptions.paths;
|
|
79
79
|
if (paths === void 0) return {};
|
|
80
|
-
const anchor = resolved.compilerOptions.baseUrl ?? resolved.pathsBase ?? dirname(absBase);
|
|
81
|
-
return Object.fromEntries(Object.entries(paths).map(([key, targets]) => [key, targets.map((target) => isAbsolute(target) ? target : resolve(anchor, target))]));
|
|
82
|
-
}
|
|
80
|
+
const anchor = resolved.value.compilerOptions.baseUrl ?? resolved.value.pathsBase ?? path.dirname(absBase);
|
|
81
|
+
return Object.fromEntries(Object.entries(paths).map(([key, targets]) => [key, targets.map((target) => path.isAbsolute(target) ? target : path.resolve(anchor, target))]));
|
|
82
|
+
});
|
|
83
83
|
/**
|
|
84
84
|
* Map an API Extractor message to a collector DiagnosticInput, or undefined if not warn/error.
|
|
85
85
|
*
|
|
@@ -148,8 +148,23 @@ const isTsSource = (path) => /\.[cm]?tsx?$/.test(path) && !ExtractorConfig.hasDt
|
|
|
148
148
|
function ownSourceInputFiles(program, cwd) {
|
|
149
149
|
return program.getSourceFiles().map(({ fileName }) => resolve(cwd, fileName)).filter((path) => isTsSource(path) && isOwnPath(path, cwd));
|
|
150
150
|
}
|
|
151
|
-
/**
|
|
152
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Run API Extractor over a single entry's .d.ts, writing the .api.json (and optionally tsdoc-metadata.json).
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* The derived tsconfig is written through `FileSystem`; API Extractor itself is synchronous and reads the host disk.
|
|
156
|
+
* Anything it throws, and the {@link MetaGenerationError} of a failed run, fails the effect with the thrown value.
|
|
157
|
+
*/
|
|
158
|
+
const runApiExtractor = (options) => Effect.flatMap(writeApiExtractorTsconfig({
|
|
159
|
+
cwd: options.cwd,
|
|
160
|
+
tsconfigPath: options.tsconfigPath,
|
|
161
|
+
entryDtsPath: options.entryDtsPath,
|
|
162
|
+
paths: options.selfReferencePaths
|
|
163
|
+
}), (tsconfigFilePath) => Effect.try({
|
|
164
|
+
try: () => invokeApiExtractor(options, tsconfigFilePath),
|
|
165
|
+
catch: (e) => e
|
|
166
|
+
}));
|
|
167
|
+
function invokeApiExtractor(options, tsconfigFilePath) {
|
|
153
168
|
const suppressor = createMessageSuppressor(options.suppressWarnings);
|
|
154
169
|
const tsdocConfigFile = TSDocConfigFile.loadForFolder(dirname(options.tsdocConfigPath));
|
|
155
170
|
const namedOwnInputs = /* @__PURE__ */ new Set();
|
|
@@ -158,12 +173,7 @@ function runApiExtractor(options) {
|
|
|
158
173
|
projectFolder: options.cwd,
|
|
159
174
|
mainEntryPointFilePath: options.entryDtsPath,
|
|
160
175
|
enumMemberOrder: "preserve",
|
|
161
|
-
compiler: { tsconfigFilePath
|
|
162
|
-
cwd: options.cwd,
|
|
163
|
-
tsconfigPath: options.tsconfigPath,
|
|
164
|
-
entryDtsPath: options.entryDtsPath,
|
|
165
|
-
paths: options.selfReferencePaths
|
|
166
|
-
}) },
|
|
176
|
+
compiler: { tsconfigFilePath },
|
|
167
177
|
docModel: options.emitDocModel === false ? { enabled: false } : {
|
|
168
178
|
enabled: true,
|
|
169
179
|
apiJsonFilePath: options.apiJsonPath,
|