@effected/bundler 0.2.0 → 0.3.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/README.md +2 -1
- package/index.d.ts +12 -6
- package/meta/generate.js +25 -11
- package/meta/og-satori.js +1 -1
- package/package.json +22 -22
- package/passes/build-target-groups.js +1 -1
- package/passes/target-groups.js +50 -3
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ Requires Node.js >=24.11.0. `effect` and `typescript` are peer dependencies. To
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import
|
|
26
|
+
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
27
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
27
28
|
import { Bundler, EffectedConfigFile } from "@effected/bundler";
|
|
28
29
|
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
29
30
|
import { Effect, Layer } from "effect";
|
package/index.d.ts
CHANGED
|
@@ -1903,7 +1903,7 @@ interface DeriveOptions {
|
|
|
1903
1903
|
* - pass 1 (this) emits per-module JS (`unbundle: true`) with `dts: false` and the
|
|
1904
1904
|
* default `clean: true`, so it starts from a fresh outDir;
|
|
1905
1905
|
* - pass 2 (`DerivedDtsPassOptions`) emits ONLY bundled declarations (`unbundle: false`,
|
|
1906
|
-
* `dts: {
|
|
1906
|
+
* `dts: { dtsOnly: true }` (`emitDtsOnly` below rolldown-plugin-dts 0.30)) with `clean: false`, so it must NOT wipe pass 1.
|
|
1907
1907
|
*
|
|
1908
1908
|
* We cannot do this in a single pass: tsdown's `unbundle` maps to rolldown
|
|
1909
1909
|
* `output.preserveModules` for the WHOLE build, and the dts plugin shares it — so one pass
|
|
@@ -1986,7 +1986,7 @@ interface DerivedTsdownOptions {
|
|
|
1986
1986
|
* the per-module JS the JS pass just wrote). `unbundle: false` makes rolldown roll the
|
|
1987
1987
|
* declarations up per public entry, so a type re-exported through the root entry lands inline
|
|
1988
1988
|
* in `index.d.ts` (fixing TS2883) instead of as a per-module sibling `.d.ts`.
|
|
1989
|
-
* `dts: {
|
|
1989
|
+
* `dts: { dtsOnly: true }` (`emitDtsOnly` below rolldown-plugin-dts 0.30) strips the JS chunks this pass would otherwise produce.
|
|
1990
1990
|
*
|
|
1991
1991
|
* Dual format: when `format` includes `cjs`, the dts pass still emits both `index.d.ts` (esm)
|
|
1992
1992
|
* and `index.d.cts` (cjs) to the shared outDir.
|
|
@@ -2022,7 +2022,10 @@ interface DerivedDtsPassOptions {
|
|
|
2022
2022
|
*/
|
|
2023
2023
|
interface DtsPassDtsOptions {
|
|
2024
2024
|
readonly tsconfig: string;
|
|
2025
|
-
|
|
2025
|
+
/** Declarations only; read by rolldown-plugin-dts 0.30 and later. Exactly one of this and `emitDtsOnly` is set. */
|
|
2026
|
+
readonly dtsOnly?: true;
|
|
2027
|
+
/** The pre-0.30 spelling of `dtsOnly`; 0.30 still reads it but logs a deprecation warning. */
|
|
2028
|
+
readonly emitDtsOnly?: true;
|
|
2026
2029
|
readonly generator: "tsgo";
|
|
2027
2030
|
readonly tsgo: {
|
|
2028
2031
|
readonly moduleUrl: string;
|
|
@@ -2031,9 +2034,12 @@ interface DtsPassDtsOptions {
|
|
|
2031
2034
|
/**
|
|
2032
2035
|
* Build the {@link DtsPassDtsOptions} for a resolved tsconfig path.
|
|
2033
2036
|
*
|
|
2037
|
+
* @param tsconfig - The resolved tsconfig path.
|
|
2038
|
+
* @param pluginVersion - The rolldown-plugin-dts version to target; defaults to the copy tsdown loads.
|
|
2039
|
+
*
|
|
2034
2040
|
* @public
|
|
2035
2041
|
*/
|
|
2036
|
-
export declare const dtsPassDtsOptions: (tsconfig: string) => DtsPassDtsOptions;
|
|
2042
|
+
export declare const dtsPassDtsOptions: (tsconfig: string, pluginVersion?: string | undefined) => DtsPassDtsOptions;
|
|
2037
2043
|
/**
|
|
2038
2044
|
* The output dir for a group: `dist/prod/\<group\>/pkg`, or `dist/dev/pkg` for the unused dev group.
|
|
2039
2045
|
*
|
|
@@ -2236,7 +2242,7 @@ interface BuildTargetGroupsOptions {
|
|
|
2236
2242
|
/**
|
|
2237
2243
|
* Extra rolldown plugins, forwarded to BOTH the JS pass and the dts-only pass. A plugin
|
|
2238
2244
|
* with JS-lifecycle side effects (asset emitters, banner injectors) runs in both passes;
|
|
2239
|
-
* the dts pass
|
|
2245
|
+
* the dts pass is declarations-only, so for esm-only builds it produces no JS chunks and most
|
|
2240
2246
|
* rolldown hooks are no-ops there. For DUAL (esm+cjs) builds, however, tsdown's dts pass
|
|
2241
2247
|
* still RE-EMITS the `.cjs` JS chunk and overwrites the JS pass's `.cjs` output — so a
|
|
2242
2248
|
* `renderChunk`/`generateBundle` plugin that must persist onto the final `.cjs` (e.g. the
|
|
@@ -2309,7 +2315,7 @@ interface BuildTargetGroupsOptions {
|
|
|
2309
2315
|
* Each group runs TWO passes to the SAME outDir:
|
|
2310
2316
|
* 1. JS pass — per-module JS (`unbundle: true`, `dts: false`), with the `emitManifest` plugin
|
|
2311
2317
|
* and the `public/` copy. Default `clean: true` gives it a fresh outDir.
|
|
2312
|
-
* 2. dts pass — bundled declarations only (`unbundle: false`, `dts: {
|
|
2318
|
+
* 2. dts pass — bundled declarations only (`unbundle: false`, `dts: { dtsOnly: true }` (`emitDtsOnly` below rolldown-plugin-dts 0.30),
|
|
2313
2319
|
* `clean: false`). No manifest plugin, no copy, no sourcemaps. `clean: false` is load-bearing:
|
|
2314
2320
|
* it must NOT wipe the JS the first pass just wrote.
|
|
2315
2321
|
*
|
package/meta/generate.js
CHANGED
|
@@ -49,6 +49,7 @@ async function generateMeta(options) {
|
|
|
49
49
|
const perEntryModels = /* @__PURE__ */ new Map();
|
|
50
50
|
const intermediateApiJsons = [];
|
|
51
51
|
let mainEntryDidTsdocMetadata = false;
|
|
52
|
+
let firstFailure;
|
|
52
53
|
const diagnosticKey = (e) => `${e.code ?? ""}\0${e.text}`;
|
|
53
54
|
const stripLocation = (e) => ({
|
|
54
55
|
source: e.source,
|
|
@@ -72,21 +73,17 @@ async function generateMeta(options) {
|
|
|
72
73
|
const perEntryApiJson = join(outMetaDir, `${safeEntry}.entry.api.json`);
|
|
73
74
|
intermediateApiJsons.push(perEntryApiJson);
|
|
74
75
|
const isMain = exportPathFor(entryName) === ".";
|
|
75
|
-
const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0
|
|
76
|
+
const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0;
|
|
77
|
+
const isCapturedFatal = (entry) => ci === true ? entry.level === "error" : entry.ciFatal === true;
|
|
76
78
|
const rollupFatal = [];
|
|
77
79
|
const runBReported = /* @__PURE__ */ new Set();
|
|
78
80
|
const captureRollupSuppressed = splitDiagnostics && onSuppressed !== void 0;
|
|
79
81
|
const rollupSuppressed = [];
|
|
80
82
|
const runBSuppressed = /* @__PURE__ */ new Set();
|
|
81
83
|
const runAOnMessage = captureRollupOnlyFatal ? (entry) => {
|
|
82
|
-
if (entry
|
|
83
|
-
} : ci === true && onMessage !== void 0 ? (entry) => {
|
|
84
|
-
if (entry.level === "error") onMessage(stripLocation(entry));
|
|
84
|
+
if (isCapturedFatal(entry)) rollupFatal.push(entry);
|
|
85
85
|
} : () => {};
|
|
86
|
-
|
|
87
|
-
if (onSuppressed !== void 0) for (const entry of rollupSuppressed) onSuppressed(stripLocation(entry));
|
|
88
|
-
throw err;
|
|
89
|
-
};
|
|
86
|
+
let runAFailure;
|
|
90
87
|
try {
|
|
91
88
|
runApiExtractor({
|
|
92
89
|
cwd,
|
|
@@ -109,12 +106,21 @@ async function generateMeta(options) {
|
|
|
109
106
|
}
|
|
110
107
|
});
|
|
111
108
|
} catch (err) {
|
|
112
|
-
|
|
109
|
+
if (!splitDiagnostics) throw err;
|
|
110
|
+
runAFailure = { error: err };
|
|
113
111
|
}
|
|
114
112
|
if (splitDiagnostics) {
|
|
115
113
|
const runBOnMessage = captureRollupOnlyFatal && onMessage !== void 0 ? (entry) => {
|
|
116
|
-
if (entry.ciFatal === true) runBReported.add(diagnosticKey(entry));
|
|
117
|
-
|
|
114
|
+
if (isCapturedFatal(entry) || entry.ciFatal === true) runBReported.add(diagnosticKey(entry));
|
|
115
|
+
if (entry.ciFatal !== true || ci !== true) {
|
|
116
|
+
onMessage(entry);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const { ciFatal: _ciFatal, ...escalated } = entry;
|
|
120
|
+
onMessage({
|
|
121
|
+
...escalated,
|
|
122
|
+
level: "error"
|
|
123
|
+
});
|
|
118
124
|
} : onMessage;
|
|
119
125
|
try {
|
|
120
126
|
runApiExtractor({
|
|
@@ -150,9 +156,17 @@ async function generateMeta(options) {
|
|
|
150
156
|
onSuppressed(stripLocation(entry));
|
|
151
157
|
}
|
|
152
158
|
}
|
|
159
|
+
if (runAFailure !== void 0) {
|
|
160
|
+
firstFailure ??= runAFailure;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
153
163
|
if (isMain) mainEntryDidTsdocMetadata = true;
|
|
154
164
|
perEntryModels.set(entryName, JSON.parse(readFileSync(perEntryApiJson, "utf-8")));
|
|
155
165
|
}
|
|
166
|
+
if (firstFailure !== void 0) {
|
|
167
|
+
for (const intermediate of intermediateApiJsons) rmSync(intermediate, { force: true });
|
|
168
|
+
throw firstFailure.error;
|
|
169
|
+
}
|
|
156
170
|
const finalModel = perEntryModels.size === 1 ? perEntryModels.values().next().value : mergeApiModels({
|
|
157
171
|
perEntryModels,
|
|
158
172
|
packageName,
|
package/meta/og-satori.js
CHANGED
|
@@ -111,7 +111,7 @@ const ogImage = { satori(options = {}) {
|
|
|
111
111
|
};
|
|
112
112
|
const cacheSalt = JSON.stringify({
|
|
113
113
|
renderer: "@effected/bundler/og#satori",
|
|
114
|
-
version: "0.
|
|
114
|
+
version: "0.3.0",
|
|
115
115
|
satori: peerVersion("satori"),
|
|
116
116
|
resvg: peerVersion("@resvg/resvg-js"),
|
|
117
117
|
colors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The kit's build pipeline: effected.toml config, tsdown JS and declaration passes, API Extractor meta, SEA, GitHub Action bundles and build journals.",
|
|
6
6
|
"keywords": [
|
|
@@ -38,33 +38,33 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@effect/platform-node": "
|
|
42
|
-
"@effected/changesets": "0.
|
|
43
|
-
"@effected/config-file": "^0.
|
|
44
|
-
"@effected/env": "^0.
|
|
45
|
-
"@effected/files": "^0.
|
|
46
|
-
"@effected/glob": "^0.
|
|
47
|
-
"@effected/images": "^0.
|
|
48
|
-
"@effected/jsonc": "^0.
|
|
49
|
-
"@effected/jsonl": "^0.
|
|
50
|
-
"@effected/manifest": "^0.
|
|
51
|
-
"@effected/npm": "^0.
|
|
52
|
-
"@effected/package-json": "^0.
|
|
53
|
-
"@effected/semver": "^0.
|
|
54
|
-
"@effected/toml": "^0.
|
|
55
|
-
"@effected/tsconfig-json": "^0.
|
|
56
|
-
"@effected/walker": "^0.
|
|
57
|
-
"@effected/workspaces": "^0.
|
|
58
|
-
"@effected/yaml": "^0.
|
|
41
|
+
"@effect/platform-node": "4.1.3",
|
|
42
|
+
"@effected/changesets": "0.4.0",
|
|
43
|
+
"@effected/config-file": "^0.27.0",
|
|
44
|
+
"@effected/env": "^0.12.0",
|
|
45
|
+
"@effected/files": "^0.3.0",
|
|
46
|
+
"@effected/glob": "^0.21.0",
|
|
47
|
+
"@effected/images": "^0.10.0",
|
|
48
|
+
"@effected/jsonc": "^0.25.0",
|
|
49
|
+
"@effected/jsonl": "^0.19.0",
|
|
50
|
+
"@effected/manifest": "^0.2.0",
|
|
51
|
+
"@effected/npm": "^0.33.0",
|
|
52
|
+
"@effected/package-json": "^0.32.0",
|
|
53
|
+
"@effected/semver": "^0.24.0",
|
|
54
|
+
"@effected/toml": "^0.20.0",
|
|
55
|
+
"@effected/tsconfig-json": "^0.21.0",
|
|
56
|
+
"@effected/walker": "^0.27.0",
|
|
57
|
+
"@effected/workspaces": "^0.45.0",
|
|
58
|
+
"@effected/yaml": "^0.30.0",
|
|
59
59
|
"@jridgewell/sourcemap-codec": "^1.6.0",
|
|
60
60
|
"@microsoft/api-extractor": "^7.60.1",
|
|
61
61
|
"@microsoft/tsdoc": "~0.17.1",
|
|
62
62
|
"@microsoft/tsdoc-config": "~0.18.3",
|
|
63
|
-
"@tsdown/exe": "^0.23.
|
|
63
|
+
"@tsdown/exe": "^0.23.7",
|
|
64
64
|
"jiti": "~2.7.0",
|
|
65
|
-
"rolldown": "^1.
|
|
65
|
+
"rolldown": "^1.3.1",
|
|
66
66
|
"rolldown-plugin-dts": "^0.30.0",
|
|
67
|
-
"tsdown": "^0.23.
|
|
67
|
+
"tsdown": "^0.23.7"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@resvg/resvg-js": "^2.6.2",
|
|
@@ -35,7 +35,7 @@ const copyEntriesFor = (entries, outDir) => entries.map((entry) => {
|
|
|
35
35
|
* Each group runs TWO passes to the SAME outDir:
|
|
36
36
|
* 1. JS pass — per-module JS (`unbundle: true`, `dts: false`), with the `emitManifest` plugin
|
|
37
37
|
* and the `public/` copy. Default `clean: true` gives it a fresh outDir.
|
|
38
|
-
* 2. dts pass — bundled declarations only (`unbundle: false`, `dts: {
|
|
38
|
+
* 2. dts pass — bundled declarations only (`unbundle: false`, `dts: { dtsOnly: true }` (`emitDtsOnly` below rolldown-plugin-dts 0.30),
|
|
39
39
|
* `clean: false`). No manifest plugin, no copy, no sourcemaps. `clean: false` is load-bearing:
|
|
40
40
|
* it must NOT wipe the JS the first pass just wrote.
|
|
41
41
|
*
|
package/passes/target-groups.js
CHANGED
|
@@ -1,16 +1,63 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { Result } from "effect";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
1
4
|
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { SemVer } from "@effected/semver";
|
|
2
7
|
|
|
3
8
|
// src/passes/target-groups.ts
|
|
4
9
|
/** The `file://` URL of the TypeScript module this package resolves (its own pinned dependency). */
|
|
5
10
|
const typescriptModuleUrl = () => import.meta.resolve("typescript");
|
|
11
|
+
/** The first rolldown-plugin-dts release that reads `dtsOnly`. */
|
|
12
|
+
const DTS_ONLY_SINCE = "0.30.0";
|
|
13
|
+
/**
|
|
14
|
+
* Choose the declarations-only option key for a rolldown-plugin-dts version.
|
|
15
|
+
*
|
|
16
|
+
* 0.30 and later read `dtsOnly` and warn on `emitDtsOnly`; earlier releases read only
|
|
17
|
+
* `emitDtsOnly` and silently ignore `dtsOnly`, which would turn the declaration pass into a
|
|
18
|
+
* JS-emitting pass. An unknown or unparsable version gets `emitDtsOnly`, which both lines honour.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
const dtsOnlyOption = (pluginVersion) => {
|
|
23
|
+
if (pluginVersion !== void 0) {
|
|
24
|
+
const have = SemVer.parseResult(pluginVersion);
|
|
25
|
+
const want = SemVer.parseResult(DTS_ONLY_SINCE);
|
|
26
|
+
if (Result.isSuccess(have) && Result.isSuccess(want) && have.success.gte(want.success)) return { dtsOnly: true };
|
|
27
|
+
}
|
|
28
|
+
return { emitDtsOnly: true };
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The version of the rolldown-plugin-dts copy tsdown will load, or `undefined` when it cannot
|
|
32
|
+
* be determined. It is resolved from tsdown's own location, not this package's, because a
|
|
33
|
+
* workspace override can point tsdown at a different copy than this package depends on.
|
|
34
|
+
*/
|
|
35
|
+
const resolveDtsPluginVersion = () => {
|
|
36
|
+
try {
|
|
37
|
+
const fromTsdown = createRequire(fileURLToPath(import.meta.resolve("tsdown")));
|
|
38
|
+
const manifest = JSON.parse(readFileSync(fromTsdown.resolve("rolldown-plugin-dts/package.json"), "utf8"));
|
|
39
|
+
return typeof manifest.version === "string" ? manifest.version : void 0;
|
|
40
|
+
} catch {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/** Resolved once per process; a build is one process. */
|
|
45
|
+
let dtsPluginVersion;
|
|
46
|
+
const installedDtsPluginVersion = () => {
|
|
47
|
+
dtsPluginVersion ??= { value: resolveDtsPluginVersion() };
|
|
48
|
+
return dtsPluginVersion.value;
|
|
49
|
+
};
|
|
6
50
|
/**
|
|
7
51
|
* Build the {@link DtsPassDtsOptions} for a resolved tsconfig path.
|
|
8
52
|
*
|
|
53
|
+
* @param tsconfig - The resolved tsconfig path.
|
|
54
|
+
* @param pluginVersion - The rolldown-plugin-dts version to target; defaults to the copy tsdown loads.
|
|
55
|
+
*
|
|
9
56
|
* @public
|
|
10
57
|
*/
|
|
11
|
-
const dtsPassDtsOptions = (tsconfig) => ({
|
|
58
|
+
const dtsPassDtsOptions = (tsconfig, pluginVersion = installedDtsPluginVersion()) => ({
|
|
12
59
|
tsconfig,
|
|
13
|
-
|
|
60
|
+
...dtsOnlyOption(pluginVersion),
|
|
14
61
|
generator: "tsgo",
|
|
15
62
|
tsgo: { moduleUrl: typescriptModuleUrl() }
|
|
16
63
|
});
|
|
@@ -109,4 +156,4 @@ function deriveDeclarationsPassOptions(options) {
|
|
|
109
156
|
};
|
|
110
157
|
}
|
|
111
158
|
|
|
112
|
-
export { declarationsDirFor, deriveDeclarationsPassOptions, deriveDtsPassOptions, deriveTargetGroupOptions, dtsPassDtsOptions, outDirFor };
|
|
159
|
+
export { declarationsDirFor, deriveDeclarationsPassOptions, deriveDtsPassOptions, deriveTargetGroupOptions, dtsOnlyOption, dtsPassDtsOptions, outDirFor };
|