@trebired/bundler 2.0.0 → 3.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 +12 -0
- package/README.md +207 -287
- package/dist/core/asset-manifest.d.ts.map +1 -1
- package/dist/core/asset-manifest.js +70 -72
- package/dist/core/asset-manifest.js.map +1 -1
- package/dist/core/build.d.ts.map +1 -1
- package/dist/core/build.js +5 -10
- package/dist/core/build.js.map +1 -1
- package/dist/core/derive-manifest.d.ts.map +1 -1
- package/dist/core/derive-manifest.js +4 -0
- package/dist/core/derive-manifest.js.map +1 -1
- package/dist/core/discovery.d.ts +13 -17
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +276 -277
- package/dist/core/discovery.js.map +1 -1
- package/dist/core/esbuild-options.d.ts +1 -3
- package/dist/core/esbuild-options.d.ts.map +1 -1
- package/dist/core/esbuild-options.js +4 -21
- package/dist/core/esbuild-options.js.map +1 -1
- package/dist/core/manifest.d.ts +2 -2
- package/dist/core/manifest.d.ts.map +1 -1
- package/dist/core/manifest.js +2 -11
- package/dist/core/manifest.js.map +1 -1
- package/dist/core/shared.d.ts +3 -9
- package/dist/core/shared.d.ts.map +1 -1
- package/dist/core/shared.js +5 -22
- package/dist/core/shared.js.map +1 -1
- package/dist/core/watch.d.ts.map +1 -1
- package/dist/core/watch.js +20 -32
- package/dist/core/watch.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/virtual-entries.js +1 -1
- package/dist/plugins/virtual-entries.js.map +1 -1
- package/dist/types.d.ts +67 -32
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to `@trebired/bundler` will be documented here.
|
|
|
4
4
|
|
|
5
5
|
This project follows semantic versioning once published.
|
|
6
6
|
|
|
7
|
+
## 3.0.0
|
|
8
|
+
|
|
9
|
+
- Rebuilt `@trebired/bundler` around discover-only configuration and removed public manual `entries`.
|
|
10
|
+
- Removed public `virtualEntries`; grouped bundle entry modules are now internal implementation detail only.
|
|
11
|
+
- Removed package-owned build `mode` profiles in favor of explicit `minify`, `stripComments`, `sourcemap`, and related esbuild-like flags.
|
|
12
|
+
- Replaced top-level discover include/exclude behavior with ordered discover `rules` using `entry`, `bundle`, and `ignore` strategies.
|
|
13
|
+
- Added per-rule `maxBundleSize` for grouped bundles, still defaulting to `50mb`.
|
|
14
|
+
- Kept grouped bundle filenames package-owned under the `bundle-...` naming scheme.
|
|
15
|
+
- Added source ownership metadata to build results and watch hooks so runtime code can resolve source file -> owning entry key.
|
|
16
|
+
- Redesigned the runtime asset manifest around `entries`, `sources`, `entryOutputs`, `outputs`, and `rules`, including grouped bundle membership and ignored-source tracking.
|
|
17
|
+
- Made `.client.*` and `.defer.*` entries fail when they import JS or TS files owned by grouped bundle rules.
|
|
18
|
+
|
|
7
19
|
## 2.0.0
|
|
8
20
|
|
|
9
21
|
- Changed `discover` to group discovered `.js` and `.ts` files into auto-named script bundles by default.
|
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# @trebired/bundler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Discover-only bundler wrapper around `esbuild` with SCSS support, watch mode, source annotations, and a runtime-friendly asset manifest.
|
|
4
4
|
|
|
5
|
-
`@trebired/bundler`
|
|
6
|
-
|
|
7
|
-
The default build mode is `compact`. It enables minification and comment stripping unless you turn on source annotations.
|
|
5
|
+
`@trebired/bundler` now has one public entry model: discovery rules. You describe what the bundler should find, whether each matched file should stay isolated, join a grouped bundle, or be ignored, and the package handles the rest.
|
|
8
6
|
|
|
9
7
|
## Install
|
|
10
8
|
|
|
@@ -14,38 +12,6 @@ Runtime support: Bun 1+ and Node.js 18+.
|
|
|
14
12
|
npm install @trebired/bundler
|
|
15
13
|
```
|
|
16
14
|
|
|
17
|
-
## What It Is For
|
|
18
|
-
|
|
19
|
-
Use this when:
|
|
20
|
-
|
|
21
|
-
- you want a bundling package that fits alongside other packages published by Trebired instead of wiring `esbuild` directly in every project
|
|
22
|
-
- you need one package that handles `tsx`, `jsx`, `ts`, `js`, `scss`, and `css`
|
|
23
|
-
- you want the package to discover entry files by walking your source tree
|
|
24
|
-
- you want in-memory generated entry modules without writing temp files
|
|
25
|
-
- you want watch mode and config-driven CLI commands without building a separate toolchain wrapper
|
|
26
|
-
- you want newly created matching files to join the build without external entry regeneration code
|
|
27
|
-
- you want a manifest describing resolved entries and generated outputs
|
|
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
|
|
32
|
-
- you want rebuild hooks instead of scraping logger text
|
|
33
|
-
- you want generated bundles to optionally include inline comments that point back to the original source file path
|
|
34
|
-
- you want production-lean defaults with minified output and stripped comments
|
|
35
|
-
- you want a stronger `extreme` mode for the most aggressive package-owned compacting defaults
|
|
36
|
-
- you want package-owned logs routed through `@trebired/logger-adapter`
|
|
37
|
-
|
|
38
|
-
## What It Does Not Do
|
|
39
|
-
|
|
40
|
-
This package does not:
|
|
41
|
-
|
|
42
|
-
- replace `esbuild`
|
|
43
|
-
- provide a dev server or HMR
|
|
44
|
-
- invent a separate package-specific module graph format
|
|
45
|
-
- manage HTML templates or deployment assets for you
|
|
46
|
-
|
|
47
|
-
If you want a fast bundling wrapper from the Trebired package ecosystem, use this package. If you want a fully custom bundler runtime, this package is intentionally not that.
|
|
48
|
-
|
|
49
15
|
## Quick Start
|
|
50
16
|
|
|
51
17
|
```ts
|
|
@@ -53,14 +19,37 @@ import { bundle } from "@trebired/bundler";
|
|
|
53
19
|
|
|
54
20
|
await bundle({
|
|
55
21
|
discover: {
|
|
56
|
-
dir: "./src",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
22
|
+
dir: "./src/frontend",
|
|
23
|
+
rules: [
|
|
24
|
+
{
|
|
25
|
+
key: "client",
|
|
26
|
+
include: ["**/*.client.ts", "**/*.client.tsx"],
|
|
27
|
+
strategy: "entry",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: "defer",
|
|
31
|
+
include: ["**/*.defer.ts"],
|
|
32
|
+
strategy: "entry",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: "global-style",
|
|
36
|
+
include: ["css/**/*.css", "css/**/*.scss"],
|
|
37
|
+
strategy: "bundle",
|
|
38
|
+
maxBundleSize: "50mb",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "shared-script",
|
|
42
|
+
include: ["**/*.ts", "**/*.js"],
|
|
43
|
+
exclude: ["**/*.client.ts", "**/*.client.tsx", "**/*.defer.ts"],
|
|
44
|
+
strategy: "bundle",
|
|
45
|
+
maxBundleSize: "50mb",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "ignored-tests",
|
|
49
|
+
include: ["**/*.test.*", "**/*.spec.*"],
|
|
50
|
+
strategy: "ignore",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
64
53
|
},
|
|
65
54
|
outDir: "./dist",
|
|
66
55
|
sourcemap: "external",
|
|
@@ -79,10 +68,25 @@ import { defineBundlerConfig } from "@trebired/bundler";
|
|
|
79
68
|
export default defineBundlerConfig({
|
|
80
69
|
discover: {
|
|
81
70
|
dir: "./src/frontend",
|
|
82
|
-
|
|
71
|
+
rules: [
|
|
72
|
+
{
|
|
73
|
+
key: "client",
|
|
74
|
+
include: ["**/*.client.ts", "**/*.client.tsx"],
|
|
75
|
+
strategy: "entry",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "global-style",
|
|
79
|
+
include: ["css/**/*.css", "css/**/*.scss"],
|
|
80
|
+
strategy: "bundle",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: "shared-script",
|
|
84
|
+
include: ["shared/**/*.ts", "shared/**/*.js"],
|
|
85
|
+
strategy: "bundle",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
83
88
|
},
|
|
84
89
|
outDir: "./dist",
|
|
85
|
-
annotateSources: true,
|
|
86
90
|
manifest: true,
|
|
87
91
|
});
|
|
88
92
|
```
|
|
@@ -94,81 +98,82 @@ trebired-bundler build --config ./bundler.config.mjs
|
|
|
94
98
|
trebired-bundler watch --config ./bundler.config.mjs
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
##
|
|
101
|
+
## Discover Rules
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
Rules are ordered. First match wins.
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
dir: "./src/frontend",
|
|
105
|
-
include: ["**/*.tsx", "**/*.js", "**/*.ts", "**/*.css", "**/*.scss"],
|
|
106
|
-
exclude: ["**/*.test.tsx"],
|
|
107
|
-
maxBundleSize: "50mb",
|
|
108
|
-
},
|
|
109
|
-
outDir: "./dist",
|
|
110
|
-
});
|
|
111
|
-
```
|
|
105
|
+
- `entry`: keep one output entry per matched file
|
|
106
|
+
- `bundle`: group all matched files together, then split only when the whole group exceeds `maxBundleSize`
|
|
107
|
+
- `ignore`: track the file as intentionally ignored and exclude it from outputs
|
|
112
108
|
|
|
113
|
-
|
|
109
|
+
Every discovered file must match exactly one rule. If a file is in scope and matches nothing, the build fails.
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
- matches files by extension plus optional include and exclude patterns
|
|
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
|
|
120
|
-
- rebuilds the entry list during watch mode when matching files are added or removed
|
|
111
|
+
### `maxBundleSize`
|
|
121
112
|
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
113
|
+
- only valid on `bundle` rules
|
|
114
|
+
- defaults to `50mb`
|
|
115
|
+
- accepts bytes or strings like `"512kb"`, `"50mb"`, or `"1gb"`
|
|
116
|
+
- splits by summed source-file size before handing grouped parts to `esbuild`
|
|
117
|
+
- fails the build if a single grouped file is larger than the configured limit
|
|
126
118
|
|
|
127
|
-
|
|
119
|
+
### Bundle Naming
|
|
128
120
|
|
|
129
|
-
|
|
121
|
+
Grouped outputs always use package-owned names:
|
|
130
122
|
|
|
131
|
-
|
|
123
|
+
- `bundle-<stable-id>.js`
|
|
124
|
+
- `bundle-<stable-id>-2.js`
|
|
125
|
+
- `bundle-<stable-id>.css`
|
|
126
|
+
- `bundle-<stable-id>-2.css`
|
|
132
127
|
|
|
133
|
-
|
|
128
|
+
Callers do not provide custom grouped bundle names.
|
|
134
129
|
|
|
135
|
-
|
|
136
|
-
- whether each entry came from `manual` config or `discover`
|
|
137
|
-
- generated output files
|
|
138
|
-
- a runtime-friendly `assetManifest` keyed by entry source path, with lookup maps for entry names and emitted outputs
|
|
130
|
+
## Frontend Conventions
|
|
139
131
|
|
|
140
|
-
|
|
132
|
+
This API is meant for conventions like:
|
|
141
133
|
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
- `*.client.ts`
|
|
135
|
+
- `*.client.tsx`
|
|
136
|
+
- `*.defer.ts`
|
|
137
|
+
- global `css/**/*.css`
|
|
138
|
+
- global `css/**/*.scss`
|
|
144
139
|
|
|
145
|
-
|
|
146
|
-
entries: {
|
|
147
|
-
app: "./src/app.tsx",
|
|
148
|
-
},
|
|
149
|
-
outDir: "./dist",
|
|
150
|
-
});
|
|
140
|
+
Typical setup:
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
142
|
+
- client boot files use `strategy: "entry"`
|
|
143
|
+
- defer boot files use `strategy: "entry"`
|
|
144
|
+
- shared JS/TS helpers use `strategy: "bundle"`
|
|
145
|
+
- global CSS/SCSS uses `strategy: "bundle"`
|
|
146
|
+
- tests and non-runtime files use `strategy: "ignore"`
|
|
157
147
|
|
|
158
|
-
|
|
148
|
+
Important behavior:
|
|
159
149
|
|
|
160
|
-
- `
|
|
161
|
-
-
|
|
162
|
-
- `allOutputs`: flat normalized output index
|
|
150
|
+
- grouped `bundle` rules must stay style-only or script-only; mixing CSS/SCSS with JS/TS in one rule fails
|
|
151
|
+
- `*.client.*` and `*.defer.*` entries may not import JS/TS files owned by a grouped bundle rule; that fails the build because those files are treated as shared standalone bundles, not implicit app-entry dependencies
|
|
163
152
|
|
|
164
|
-
|
|
153
|
+
## Manifest
|
|
154
|
+
|
|
155
|
+
Set `manifest: true` to write `dist/bundler-manifest.json`, or pass `manifest: { file: "custom-name.json" }`.
|
|
156
|
+
|
|
157
|
+
The build result also exposes `assetManifest` directly.
|
|
165
158
|
|
|
166
159
|
```ts
|
|
167
160
|
import { buildAssetManifest, bundle, collectAssetLinks } from "@trebired/bundler";
|
|
168
161
|
|
|
169
162
|
const result = await bundle({
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
discover: {
|
|
164
|
+
dir: "./src/frontend",
|
|
165
|
+
rules: [
|
|
166
|
+
{
|
|
167
|
+
key: "client",
|
|
168
|
+
include: ["**/*.client.ts", "**/*.client.tsx"],
|
|
169
|
+
strategy: "entry",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: "global-style",
|
|
173
|
+
include: ["css/**/*.css", "css/**/*.scss"],
|
|
174
|
+
strategy: "bundle",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
172
177
|
},
|
|
173
178
|
outDir: "./dist",
|
|
174
179
|
});
|
|
@@ -177,55 +182,79 @@ const assetManifest = result.assetManifest || buildAssetManifest({
|
|
|
177
182
|
metafile: result.metafile!,
|
|
178
183
|
outDir: "./dist",
|
|
179
184
|
rootDir: process.cwd(),
|
|
180
|
-
|
|
185
|
+
resolvedDiscovery: result.resolvedDiscovery,
|
|
181
186
|
});
|
|
182
187
|
|
|
183
|
-
const assets = collectAssetLinks(assetManifest, [
|
|
188
|
+
const assets = collectAssetLinks(assetManifest, [
|
|
189
|
+
"src/frontend/home.client.tsx",
|
|
190
|
+
], {
|
|
191
|
+
from: "source",
|
|
184
192
|
publicPath: "/",
|
|
185
193
|
});
|
|
186
194
|
```
|
|
187
195
|
|
|
188
|
-
|
|
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`
|
|
196
|
+
### Asset Manifest Shape
|
|
194
197
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Use `virtualEntries` when you want generated entry modules without writing temporary files:
|
|
198
|
+
`result.entries` is a source ownership map:
|
|
198
199
|
|
|
199
200
|
```ts
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
app: "./src/app.tsx",
|
|
203
|
-
},
|
|
204
|
-
virtualEntries: {
|
|
205
|
-
"entry-server": `
|
|
206
|
-
import { message } from "./src/lib/message";
|
|
207
|
-
export const rendered = message.toUpperCase();
|
|
208
|
-
`,
|
|
209
|
-
"global.client": `
|
|
210
|
-
import "./src/styles/site.scss";
|
|
211
|
-
console.log("global-client");
|
|
212
|
-
`,
|
|
213
|
-
},
|
|
214
|
-
outDir: "./dist",
|
|
215
|
-
});
|
|
201
|
+
Record<string, string>
|
|
202
|
+
// source path -> owning entry key
|
|
216
203
|
```
|
|
217
204
|
|
|
218
|
-
|
|
205
|
+
`assetManifest` exposes:
|
|
206
|
+
|
|
207
|
+
- `sources[sourcePath]`: source file -> owning entry key, rule key, strategy, outputs
|
|
208
|
+
- `entries[entryKey]`: entry or grouped bundle -> owned sources, outputs, JS, CSS, assets
|
|
209
|
+
- `entryOutputs[emittedFile]`: emitted entry output -> entry key
|
|
210
|
+
- `outputs[outputFile]`: normalized output metadata
|
|
211
|
+
- `rules[ruleKey]`: grouped entry keys plus ignored sources for that rule
|
|
212
|
+
|
|
213
|
+
This lets runtime code resolve either:
|
|
214
|
+
|
|
215
|
+
- a source path to its owning entry key
|
|
216
|
+
- an entry key to the emitted scripts/styles/assets
|
|
217
|
+
- a grouped bundle back to the exact source files it owns
|
|
218
|
+
|
|
219
|
+
### Collecting Runtime Links
|
|
220
|
+
|
|
221
|
+
Use `collectAssetLinks()` when app code needs scripts and styles for one or more sources or entry keys.
|
|
222
|
+
|
|
223
|
+
Supported lookup modes:
|
|
219
224
|
|
|
220
|
-
|
|
225
|
+
- `from: "source"`
|
|
226
|
+
- `from: "entryKey"`
|
|
227
|
+
- `from: "entryOutput"`
|
|
228
|
+
- `from: "auto"` (default)
|
|
221
229
|
|
|
222
|
-
|
|
230
|
+
## Watch Mode
|
|
231
|
+
|
|
232
|
+
`watch()` stays discover-driven.
|
|
233
|
+
|
|
234
|
+
- added or removed matching files trigger a discovery rescan
|
|
235
|
+
- if source ownership changes, the bundler rebuilds the esbuild context
|
|
236
|
+
- `onEntrySetChanged()` receives the new source ownership map
|
|
237
|
+
- `onRebuilt()` receives the full `BundlerBuildResult`
|
|
238
|
+
- invalid intermediate states still surface failures, but the watcher keeps running and recovers on the next valid filesystem change
|
|
223
239
|
|
|
224
240
|
```ts
|
|
225
|
-
|
|
241
|
+
import { watch } from "@trebired/bundler";
|
|
242
|
+
|
|
243
|
+
const session = await watch({
|
|
226
244
|
discover: {
|
|
227
|
-
dir: "./src/
|
|
228
|
-
|
|
245
|
+
dir: "./src/frontend",
|
|
246
|
+
rules: [
|
|
247
|
+
{
|
|
248
|
+
key: "client",
|
|
249
|
+
include: ["**/*.client.ts", "**/*.client.tsx"],
|
|
250
|
+
strategy: "entry",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "shared-script",
|
|
254
|
+
include: ["shared/**/*.ts", "shared/**/*.js"],
|
|
255
|
+
strategy: "bundle",
|
|
256
|
+
},
|
|
257
|
+
],
|
|
229
258
|
},
|
|
230
259
|
outDir: "./dist",
|
|
231
260
|
async onEntrySetChanged(entries) {
|
|
@@ -235,13 +264,13 @@ await watch({
|
|
|
235
264
|
console.log(result.outputs);
|
|
236
265
|
},
|
|
237
266
|
});
|
|
238
|
-
```
|
|
239
267
|
|
|
240
|
-
|
|
268
|
+
await session.dispose();
|
|
269
|
+
```
|
|
241
270
|
|
|
242
271
|
## Import Graph Walking
|
|
243
272
|
|
|
244
|
-
Use `walkImportGraph()` when a higher-level
|
|
273
|
+
Use `walkImportGraph()` when a higher-level tool needs to inspect internal source dependencies without bundling:
|
|
245
274
|
|
|
246
275
|
```ts
|
|
247
276
|
import { walkImportGraph } from "@trebired/bundler";
|
|
@@ -252,131 +281,38 @@ const graph = await walkImportGraph({
|
|
|
252
281
|
});
|
|
253
282
|
```
|
|
254
283
|
|
|
255
|
-
|
|
284
|
+
It resolves:
|
|
256
285
|
|
|
257
|
-
-
|
|
258
|
-
-
|
|
259
|
-
-
|
|
286
|
+
- relative imports
|
|
287
|
+
- re-exports
|
|
288
|
+
- string-literal dynamic imports
|
|
289
|
+
- tsconfig `paths`
|
|
260
290
|
|
|
261
|
-
##
|
|
262
|
-
|
|
263
|
-
`@trebired/bundler` now defaults to production-lean output through `mode: "compact"`:
|
|
264
|
-
|
|
265
|
-
- `mode` defaults to `"compact"`
|
|
266
|
-
- `minify` defaults to `true`
|
|
267
|
-
- `stripComments` defaults to `true`
|
|
268
|
-
- source annotations stay opt-in through `annotateSources: true`
|
|
269
|
-
|
|
270
|
-
Available modes:
|
|
271
|
-
|
|
272
|
-
- `debug`: readable output, no minification, no comment stripping by default
|
|
273
|
-
- `compact`: minified output with stripped preserved comments by default
|
|
274
|
-
- `extreme`: compact mode with the strongest package-owned compacting profile, without renaming classes or artifacts
|
|
275
|
-
|
|
276
|
-
If you want a more readable debug build:
|
|
277
|
-
|
|
278
|
-
```ts
|
|
279
|
-
await bundle({
|
|
280
|
-
entries: {
|
|
281
|
-
app: "./src/app.tsx",
|
|
282
|
-
},
|
|
283
|
-
mode: "debug",
|
|
284
|
-
minify: false,
|
|
285
|
-
outDir: "./dist",
|
|
286
|
-
stripComments: false,
|
|
287
|
-
});
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## Extreme Mode
|
|
291
|
-
|
|
292
|
-
Use `mode: "extreme"` when you want the package to apply its strongest built-in compacting profile:
|
|
291
|
+
## Public Config Shape
|
|
293
292
|
|
|
294
293
|
```ts
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
This mode enables:
|
|
305
|
-
|
|
306
|
-
- minification
|
|
307
|
-
- stripped preserved comments
|
|
308
|
-
- stable entry, chunk, and asset naming
|
|
309
|
-
|
|
310
|
-
Today `extreme` intentionally keeps the same readable artifact and class names as other modes. The difference is its production-lean compacting profile, not obfuscation.
|
|
311
|
-
|
|
312
|
-
## Source Annotation Comments
|
|
313
|
-
|
|
314
|
-
Set `annotateSources: true` to inject preserved inline comments into bundled output.
|
|
315
|
-
|
|
316
|
-
JavaScript and TypeScript modules are annotated like this:
|
|
317
|
-
|
|
318
|
-
```js
|
|
319
|
-
/*! source: src/app.tsx */
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
CSS and SCSS sources are annotated like this:
|
|
323
|
-
|
|
324
|
-
```css
|
|
325
|
-
/*! source: src/styles/site.scss */
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
These comments are emitted with project-relative POSIX-style paths so the generated bundle still points back to the original source file that contributed that segment.
|
|
329
|
-
|
|
330
|
-
## Supported File Types
|
|
331
|
-
|
|
332
|
-
The package supports:
|
|
333
|
-
|
|
334
|
-
- `js`
|
|
335
|
-
- `jsx`
|
|
336
|
-
- `ts`
|
|
337
|
-
- `tsx`
|
|
338
|
-
- `css`
|
|
339
|
-
- `scss`
|
|
340
|
-
|
|
341
|
-
Plain JS, TS, JSX, TSX, and CSS are handled directly by `esbuild`. SCSS is compiled with `sass-embedded` and then passed back into the bundle pipeline as CSS.
|
|
342
|
-
|
|
343
|
-
## Logging
|
|
344
|
-
|
|
345
|
-
Package-owned logs are normalized through `@trebired/logger-adapter`, the same way other packages published by Trebired do it.
|
|
346
|
-
|
|
347
|
-
You can pass:
|
|
348
|
-
|
|
349
|
-
- a logger using the same call shape as other Trebired packages
|
|
350
|
-
- an event sink logger
|
|
351
|
-
- a common logger object
|
|
352
|
-
- a custom `loggerAdapter(logger, event)` for exact output control
|
|
294
|
+
type BundlerDiscoverRuleStrategy = "entry" | "bundle" | "ignore";
|
|
295
|
+
|
|
296
|
+
type BundlerDiscoverRule = {
|
|
297
|
+
key: string;
|
|
298
|
+
include: string[];
|
|
299
|
+
exclude?: string[];
|
|
300
|
+
strategy: BundlerDiscoverRuleStrategy;
|
|
301
|
+
maxBundleSize?: number | string;
|
|
302
|
+
};
|
|
353
303
|
|
|
354
|
-
|
|
304
|
+
type BundlerDiscoverOptions = {
|
|
305
|
+
dir: string;
|
|
306
|
+
rules: BundlerDiscoverRule[];
|
|
307
|
+
ignoreDirs?: string[];
|
|
308
|
+
};
|
|
355
309
|
|
|
356
|
-
```ts
|
|
357
310
|
type BundlerOptions = {
|
|
358
|
-
|
|
359
|
-
discover?: {
|
|
360
|
-
dir: string;
|
|
361
|
-
include?: string[];
|
|
362
|
-
exclude?: string[];
|
|
363
|
-
extensions?: string[];
|
|
364
|
-
ignoreDirs?: string[];
|
|
365
|
-
namePrefix?: string;
|
|
366
|
-
} | Array<{
|
|
367
|
-
dir: string;
|
|
368
|
-
include?: string[];
|
|
369
|
-
exclude?: string[];
|
|
370
|
-
extensions?: string[];
|
|
371
|
-
ignoreDirs?: string[];
|
|
372
|
-
namePrefix?: string;
|
|
373
|
-
}>;
|
|
374
|
-
virtualEntries?: Record<string, string>;
|
|
311
|
+
discover: BundlerDiscoverOptions | BundlerDiscoverOptions[];
|
|
375
312
|
outDir: string;
|
|
376
313
|
rootDir?: string;
|
|
377
|
-
mode?: "debug" | "compact" | "extreme";
|
|
378
314
|
environment?: "browser" | "node" | "neutral";
|
|
379
|
-
format?:
|
|
315
|
+
format?: Format;
|
|
380
316
|
target?: string | string[];
|
|
381
317
|
minify?: boolean;
|
|
382
318
|
stripComments?: boolean;
|
|
@@ -387,45 +323,29 @@ type BundlerOptions = {
|
|
|
387
323
|
define?: Record<string, string>;
|
|
388
324
|
clean?: boolean;
|
|
389
325
|
annotateSources?: boolean;
|
|
390
|
-
manifest?: boolean | {
|
|
391
|
-
file?: string;
|
|
392
|
-
};
|
|
326
|
+
manifest?: boolean | { file?: string };
|
|
393
327
|
onRebuilt?: (result: BundlerBuildResult) => void | Promise<void>;
|
|
394
328
|
onEntrySetChanged?: (entries: Record<string, string>) => void | Promise<void>;
|
|
395
|
-
logger?:
|
|
396
|
-
loggerAdapter?:
|
|
329
|
+
logger?: BundlerLogger;
|
|
330
|
+
loggerAdapter?: BundlerLoggerAdapter;
|
|
397
331
|
};
|
|
332
|
+
```
|
|
398
333
|
|
|
399
|
-
|
|
400
|
-
entries: Record<string, string>;
|
|
401
|
-
outputs: string[];
|
|
402
|
-
warnings: number;
|
|
403
|
-
metafile?: object;
|
|
404
|
-
manifestPath?: string;
|
|
405
|
-
durationMs: number;
|
|
406
|
-
}>;
|
|
407
|
-
|
|
408
|
-
declare function deriveManifest(
|
|
409
|
-
metafile: object,
|
|
410
|
-
options: {
|
|
411
|
-
rootDir: string;
|
|
412
|
-
outDir: string;
|
|
413
|
-
},
|
|
414
|
-
): {
|
|
415
|
-
entries: Record<string, unknown>;
|
|
416
|
-
chunks: Record<string, unknown>;
|
|
417
|
-
allOutputs: Record<string, unknown>;
|
|
418
|
-
};
|
|
334
|
+
## Migration Notes
|
|
419
335
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
336
|
+
This release removes the old mixed entry model.
|
|
337
|
+
|
|
338
|
+
- `entries` is gone
|
|
339
|
+
- public `virtualEntries` is gone
|
|
340
|
+
- `mode` is gone
|
|
341
|
+
- `discover.include` / `discover.exclude` at the top level is replaced by ordered `discover.rules`
|
|
342
|
+
- runtime code using `entryNames` or `entrySources` should move to `assetManifest.sources` and `assetManifest.entries`
|
|
343
|
+
|
|
344
|
+
## What It Does Not Do
|
|
345
|
+
|
|
346
|
+
This package does not:
|
|
347
|
+
|
|
348
|
+
- replace `esbuild`
|
|
349
|
+
- provide a dev server or HMR
|
|
350
|
+
- invent a custom runtime module system
|
|
351
|
+
- auto-convert grouped shared JS/TS sources into dependency-safe page entry imports
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-manifest.d.ts","sourceRoot":"","sources":["../../src/core/asset-manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asset-manifest.d.ts","sourceRoot":"","sources":["../../src/core/asset-manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAEpB,gCAAgC,EAChC,0BAA0B,EAE1B,+BAA+B,EAEhC,MAAM,aAAa,CAAC;AA2GrB,iBAAS,kBAAkB,CAAC,OAAO,EAAE,gCAAgC,GAAG,oBAAoB,CA0G3F;AAqCD,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"}
|