@trebired/bundler 1.5.0 → 2.0.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/CHANGELOG.md +15 -0
- package/README.md +64 -4
- package/dist/core/asset-manifest.d.ts +5 -0
- package/dist/core/asset-manifest.d.ts.map +1 -0
- package/dist/core/asset-manifest.js +257 -0
- package/dist/core/asset-manifest.js.map +1 -0
- package/dist/core/discovery.d.ts +1 -0
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +173 -1
- package/dist/core/discovery.js.map +1 -1
- package/dist/core/import-graph.d.ts +4 -0
- package/dist/core/import-graph.d.ts.map +1 -0
- package/dist/core/import-graph.js +410 -0
- package/dist/core/import-graph.js.map +1 -0
- package/dist/core/manifest.d.ts.map +1 -1
- package/dist/core/manifest.js +7 -0
- package/dist/core/manifest.js.map +1 -1
- package/dist/core/shared.d.ts.map +1 -1
- package/dist/core/shared.js +10 -0
- package/dist/core/shared.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/virtual-entries.d.ts.map +1 -1
- package/dist/plugins/virtual-entries.js +10 -4
- package/dist/plugins/virtual-entries.js.map +1 -1
- package/dist/types.d.ts +81 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to `@trebired/bundler` will be documented here.
|
|
|
4
4
|
|
|
5
5
|
This project follows semantic versioning once published.
|
|
6
6
|
|
|
7
|
+
## 2.0.0
|
|
8
|
+
|
|
9
|
+
- Changed `discover` to group discovered `.js` and `.ts` files into auto-named script bundles by default.
|
|
10
|
+
- Changed `discover` to group discovered `.css` and `.scss` files into auto-named style bundles by default.
|
|
11
|
+
- Added `discover.maxBundleSize` with a default of `50mb`, splitting grouped discovered bundles only when the full group exceeds the limit.
|
|
12
|
+
- Kept discovered `.jsx` and `.tsx` files as normal per-file entries.
|
|
13
|
+
- Made grouped discovered builds fail when one grouped source file is larger than the configured max bundle size.
|
|
14
|
+
|
|
15
|
+
## 1.6.0
|
|
16
|
+
|
|
17
|
+
- Added `buildAssetManifest()` for a runtime-friendly asset manifest keyed by logical entries and source paths.
|
|
18
|
+
- Added `collectAssetLinks()` for collecting emitted scripts, styles, and other assets without app-specific HTML generation.
|
|
19
|
+
- Added `walkImportGraph()` for generic source dependency walking with relative import and tsconfig `paths` resolution.
|
|
20
|
+
- Exposed `assetManifest` on `bundle()` and `watch()` build results and included the same structure in the written bundler manifest.
|
|
21
|
+
|
|
7
22
|
## 1.5.0
|
|
8
23
|
|
|
9
24
|
- Removed the `obfuscate` option and all package-owned obfuscation behavior, including hashed artifact naming, property mangling, and static class-token rewriting.
|
package/README.md
CHANGED
|
@@ -26,6 +26,9 @@ Use this when:
|
|
|
26
26
|
- you want newly created matching files to join the build without external entry regeneration code
|
|
27
27
|
- you want a manifest describing resolved entries and generated outputs
|
|
28
28
|
- you want a stable helper for turning esbuild metafiles into runtime asset graphs
|
|
29
|
+
- you want a runtime-friendly asset manifest keyed by entry names and source paths
|
|
30
|
+
- you want a package-owned helper for collecting script and stylesheet links for selected entries
|
|
31
|
+
- you want a generic import graph walker with tsconfig path resolution for higher-level presets
|
|
29
32
|
- you want rebuild hooks instead of scraping logger text
|
|
30
33
|
- you want generated bundles to optionally include inline comments that point back to the original source file path
|
|
31
34
|
- you want production-lean defaults with minified output and stripped comments
|
|
@@ -99,10 +102,9 @@ Set `discover` when you want `@trebired/bundler` to walk the source tree and bui
|
|
|
99
102
|
await bundle({
|
|
100
103
|
discover: {
|
|
101
104
|
dir: "./src/frontend",
|
|
102
|
-
include: ["**/*.tsx", "
|
|
105
|
+
include: ["**/*.tsx", "**/*.js", "**/*.ts", "**/*.css", "**/*.scss"],
|
|
103
106
|
exclude: ["**/*.test.tsx"],
|
|
104
|
-
|
|
105
|
-
namePrefix: "frontend",
|
|
107
|
+
maxBundleSize: "50mb",
|
|
106
108
|
},
|
|
107
109
|
outDir: "./dist",
|
|
108
110
|
});
|
|
@@ -112,9 +114,16 @@ The package:
|
|
|
112
114
|
|
|
113
115
|
- walks the configured directory recursively
|
|
114
116
|
- matches files by extension plus optional include and exclude patterns
|
|
115
|
-
-
|
|
117
|
+
- groups discovered `.js` and `.ts` files into auto-named script bundles
|
|
118
|
+
- groups discovered `.css` and `.scss` files into auto-named style bundles
|
|
119
|
+
- leaves discovered `.jsx` and `.tsx` files as normal per-file entries
|
|
116
120
|
- rebuilds the entry list during watch mode when matching files are added or removed
|
|
117
121
|
|
|
122
|
+
- grouped bundles are auto-named like `bundle-abc123.js` and `bundle-abc123-2.css`
|
|
123
|
+
- `maxBundleSize` defaults to `50mb`
|
|
124
|
+
- `maxBundleSize` accepts bytes or strings like `"50mb"` and splits bundles by summed discovered source-file size before handing each group to `esbuild`
|
|
125
|
+
- if one discovered grouped file is larger than `maxBundleSize`, the build fails
|
|
126
|
+
|
|
118
127
|
You can combine manual `entries` with `discover`. If both resolve the same entry name to different files, the build fails so the collision is explicit.
|
|
119
128
|
|
|
120
129
|
## Manifest
|
|
@@ -126,6 +135,7 @@ The manifest contains:
|
|
|
126
135
|
- resolved entries
|
|
127
136
|
- whether each entry came from `manual` config or `discover`
|
|
128
137
|
- generated output files
|
|
138
|
+
- a runtime-friendly `assetManifest` keyed by entry source path, with lookup maps for entry names and emitted outputs
|
|
129
139
|
|
|
130
140
|
If you want a runtime-friendly asset graph directly in app code, call `deriveManifest()` on the returned `metafile`:
|
|
131
141
|
|
|
@@ -151,6 +161,37 @@ The helper returns:
|
|
|
151
161
|
- `chunks`: shared output -> import/CSS graph
|
|
152
162
|
- `allOutputs`: flat normalized output index
|
|
153
163
|
|
|
164
|
+
If you want a manifest ready for runtime asset selection, use `buildAssetManifest()`:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { buildAssetManifest, bundle, collectAssetLinks } from "@trebired/bundler";
|
|
168
|
+
|
|
169
|
+
const result = await bundle({
|
|
170
|
+
entries: {
|
|
171
|
+
app: "./src/app.tsx",
|
|
172
|
+
},
|
|
173
|
+
outDir: "./dist",
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const assetManifest = result.assetManifest || buildAssetManifest({
|
|
177
|
+
metafile: result.metafile!,
|
|
178
|
+
outDir: "./dist",
|
|
179
|
+
rootDir: process.cwd(),
|
|
180
|
+
resolvedEntries: result.entries,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const assets = collectAssetLinks(assetManifest, ["app"], {
|
|
184
|
+
publicPath: "/",
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The runtime asset manifest exposes:
|
|
189
|
+
|
|
190
|
+
- `entries`: entry source path -> primary file, reachable JS, reachable CSS, and other emitted assets
|
|
191
|
+
- `entryNames`: logical entry name -> entry source path
|
|
192
|
+
- `entryOutputs`: emitted entry file -> entry source path
|
|
193
|
+
- `outputs`: emitted output index relative to `outDir`
|
|
194
|
+
|
|
154
195
|
## Virtual Entries
|
|
155
196
|
|
|
156
197
|
Use `virtualEntries` when you want generated entry modules without writing temporary files:
|
|
@@ -198,6 +239,25 @@ await watch({
|
|
|
198
239
|
|
|
199
240
|
`onEntrySetChanged()` runs only when the resolved entry set changes. `onRebuilt()` runs after a successful rebuild result is assembled.
|
|
200
241
|
|
|
242
|
+
## Import Graph Walking
|
|
243
|
+
|
|
244
|
+
Use `walkImportGraph()` when a higher-level preset needs to inspect internal source dependencies without reimplementing relative import or tsconfig-path resolution:
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { walkImportGraph } from "@trebired/bundler";
|
|
248
|
+
|
|
249
|
+
const graph = await walkImportGraph({
|
|
250
|
+
entries: "./src/app.tsx",
|
|
251
|
+
rootDir: process.cwd(),
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The helper:
|
|
256
|
+
|
|
257
|
+
- walks static imports, re-exports, and string-literal dynamic imports
|
|
258
|
+
- resolves relative imports and tsconfig `paths`
|
|
259
|
+
- returns a root-relative file graph with resolved internal imports marked explicitly
|
|
260
|
+
|
|
201
261
|
## Optimization Defaults
|
|
202
262
|
|
|
203
263
|
`@trebired/bundler` now defaults to production-lean output through `mode: "compact"`:
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BundlerAssetManifest, BundlerBuildAssetManifestOptions, BundlerCollectedAssetLinks, BundlerCollectAssetLinksOptions } from "../types.js";
|
|
2
|
+
declare function buildAssetManifest(options: BundlerBuildAssetManifestOptions): BundlerAssetManifest;
|
|
3
|
+
declare function collectAssetLinks(manifest: BundlerAssetManifest, entryIds: string[], options?: BundlerCollectAssetLinksOptions): BundlerCollectedAssetLinks;
|
|
4
|
+
export { buildAssetManifest, collectAssetLinks };
|
|
5
|
+
//# sourceMappingURL=asset-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-manifest.d.ts","sourceRoot":"","sources":["../../src/core/asset-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EAEpB,gCAAgC,EAChC,0BAA0B,EAE1B,+BAA+B,EAGhC,MAAM,aAAa,CAAC;AA8HrB,iBAAS,kBAAkB,CAAC,OAAO,EAAE,gCAAgC,GAAG,oBAAoB,CAkF3F;AA0CD,iBAAS,iBAAiB,CACxB,QAAQ,EAAE,oBAAoB,EAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,+BAAoC,GAC5C,0BAA0B,CAqD5B;AAED,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { deriveManifest } from "./derive-manifest.js";
|
|
3
|
+
import { toPosixPath } from "./discovery.js";
|
|
4
|
+
function normalizeKey(value) {
|
|
5
|
+
return toPosixPath(String(value || "").trim()).replace(/^\.\/+/, "").replace(/^\/+|\/+$/g, "");
|
|
6
|
+
}
|
|
7
|
+
function normalizeSourcePath(value, rootDir) {
|
|
8
|
+
const raw = String(value || "").trim();
|
|
9
|
+
if (!raw)
|
|
10
|
+
return "";
|
|
11
|
+
if (raw.startsWith("virtual:"))
|
|
12
|
+
return normalizeKey(raw);
|
|
13
|
+
const absolute = path.isAbsolute(raw) ? raw : path.resolve(rootDir, raw);
|
|
14
|
+
return normalizeKey(path.relative(rootDir, absolute));
|
|
15
|
+
}
|
|
16
|
+
function normalizeOutputPath(value, rootDir, outDir) {
|
|
17
|
+
const raw = String(value || "").trim();
|
|
18
|
+
if (!raw)
|
|
19
|
+
return "";
|
|
20
|
+
if (path.isAbsolute(raw)) {
|
|
21
|
+
return normalizeKey(path.relative(outDir, raw));
|
|
22
|
+
}
|
|
23
|
+
const normalized = normalizeKey(raw);
|
|
24
|
+
if (!normalized)
|
|
25
|
+
return "";
|
|
26
|
+
const outDirRel = normalizeKey(path.relative(rootDir, outDir));
|
|
27
|
+
if (outDirRel && normalized.startsWith(`${outDirRel}/`)) {
|
|
28
|
+
return normalized.slice(outDirRel.length + 1);
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
function toStableList(values) {
|
|
33
|
+
return Array.from(new Set(Array.from(values).filter(Boolean)));
|
|
34
|
+
}
|
|
35
|
+
function normalizeResolvedEntries(resolvedEntries, rootDir) {
|
|
36
|
+
const out = new Map();
|
|
37
|
+
if (!resolvedEntries)
|
|
38
|
+
return out;
|
|
39
|
+
if (Array.isArray(resolvedEntries)) {
|
|
40
|
+
for (const entry of resolvedEntries) {
|
|
41
|
+
const entryKey = entry.source === "virtual"
|
|
42
|
+
? `virtual:${normalizeKey(entry.name)}`
|
|
43
|
+
: normalizeSourcePath(entry.path, rootDir);
|
|
44
|
+
if (!entryKey || !entry.name)
|
|
45
|
+
continue;
|
|
46
|
+
out.set(entryKey, entry.name);
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
for (const [entryName, entryPath] of Object.entries(resolvedEntries)) {
|
|
51
|
+
const entryKey = normalizeSourcePath(entryPath, rootDir);
|
|
52
|
+
if (!entryKey || !entryName)
|
|
53
|
+
continue;
|
|
54
|
+
out.set(entryKey, normalizeKey(entryName));
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
function collectReachableOutputs(args) {
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
const stack = [args.entryOutput];
|
|
61
|
+
while (stack.length) {
|
|
62
|
+
const current = stack.pop();
|
|
63
|
+
if (!current || seen.has(current))
|
|
64
|
+
continue;
|
|
65
|
+
seen.add(current);
|
|
66
|
+
const output = args.outputs[current];
|
|
67
|
+
if (!output)
|
|
68
|
+
continue;
|
|
69
|
+
for (const imported of output.imports) {
|
|
70
|
+
if (args.outputs[imported]) {
|
|
71
|
+
stack.push(imported);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const css of output.css) {
|
|
75
|
+
if (args.outputs[css]) {
|
|
76
|
+
stack.push(css);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return Array.from(seen).sort();
|
|
81
|
+
}
|
|
82
|
+
function createEntryRecord(args) {
|
|
83
|
+
const js = toStableList(args.js);
|
|
84
|
+
const css = toStableList(args.css);
|
|
85
|
+
const outputs = toStableList(args.outputs);
|
|
86
|
+
const jsSet = new Set(js);
|
|
87
|
+
const cssSet = new Set(css);
|
|
88
|
+
return {
|
|
89
|
+
entryName: args.entryName,
|
|
90
|
+
entrySource: args.entrySource,
|
|
91
|
+
file: args.entryOutput,
|
|
92
|
+
entryOutput: args.entryOutput,
|
|
93
|
+
outputs,
|
|
94
|
+
js,
|
|
95
|
+
css,
|
|
96
|
+
assets: outputs.filter((value) => !jsSet.has(value) && !cssSet.has(value)),
|
|
97
|
+
imports: toStableList(args.imports),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function buildAssetManifest(options) {
|
|
101
|
+
const rootDir = path.resolve(options.rootDir);
|
|
102
|
+
const outDir = path.resolve(rootDir, options.outDir);
|
|
103
|
+
const derived = deriveManifest(options.metafile, {
|
|
104
|
+
outDir,
|
|
105
|
+
rootDir,
|
|
106
|
+
});
|
|
107
|
+
const resolvedEntryNames = normalizeResolvedEntries(options.resolvedEntries, rootDir);
|
|
108
|
+
const entries = {};
|
|
109
|
+
const entryNames = {};
|
|
110
|
+
const entrySources = {};
|
|
111
|
+
const entryOutputs = {};
|
|
112
|
+
const outputs = {};
|
|
113
|
+
for (const output of Object.values(derived.allOutputs)) {
|
|
114
|
+
const entrySource = output.entryPoint
|
|
115
|
+
? normalizeSourcePath(output.entryPoint, rootDir)
|
|
116
|
+
: undefined;
|
|
117
|
+
const entryName = entrySource
|
|
118
|
+
? resolvedEntryNames.get(entrySource) || output.entryName
|
|
119
|
+
: output.entryName;
|
|
120
|
+
const outputKey = normalizeOutputPath(output.output, rootDir, outDir);
|
|
121
|
+
if (!outputKey)
|
|
122
|
+
continue;
|
|
123
|
+
outputs[outputKey] = {
|
|
124
|
+
output: outputKey,
|
|
125
|
+
kind: output.kind,
|
|
126
|
+
entryName,
|
|
127
|
+
entrySource,
|
|
128
|
+
entryPoint: entrySource,
|
|
129
|
+
inputs: output.inputs.map((value) => normalizeSourcePath(value, rootDir)).filter(Boolean),
|
|
130
|
+
css: output.css.map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean),
|
|
131
|
+
imports: output.imports.map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean),
|
|
132
|
+
bytes: output.bytes,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
for (const entry of Object.values(derived.entries)) {
|
|
136
|
+
const outputInfo = derived.allOutputs[entry.entryOutput];
|
|
137
|
+
const entrySource = outputInfo?.entryPoint
|
|
138
|
+
? normalizeSourcePath(outputInfo.entryPoint, rootDir)
|
|
139
|
+
: undefined;
|
|
140
|
+
const entryName = entrySource
|
|
141
|
+
? resolvedEntryNames.get(entrySource) || outputInfo?.entryName || entry.entryName
|
|
142
|
+
: outputInfo?.entryName || entry.entryName;
|
|
143
|
+
const entryKey = entrySource || normalizeOutputPath(entry.entryOutput, rootDir, outDir);
|
|
144
|
+
const entryOutput = normalizeOutputPath(entry.entryOutput, rootDir, outDir);
|
|
145
|
+
const reachableOutputs = collectReachableOutputs({
|
|
146
|
+
entryOutput: entry.entryOutput,
|
|
147
|
+
outputs: derived.allOutputs,
|
|
148
|
+
}).map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean);
|
|
149
|
+
if (!entryKey || !entryOutput)
|
|
150
|
+
continue;
|
|
151
|
+
entries[entryKey] = createEntryRecord({
|
|
152
|
+
entryName,
|
|
153
|
+
entryOutput,
|
|
154
|
+
entrySource,
|
|
155
|
+
outputs: reachableOutputs,
|
|
156
|
+
js: entry.js.map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean),
|
|
157
|
+
css: entry.css.map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean),
|
|
158
|
+
imports: entry.imports.map((value) => normalizeOutputPath(value, rootDir, outDir)).filter(Boolean),
|
|
159
|
+
});
|
|
160
|
+
if (entryName) {
|
|
161
|
+
entryNames[entryName] = entryKey;
|
|
162
|
+
}
|
|
163
|
+
if (entrySource) {
|
|
164
|
+
entrySources[entrySource] = entryKey;
|
|
165
|
+
}
|
|
166
|
+
entryOutputs[entryOutput] = entryKey;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
entries: Object.fromEntries(Object.entries(entries).sort(([a], [b]) => a.localeCompare(b))),
|
|
170
|
+
entryNames: Object.fromEntries(Object.entries(entryNames).sort(([a], [b]) => a.localeCompare(b))),
|
|
171
|
+
entrySources: Object.fromEntries(Object.entries(entrySources).sort(([a], [b]) => a.localeCompare(b))),
|
|
172
|
+
entryOutputs: Object.fromEntries(Object.entries(entryOutputs).sort(([a], [b]) => a.localeCompare(b))),
|
|
173
|
+
outputs: Object.fromEntries(Object.entries(outputs).sort(([a], [b]) => a.localeCompare(b))),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function toPublicPath(publicPath, value) {
|
|
177
|
+
const normalizedValue = normalizeKey(value);
|
|
178
|
+
const base = String(publicPath || "").trim();
|
|
179
|
+
if (!base)
|
|
180
|
+
return normalizedValue;
|
|
181
|
+
if (base === "/")
|
|
182
|
+
return normalizedValue ? `/${normalizedValue}` : "/";
|
|
183
|
+
return `${base.replace(/\/+$/g, "")}/${normalizedValue.replace(/^\/+/g, "")}`;
|
|
184
|
+
}
|
|
185
|
+
function resolveEntryKey(manifest, entryId, from) {
|
|
186
|
+
const normalizedId = normalizeKey(entryId);
|
|
187
|
+
if (!normalizedId)
|
|
188
|
+
return "";
|
|
189
|
+
if (from === "entryKey") {
|
|
190
|
+
return manifest.entries[normalizedId] ? normalizedId : "";
|
|
191
|
+
}
|
|
192
|
+
if (from === "entryName") {
|
|
193
|
+
return manifest.entryNames[normalizedId] || "";
|
|
194
|
+
}
|
|
195
|
+
if (from === "entrySource") {
|
|
196
|
+
return manifest.entrySources[normalizedId] || "";
|
|
197
|
+
}
|
|
198
|
+
if (from === "entryOutput") {
|
|
199
|
+
return manifest.entryOutputs[normalizedId] || "";
|
|
200
|
+
}
|
|
201
|
+
return manifest.entries[normalizedId]
|
|
202
|
+
? normalizedId
|
|
203
|
+
: manifest.entryNames[normalizedId]
|
|
204
|
+
|| manifest.entrySources[normalizedId]
|
|
205
|
+
|| manifest.entryOutputs[normalizedId]
|
|
206
|
+
|| "";
|
|
207
|
+
}
|
|
208
|
+
function collectAssetLinks(manifest, entryIds, options = {}) {
|
|
209
|
+
const from = options.from || "auto";
|
|
210
|
+
const publicPath = options.publicPath;
|
|
211
|
+
const entryKeys = [];
|
|
212
|
+
const missing = [];
|
|
213
|
+
const scripts = new Set();
|
|
214
|
+
const styles = new Set();
|
|
215
|
+
const assets = new Set();
|
|
216
|
+
const outputs = new Set();
|
|
217
|
+
const seenKeys = new Set();
|
|
218
|
+
for (const entryId of entryIds || []) {
|
|
219
|
+
const entryKey = resolveEntryKey(manifest, entryId, from);
|
|
220
|
+
if (!entryKey) {
|
|
221
|
+
const normalizedId = normalizeKey(entryId);
|
|
222
|
+
if (normalizedId && !missing.includes(normalizedId)) {
|
|
223
|
+
missing.push(normalizedId);
|
|
224
|
+
}
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (seenKeys.has(entryKey))
|
|
228
|
+
continue;
|
|
229
|
+
seenKeys.add(entryKey);
|
|
230
|
+
entryKeys.push(entryKey);
|
|
231
|
+
const entry = manifest.entries[entryKey];
|
|
232
|
+
if (!entry)
|
|
233
|
+
continue;
|
|
234
|
+
for (const output of entry.outputs) {
|
|
235
|
+
outputs.add(toPublicPath(publicPath, output));
|
|
236
|
+
}
|
|
237
|
+
for (const asset of entry.assets) {
|
|
238
|
+
assets.add(toPublicPath(publicPath, asset));
|
|
239
|
+
}
|
|
240
|
+
for (const style of entry.css) {
|
|
241
|
+
styles.add(toPublicPath(publicPath, style));
|
|
242
|
+
}
|
|
243
|
+
if (/\.(?:[mc]?js)$/i.test(entry.file)) {
|
|
244
|
+
scripts.add(toPublicPath(publicPath, entry.file));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
entryKeys,
|
|
249
|
+
scripts: Array.from(scripts),
|
|
250
|
+
styles: Array.from(styles),
|
|
251
|
+
assets: Array.from(assets),
|
|
252
|
+
outputs: Array.from(outputs),
|
|
253
|
+
missing,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
export { buildAssetManifest, collectAssetLinks };
|
|
257
|
+
//# sourceMappingURL=asset-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-manifest.js","sourceRoot":"","sources":["../../src/core/asset-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,OAAO,EAAE,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C,CAAC;QAC9C,CAAC;QAED,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QAC5B,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QAC5B,OAAO;KACR,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/core/discovery.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/core/discovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/core/discovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EAGf,MAAM,aAAa,CAAC;AAyBrB,QAAA,MAAM,oBAAoB,sBAAsB,CAAC;AAQjD,KAAK,yBAAyB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM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,GAChB,CAAC"}
|
package/dist/core/discovery.js
CHANGED
|
@@ -3,6 +3,23 @@ import fsp from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
const DEFAULT_DISCOVERY_EXTENSIONS = [".css", ".js", ".jsx", ".scss", ".ts", ".tsx"];
|
|
5
5
|
const DEFAULT_IGNORE_DIRS = [".git", "coverage", "dist", "node_modules"];
|
|
6
|
+
const DEFAULT_DISCOVERY_BUNDLE_MAX_SIZE = 50 * 1024 * 1024;
|
|
7
|
+
const DEFAULT_DISCOVERY_BUNDLE_GROUPS = [
|
|
8
|
+
{
|
|
9
|
+
name: "scripts",
|
|
10
|
+
extensions: [".js", ".ts"],
|
|
11
|
+
loader: "ts",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "styles",
|
|
15
|
+
extensions: [".css", ".scss"],
|
|
16
|
+
loader: "css",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
const NORMALIZED_DISCOVERY_BUNDLE_GROUPS = DEFAULT_DISCOVERY_BUNDLE_GROUPS.map((group) => ({
|
|
20
|
+
...group,
|
|
21
|
+
extensions: new Set(group.extensions),
|
|
22
|
+
}));
|
|
6
23
|
const VIRTUAL_ENTRY_PREFIX = "trebired-virtual:";
|
|
7
24
|
function toPosixPath(value) {
|
|
8
25
|
return value.replace(/\\/g, "/");
|
|
@@ -60,6 +77,35 @@ function matchesAnyPattern(value, patterns) {
|
|
|
60
77
|
function normalizeStringList(values) {
|
|
61
78
|
return (values || []).map(normalizePathValue).filter(Boolean);
|
|
62
79
|
}
|
|
80
|
+
function parseBundleMaxSize(value) {
|
|
81
|
+
if (typeof value === "number") {
|
|
82
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
83
|
+
throw new Error("bundler-discover-bundle-invalid-max-size");
|
|
84
|
+
}
|
|
85
|
+
return Math.floor(value);
|
|
86
|
+
}
|
|
87
|
+
const raw = String(value || "").trim();
|
|
88
|
+
if (!raw)
|
|
89
|
+
return DEFAULT_DISCOVERY_BUNDLE_MAX_SIZE;
|
|
90
|
+
const match = raw.match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/i);
|
|
91
|
+
if (!match) {
|
|
92
|
+
throw new Error("bundler-discover-bundle-invalid-max-size");
|
|
93
|
+
}
|
|
94
|
+
const amount = Number(match[1]);
|
|
95
|
+
const unit = (match[2] || "b").toLowerCase();
|
|
96
|
+
const multiplier = unit === "gb"
|
|
97
|
+
? 1024 * 1024 * 1024
|
|
98
|
+
: unit === "mb"
|
|
99
|
+
? 1024 * 1024
|
|
100
|
+
: unit === "kb"
|
|
101
|
+
? 1024
|
|
102
|
+
: 1;
|
|
103
|
+
const resolved = Math.floor(amount * multiplier);
|
|
104
|
+
if (!Number.isFinite(resolved) || resolved <= 0) {
|
|
105
|
+
throw new Error("bundler-discover-bundle-invalid-max-size");
|
|
106
|
+
}
|
|
107
|
+
return resolved;
|
|
108
|
+
}
|
|
63
109
|
function normalizeDiscoverOptions(rootDir, discover) {
|
|
64
110
|
const list = Array.isArray(discover) ? discover : discover ? [discover] : [];
|
|
65
111
|
return list
|
|
@@ -84,6 +130,7 @@ function normalizeDiscoverOptions(rootDir, discover) {
|
|
|
84
130
|
...normalizeStringList(item.ignoreDirs),
|
|
85
131
|
].map((value) => path.basename(value))),
|
|
86
132
|
include: normalizeStringList(item.include),
|
|
133
|
+
maxBundleSize: parseBundleMaxSize(item.maxBundleSize),
|
|
87
134
|
namePrefix: normalizePathValue(item.namePrefix || ""),
|
|
88
135
|
};
|
|
89
136
|
});
|
|
@@ -173,6 +220,124 @@ function buildDiscoveredEntryName(args) {
|
|
|
173
220
|
const withoutExt = ext ? args.relativePath.slice(0, -ext.length) : args.relativePath;
|
|
174
221
|
return normalizePathValue([args.config.namePrefix, withoutExt].filter(Boolean).join("/"));
|
|
175
222
|
}
|
|
223
|
+
function createStableBundleId(value) {
|
|
224
|
+
let hash = 2166136261;
|
|
225
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
226
|
+
hash ^= value.charCodeAt(index);
|
|
227
|
+
hash = Math.imul(hash, 16777619);
|
|
228
|
+
}
|
|
229
|
+
return (hash >>> 0).toString(36);
|
|
230
|
+
}
|
|
231
|
+
function resolveBundleGroup(entry) {
|
|
232
|
+
const ext = path.extname(entry.path).toLowerCase();
|
|
233
|
+
return NORMALIZED_DISCOVERY_BUNDLE_GROUPS.find((group) => group.extensions.has(ext));
|
|
234
|
+
}
|
|
235
|
+
function toRootImportSpecifier(rootDir, absPath) {
|
|
236
|
+
const rel = normalizePathValue(path.relative(rootDir, absPath));
|
|
237
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
238
|
+
}
|
|
239
|
+
function buildBundleContents(args) {
|
|
240
|
+
if (args.loader === "css") {
|
|
241
|
+
return args.files
|
|
242
|
+
.map((file) => `@import ${JSON.stringify(toRootImportSpecifier(args.rootDir, file.path))};`)
|
|
243
|
+
.join("\n");
|
|
244
|
+
}
|
|
245
|
+
return args.files
|
|
246
|
+
.map((file) => `import ${JSON.stringify(toRootImportSpecifier(args.rootDir, file.path))};`)
|
|
247
|
+
.join("\n");
|
|
248
|
+
}
|
|
249
|
+
function splitEntriesByMaxSize(args) {
|
|
250
|
+
const chunks = [];
|
|
251
|
+
let current = [];
|
|
252
|
+
let currentSize = 0;
|
|
253
|
+
for (const entry of args.entries) {
|
|
254
|
+
const nextSize = currentSize + entry.bytes;
|
|
255
|
+
if (current.length > 0 && nextSize > args.maxSize) {
|
|
256
|
+
chunks.push(current);
|
|
257
|
+
current = [];
|
|
258
|
+
currentSize = 0;
|
|
259
|
+
}
|
|
260
|
+
current.push(entry);
|
|
261
|
+
currentSize += entry.bytes;
|
|
262
|
+
}
|
|
263
|
+
if (current.length > 0) {
|
|
264
|
+
chunks.push(current);
|
|
265
|
+
}
|
|
266
|
+
return chunks;
|
|
267
|
+
}
|
|
268
|
+
async function toBundledDiscoverEntries(args) {
|
|
269
|
+
const resolved = await Promise.all(args.records.map(async (record) => {
|
|
270
|
+
const group = resolveBundleGroup(record);
|
|
271
|
+
if (!group) {
|
|
272
|
+
return {
|
|
273
|
+
group: undefined,
|
|
274
|
+
record,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
const stats = await fsp.stat(record.path);
|
|
278
|
+
const bytes = Math.max(stats.size, 1);
|
|
279
|
+
if (bytes > args.config.maxBundleSize) {
|
|
280
|
+
throw new Error(`bundler-discover-bundle-file-too-large :: ${normalizePathValue(path.relative(args.rootDir, record.path))}`);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
group,
|
|
284
|
+
record: {
|
|
285
|
+
...record,
|
|
286
|
+
bytes,
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
}));
|
|
290
|
+
const passthrough = [];
|
|
291
|
+
const grouped = new Map();
|
|
292
|
+
for (const item of resolved) {
|
|
293
|
+
if (!item.group) {
|
|
294
|
+
passthrough.push(item.record);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const existing = grouped.get(item.group.name);
|
|
298
|
+
if (existing) {
|
|
299
|
+
existing.files.push(item.record);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
grouped.set(item.group.name, {
|
|
303
|
+
files: [item.record],
|
|
304
|
+
group: item.group,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const bundledRecords = [];
|
|
308
|
+
for (const [groupName, value] of Array.from(grouped.entries()).sort(([a], [b]) => a.localeCompare(b))) {
|
|
309
|
+
const bundleId = createStableBundleId(JSON.stringify({
|
|
310
|
+
dir: args.config.dir,
|
|
311
|
+
exclude: args.config.exclude,
|
|
312
|
+
extensions: args.config.extensions,
|
|
313
|
+
groupName,
|
|
314
|
+
include: args.config.include,
|
|
315
|
+
maxBundleSize: args.config.maxBundleSize,
|
|
316
|
+
namePrefix: args.config.namePrefix,
|
|
317
|
+
}));
|
|
318
|
+
const chunks = splitEntriesByMaxSize({
|
|
319
|
+
entries: value.files.sort((a, b) => a.name.localeCompare(b.name) || a.path.localeCompare(b.path)),
|
|
320
|
+
maxSize: args.config.maxBundleSize,
|
|
321
|
+
});
|
|
322
|
+
chunks.forEach((chunk, index) => {
|
|
323
|
+
const suffix = chunks.length > 1 ? `-${index + 1}` : "";
|
|
324
|
+
const name = `bundle-${bundleId}${suffix}`;
|
|
325
|
+
bundledRecords.push({
|
|
326
|
+
contents: buildBundleContents({
|
|
327
|
+
files: chunk,
|
|
328
|
+
loader: value.group.loader,
|
|
329
|
+
rootDir: args.rootDir,
|
|
330
|
+
}),
|
|
331
|
+
name,
|
|
332
|
+
path: `${VIRTUAL_ENTRY_PREFIX}${name}`,
|
|
333
|
+
source: "virtual",
|
|
334
|
+
virtualLoader: value.group.loader,
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return [...passthrough, ...bundledRecords]
|
|
339
|
+
.sort((a, b) => a.name.localeCompare(b.name) || a.path.localeCompare(b.path));
|
|
340
|
+
}
|
|
176
341
|
async function walkDiscoveredEntries(config) {
|
|
177
342
|
if (!fs.existsSync(config.dirAbs))
|
|
178
343
|
return [];
|
|
@@ -217,7 +382,14 @@ async function walkDiscoveredEntries(config) {
|
|
|
217
382
|
async function resolveBundlerEntries(options, rootDir, settings = {}) {
|
|
218
383
|
const manual = normalizeManualEntries(options.entries, rootDir);
|
|
219
384
|
const virtual = normalizeVirtualEntries(options.virtualEntries);
|
|
220
|
-
const discoveredGroups = await Promise.all(normalizeDiscoverOptions(rootDir, options.discover).map(
|
|
385
|
+
const discoveredGroups = await Promise.all(normalizeDiscoverOptions(rootDir, options.discover).map(async (config) => {
|
|
386
|
+
const records = await walkDiscoveredEntries(config);
|
|
387
|
+
return toBundledDiscoverEntries({
|
|
388
|
+
config,
|
|
389
|
+
records,
|
|
390
|
+
rootDir,
|
|
391
|
+
});
|
|
392
|
+
}));
|
|
221
393
|
const discovered = discoveredGroups.flat();
|
|
222
394
|
const deduped = dedupeEntriesBySourcePath([...manual, ...virtual, ...discovered]);
|
|
223
395
|
const all = deduped.records;
|