@nullvoxpopuli/ember-rolldown 2.8.0 → 2.9.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as RolldownPluginLike } from "./plugin-like-CBvGkzCB.js";
1
+ import { t as RolldownPluginLike } from "./plugin-like-BmC0mYXP.js";
2
2
  import { Transform } from "babel-plugin-ember-template-compilation";
3
3
  import { PluginItem } from "@babel/core";
4
4
  //#region src/babel.d.ts
@@ -21,14 +21,15 @@ interface BabelOptions {
21
21
  /**
22
22
  * The babel config file to use.
23
23
  *
24
- * - `undefined`: auto-detect. A `babel.publish.config.*` (in the package root
25
- * or `config/`) wins, because this is a publish build; otherwise babel's own
26
- * config resolution applies (see `detectConfigFile`).
24
+ * - `undefined`: auto-detect.
25
+ * A `babel.publish.config.*` (in the package root or `config/`) wins,
26
+ * because this is a publish build.
27
+ * Otherwise babel's own config resolution applies (see `detectConfigFile`).
27
28
  * - a string: use that config file.
28
29
  * - `false`: ignore config files entirely.
29
30
  *
30
- * Without a config file, templates, decorators, and TypeScript are still
31
- * handled (see `defaultPlugins`).
31
+ * Without a config file, templates, decorators, and TypeScript are still handled
32
+ * (see `defaultPlugins`).
32
33
  */
33
34
  configFile?: string | false;
34
35
  /**
@@ -36,17 +37,20 @@ interface BabelOptions {
36
37
  */
37
38
  plugins?: PluginItem[];
38
39
  /**
39
- * Template AST transforms (e.g. ember-scoped-css's `scopedCSS.template()`)
40
- * passed to the default `babel-plugin-ember-template-compilation` entry.
40
+ * Template AST transforms passed to the default
41
+ * `babel-plugin-ember-template-compilation` entry.
42
+ * e.g. ember-scoped-css's `scopedCSS.template()`
41
43
  *
42
- * Only valid without a babel config file: with your own config, you list
43
- * `babel-plugin-ember-template-compilation` yourself, so its `transforms`
44
- * belong there.
44
+ * Only valid without a babel config file.
45
+ * With your own config, you list `babel-plugin-ember-template-compilation` yourself,
46
+ * so its `transforms` belong there.
45
47
  */
46
48
  templateTransforms?: Transform[];
47
49
  /**
48
- * Opt additional files into babel (see maybeBabel's `filter`). Use this to
49
- * cover addons that ship code needing babel (e.g. `ember-concurrency`).
50
+ * Opt additional files into babel (see maybeBabel's `filter`).
51
+ *
52
+ * Use this to cover addons that ship code needing babel
53
+ * (e.g. `ember-concurrency`).
50
54
  */
51
55
  filter?: {
52
56
  include: {
@@ -78,38 +82,51 @@ interface Config {
78
82
  */
79
83
  bundle?: boolean;
80
84
  /**
81
- * Options for the babel step; see `BabelOptions`.
85
+ * Options for the babel step.
86
+ * See `BabelOptions`.
82
87
  */
83
88
  babel?: BabelOptions;
84
89
  }
85
90
  /**
86
- * A batteries-included plugin for building Ember v2 libraries (addons) with
87
- * rolldown (or tsdown, which is built on rolldown).
91
+ * A batteries-included plugin for building Ember v2 libraries (addons)
92
+ * with rolldown, or with tsdown (which is built on rolldown).
93
+ *
94
+ * It bundles everything needed to compile `.gts` / `.gjs` and
95
+ * template-tag (`<template>`) source into publishable output:
96
+ *
97
+ * - `emberConfig()`
98
+ * applies sensible tsdown defaults for a library build
99
+ * (sourcemaps, `clean`, `dts`, `.js` / `.d.ts` extensions, quiet logging).
100
+ * Anything you set explicitly still wins.
88
101
  *
89
- * It bundles everything needed to compile `.gts`/`.gjs` and template-tag
90
- * (`<template>`) source into publishable output:
102
+ * - `emberIsolatedDeclarations()`
103
+ * errors when a tsconfig.json is present without `isolatedDeclarations: true`.
104
+ * That is the only declaration pipeline that can see compiled template-tag modules.
91
105
  *
92
- * - `emberConfig()` — applies sensible tsdown defaults for a library build
93
- * (sourcemaps, `clean`, `dts`, `.js`/`.d.ts` extensions, quiet logging);
94
- * anything you set explicitly still wins.
95
- * - `emberIsolatedDeclarations()` — errors when a tsconfig.json is present
96
- * without `isolatedDeclarations: true` (required: it is the only
97
- * declaration pipeline that can see compiled template-tag modules).
98
- * - `emberExternals()` — keeps your dependencies, peerDependencies, and the
99
- * ember virtual packages external, so consuming apps resolve them.
100
- * - `emberBundle()` — bundle mode only, in place of `emberExternals()`:
101
- * aliases the ember virtual packages into ember-source,
106
+ * - `emberExternals()`
107
+ * keeps your dependencies, peerDependencies, and the ember virtual packages external,
108
+ * so consuming apps resolve them.
109
+ *
110
+ * - `emberBundle()`
111
+ * bundle mode only, in place of `emberExternals()`.
112
+ * Aliases the ember virtual packages into ember-source,
102
113
  * whose export conditions pick the build to bundle.
103
- * - `emberTransform()` — preprocesses `<template>` via content-tag and maps
104
- * `.gts`/`.gjs` to `.ts`/`.js` so rolldown can understand them.
105
- * - `emberBabel()` — runs babel (template compilation, decorators, type
106
- * stripping) with `babelHelpers: "bundled"`, but only on the files that
107
- * actually need it (via `maybeBabel`); everything else stays on the fast
108
- * native transform. The library's own `babel.config.js` is used when it
109
- * exists; no config file is required.
110
114
  *
111
- * Usage in `tsdown.config.js` (import `defineConfig` from `tsdown` — or from
112
- * `rolldown` for a `rolldown.config.js` — so it carries the correct types):
115
+ * - `emberTransform()`
116
+ * preprocesses `<template>` via content-tag,
117
+ * and maps `.gts` / `.gjs` to `.ts` / `.js` so rolldown can understand them.
118
+ *
119
+ * - `emberBabel()`
120
+ * runs babel (template compilation, decorators, type stripping)
121
+ * with `babelHelpers: "bundled"`.
122
+ * Only the files that need it go through babel (via `maybeBabel`).
123
+ * Everything else stays on the fast native transform.
124
+ * The library's own `babel.config.js` is used when it exists.
125
+ * No config file is required.
126
+ *
127
+ * Usage in `tsdown.config.js`.
128
+ * Import `defineConfig` from `tsdown` (or from `rolldown` for a `rolldown.config.js`)
129
+ * so it carries the correct types:
113
130
  *
114
131
  * ```js
115
132
  * import { defineConfig } from "tsdown";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/babel.ts","../index.ts"],"mappings":";;;;UAWiB;;;;;;;;;;;;;;EAcf;EACA;;;;;;;;;;;;;EAaA;;;;EAIA,UAAU;;;;;;;;;EASV,qBAAqB;;;;;EAKrB;IACE;MACE;MACA,gBAAgB;;;;;;UCpDZ;;;;;;;;;;;;;;;;;;;EAmBR;;;;EAIA,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CM,MAAM,SAAQ,SAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/babel.ts","../index.ts"],"mappings":";;;;UAWiB;;;;;;;;;;;;;;EAcf;EACA;;;;;;;;;;;;;;EAcA;;;;EAIA,UAAU;;;;;;;;;;EAUV,qBAAqB;;;;;;;EAOrB;IACE;MACE;MACA,gBAAgB;;;;;;UCxDZ;;;;;;;;;;;;;;;;;;;EAmBR;;;;;EAKA,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDM,MAAM,SAAQ,SAAc"}
package/dist/index.js CHANGED
@@ -10,7 +10,9 @@ import pkg from "@embroider/core";
10
10
  import { Preprocessor } from "content-tag";
11
11
  import { readFile, readdir, writeFile } from "node:fs/promises";
12
12
  //#region src/babel.ts
13
- /** Tried in order, so an ESM config wins over a JSON one of the same name. */
13
+ /**
14
+ * Tried in order, so an ESM config wins over a JSON one of the same name.
15
+ */
14
16
  const PUBLISH_CONFIG_EXTENSIONS = [
15
17
  "mjs",
16
18
  "cjs",
@@ -21,22 +23,27 @@ const PUBLISH_CONFIG_EXTENSIONS = [
21
23
  "json"
22
24
  ];
23
25
  /**
24
- * Tried in order: next to package.json first, then `config/` for libraries that
25
- * keep their build configuration out of the package root.
26
+ * Tried in order:
27
+ * - next to package.json first
28
+ * - then `config/`, for libraries that keep their build configuration
29
+ * out of the package root
26
30
  */
27
31
  const PUBLISH_CONFIG_DIRECTORIES = [".", "config"];
28
32
  /**
29
- * A `babel.publish.config.*` (in the package root or `config/`), if there is
30
- * one.
31
- *
32
- * A library's plain `babel.config.*` is its *development* config: it typically
33
- * compiles `@embroider/macros` away, targets the wire format, and wires up
34
- * whatever the in-package demo app or test suite needs. None of that belongs in
35
- * a published artifact -- macros must stay for the consuming app to evaluate,
36
- * and the wire format is private between one template compiler and one glimmer
37
- * runtime. Babel's own resolution can't tell the two apart (it finds whatever
38
- * `babel.config.*` exists), so a publish build has to prefer the config named
39
- * for publishing.
33
+ * A `babel.publish.config.*` (in the package root or `config/`), if there is one.
34
+ *
35
+ * A library's plain `babel.config.*` is its *development* config.
36
+ * It typically:
37
+ * - compiles `@embroider/macros` away
38
+ * - targets the wire format
39
+ * - wires up whatever the in-package demo app or test suite needs
40
+ *
41
+ * None of that belongs in a published artifact:
42
+ * - macros must stay, for the consuming app to evaluate
43
+ * - the wire format is private between one template compiler and one glimmer runtime
44
+ *
45
+ * Babel's own resolution can't tell the two apart (it finds whatever `babel.config.*` exists),
46
+ * so a publish build has to prefer the config named for publishing.
40
47
  */
41
48
  function detectPublishConfigFile() {
42
49
  for (const directory of PUBLISH_CONFIG_DIRECTORIES) for (const extension of PUBLISH_CONFIG_EXTENSIONS) {
@@ -45,14 +52,16 @@ function detectPublishConfigFile() {
45
52
  }
46
53
  }
47
54
  /**
48
- * The config this publish build should use: a `babel.publish.config.*` when the
49
- * library has one, else the project's root babel config resolved the way babel
50
- * itself does (`babel.config.{js,cjs,mjs,cts,json}`, honoring `rootMode`
51
- * semantics) -- which for a library whose only config *is* its publish config
52
- * is the same file either way.
53
- *
54
- * The sync API evaluates the config file; on node 24+ that works for native
55
- * ESM configs too (require(esm)).
55
+ * The config this publish build must use:
56
+ * - a `babel.publish.config.*`, when the library has one
57
+ * - else the project's root babel config, resolved the way babel itself does
58
+ * (`babel.config.{js,cjs,mjs,cts,json}`, honoring `rootMode` semantics)
59
+ *
60
+ * For a library whose only config *is* its publish config,
61
+ * that is the same file either way.
62
+ *
63
+ * The sync API evaluates the config file.
64
+ * On node 24+ that works for native ESM configs too (require(esm)).
56
65
  */
57
66
  function detectConfigFile() {
58
67
  const publishConfig = detectPublishConfigFile();
@@ -63,20 +72,21 @@ function detectConfigFile() {
63
72
  * Everything a library without its own babel config needs:
64
73
  *
65
74
  * - TypeScript stripping
75
+ *
66
76
  * - template compilation to `precompileTemplate` (`targetFormat: "hbs"`).
67
- * Published libraries must NOT ship wire format: the wire format is
68
- * private between the template compiler and the glimmer runtime of the
69
- * same version, so baking it in ties the published artifact to the
70
- * consuming app's exact ember-source. The consuming app performs final
71
- * compilation.
77
+ * Published libraries must NOT ship wire format.
78
+ * The wire format is private between the template compiler and the glimmer runtime
79
+ * of the same version, so baking it in ties the published artifact
80
+ * to the consuming app's exact ember-source.
81
+ * The consuming app performs final compilation.
72
82
  *
73
83
  * A bundle-mode build ships that exact ember-source,
74
84
  * so it compiles to the wire format with ember-source's own compiler,
75
85
  * and needs no compiler at runtime.
76
86
  *
77
- * - decorator-transforms, with its runtime left as a bare specifier so the
78
- * consuming app resolves it (the library keeps `decorator-transforms` as
79
- * a real dependency).
87
+ * - decorator-transforms, with its runtime left as a bare specifier
88
+ * so the consuming app resolves it.
89
+ * (the library keeps `decorator-transforms` as a real dependency)
80
90
  *
81
91
  * A bundle-mode build resolves it itself.
82
92
  */
@@ -95,29 +105,34 @@ function defaultPlugins(templateTransforms, bundle = false) {
95
105
  ];
96
106
  }
97
107
  /**
98
- * We still need babel (not just oxc/rolldown's native transforms) for two
99
- * reasons:
100
- *
101
- * - template compilation: `babel-plugin-ember-template-compilation` turns the
102
- * content-tag output into `precompileTemplate` calls; oxc has no equivalent.
103
- * - decorators: Ember uses the legacy/stage-1 decorator signature together
104
- * with `decorator-transforms`, which rewrites decorated class fields
105
- * (`@tracked x`) into getter/setters backed by a runtime. oxc's native
106
- * "legacy decorators" emit tsc-style `__decorate` output, which does not
107
- * match those semantics.
108
- *
109
- * But we don't want to send *every* file through babel and give back the speed
110
- * rolldown/oxc buys us -- so we run babel via `maybeBabel`, which filters down
111
- * to only the files that actually need it (template-tag, decorators, template
112
- * imports). Everything else stays on the native transform.
113
- *
114
- * The library's own babel config is used when it exists -- its
115
- * `babel.publish.config.*` (root or `config/`) in preference to its
116
- * `babel.config.*`, since this is a publish build. Without one, `defaultPlugins` covers templates, decorators,
117
- * and TypeScript, so no config file is required.
118
- *
119
- * Libraries default to `babelHelpers: "bundled"` so the emitted output is
120
- * self-contained.
108
+ * We still need babel (not just oxc / rolldown's native transforms) for two reasons:
109
+ *
110
+ * - template compilation.
111
+ * `babel-plugin-ember-template-compilation` turns the content-tag output
112
+ * into `precompileTemplate` calls.
113
+ * oxc has no equivalent.
114
+ *
115
+ * - decorators.
116
+ * Ember uses the legacy / stage-1 decorator signature together with `decorator-transforms`,
117
+ * which rewrites decorated class fields (`@tracked x`) into getter / setters backed by a runtime.
118
+ * oxc's native "legacy decorators" emit tsc-style `__decorate` output,
119
+ * which does not match those semantics.
120
+ *
121
+ * But we don't want to send *every* file through babel
122
+ * and give back the speed rolldown / oxc buys us.
123
+ *
124
+ * So we run babel via `maybeBabel`, which filters down to only the files that need it
125
+ * (template-tag, decorators, template imports).
126
+ * Everything else stays on the native transform.
127
+ *
128
+ * The library's own babel config is used when it exists.
129
+ * Its `babel.publish.config.*` (root or `config/`) wins over its `babel.config.*`,
130
+ * since this is a publish build.
131
+ *
132
+ * Without one, `defaultPlugins` covers templates, decorators, and TypeScript,
133
+ * so no config file is required.
134
+ *
135
+ * Libraries default to `babelHelpers: "bundled"`, so the emitted output is self-contained.
121
136
  */
122
137
  function emberBabel(options = {}) {
123
138
  const configFile = options.configFile === void 0 ? detectConfigFile() : options.configFile;
@@ -151,8 +166,8 @@ function readJsonSync(path) {
151
166
  return JSON.parse(readFileSync(path, { encoding: "utf8" }));
152
167
  }
153
168
  /**
154
- * Everything the library declares as a `dependency` or `peerDependency` is
155
- * resolvable by the consuming app, so we never bundle it.
169
+ * Everything the library declares as a `dependency` or `peerDependency`
170
+ * is resolvable by the consuming app, so we never bundle it.
156
171
  */
157
172
  function resolvableDependencies() {
158
173
  const deps = /* @__PURE__ */ new Set();
@@ -193,10 +208,13 @@ function emberSourceProvidedModules() {
193
208
  return provided;
194
209
  }
195
210
  /**
196
- * Keeps the library's declared dependencies and the ember virtual packages
197
- * (things like `@ember/component`, `@glimmer/tracking`, the template compiler,
198
- * …) external, so the app that consumes the library resolves them instead of
199
- * the library bundling copies of them.
211
+ * Keeps external:
212
+ * - the library's declared dependencies
213
+ * - the ember virtual packages
214
+ * (things like `@ember/component`, `@glimmer/tracking`, the template compiler, …)
215
+ *
216
+ * So the app that consumes the library resolves them,
217
+ * instead of the library bundling copies of them.
200
218
  */
201
219
  function emberExternals() {
202
220
  let deps;
@@ -284,29 +302,33 @@ function emberBundle() {
284
302
  //#endregion
285
303
  //#region src/config.ts
286
304
  /**
287
- * Sensible defaults for an Ember v2 library, applied through plugin hooks so
288
- * they travel with `ember()` — you get them whether you use this package's
289
- * `defineConfig`, tsdown's, or a plain `tsdown.config.js` / `rolldown.config.js`.
305
+ * Sensible defaults for an Ember v2 library.
306
+ *
307
+ * Applied through plugin hooks, so they travel with `ember()`.
308
+ * You get them whether you use this package's `defineConfig`, tsdown's,
309
+ * or a plain `tsdown.config.js` / `rolldown.config.js`.
290
310
  *
291
311
  * Every value is applied with `??=`, so anything you set explicitly wins.
292
312
  *
293
- * Under tsdown, the full set applies via the `tsdownConfig` hook (analogous to
294
- * Vite's `config` hook):
313
+ * Under tsdown, the full set applies via the `tsdownConfig` hook
314
+ * (analogous to Vite's `config` hook):
295
315
  *
296
- * - `sourcemap` — emit sourcemaps alongside the output.
297
- * - `clean` — wipe `dist/` between builds.
298
- * - `dts` — emit `.d.ts` declarations (via isolated declarations).
299
- * - `outExtensions` — `.js`/`.d.ts` rather than tsdown's default `.mjs`/`.d.mts`,
300
- * since exports maps conventionally point at `.js`/`.d.ts`.
301
- * - `report` — off; the size report is noise for a library build.
302
- * - `deps.neverBundle` — leave node builtins and the ember virtual packages to
303
- * the consuming app (`emberExternals()` handles the rest).
316
+ * - `sourcemap` — emit sourcemaps alongside the output
317
+ * - `clean` — wipe `dist/` between builds
318
+ * - `dts` — emit `.d.ts` declarations (via isolated declarations)
319
+ * - `outExtensions` — `.js` / `.d.ts` rather than tsdown's default `.mjs` / `.d.mts`
320
+ * (exports maps conventionally point at `.js` / `.d.ts`)
321
+ * - `report` — off.
322
+ * The size report is noise for a library build.
323
+ * - `deps.neverBundle` — leave node builtins and the ember virtual packages
324
+ * to the consuming app (`emberExternals()` handles the rest)
304
325
  *
305
- * A plain rolldown build has no notion of `clean`/`dts`/`outExtensions`/`report`
306
- * (those are tsdown-level concepts), so only the options with rolldown
307
- * equivalents are applied there, via rolldown's own `outputOptions` hook:
326
+ * A plain rolldown build has no notion of `clean` / `dts` / `outExtensions` / `report`.
327
+ * Those are tsdown-level concepts.
328
+ * So only the options with rolldown equivalents are applied there,
329
+ * via rolldown's own `outputOptions` hook:
308
330
  *
309
- * - `output.sourcemap` — on (output option).
331
+ * - `output.sourcemap` — on
310
332
  *
311
333
  * Externals are handled by `emberExternals()` (a `resolveId` hook) in both cases.
312
334
  *
@@ -356,16 +378,16 @@ function emberConfig({ bundle = false } = {}) {
356
378
  //#endregion
357
379
  //#region src/isolated-declarations.ts
358
380
  /**
359
- * Resolve the tsconfig the build will actually use, mirroring tsdown's own
360
- * `tsconfig` option (`string | boolean`):
381
+ * Resolve the tsconfig the build will use.
361
382
  *
362
- * - `undefined` / `true`: `tsconfig.json` in the cwd.
363
- * - a path to a file: that file.
364
- * - a path to a directory: `tsconfig.json` inside it.
365
- * - `false`: no tsconfig at all.
383
+ * Mirrors tsdown's own `tsconfig` option (`string | boolean`):
384
+ * - `undefined` / `true`: `tsconfig.json` in the cwd
385
+ * - a path to a file: that file
386
+ * - a path to a directory: `tsconfig.json` inside it
387
+ * - `false`: no tsconfig at all
366
388
  *
367
- * Under plain rolldown there is no such option, so the cwd's `tsconfig.json`
368
- * is all there is.
389
+ * Under plain rolldown there is no such option,
390
+ * so the cwd's `tsconfig.json` is all there is.
369
391
  */
370
392
  function resolveTsconfigPath(option) {
371
393
  if (option === false) return void 0;
@@ -377,33 +399,41 @@ function resolveTsconfigPath(option) {
377
399
  return resolve("tsconfig.json");
378
400
  }
379
401
  /**
380
- * Errors the build when the tsconfig it builds with does not set
381
- * `isolatedDeclarations: true`.
382
- *
383
- * This is required: declarations for `.gts`/`.gjs` (template tag) modules can
384
- * only be emitted by the isolated-declarations pipeline, which reads compiled
385
- * modules from the bundler's module graph. The `tsc`-based pipeline reads
386
- * source files from disk, where the compiled modules don't exist, and fails
387
- * with "Source file not found".
388
- *
389
- * Failing fast here -- rather than only when declaration emit happens to run
390
- * -- keeps the project honest: editors and `tsc`/`ember-tsc` then check the
391
- * same rules the build enforces (exported values need explicit type
392
- * annotations, e.g. `export const X: TOC<Sig> = <template>...`).
393
- *
394
- * The tsconfig checked is the one tsdown's `tsconfig` option points at, not
395
- * necessarily `tsconfig.json`. A library whose package also holds dev-only code
396
- * (a demo app, in-package tests) can therefore keep a permissive
397
- * `tsconfig.json` covering everything for editors and `tsc --noEmit`, and point
398
- * the build at a `tsconfig.publish.json` that covers only the publishable
399
- * sources -- isolated declarations then constrain exactly the code that gets
400
- * declarations emitted for it, and nothing else.
401
- *
402
- * Projects with no tsconfig (JavaScript libraries) or without the `typescript`
403
- * package have no declarations to emit, so there is nothing to check.
404
- * `tsconfig: false` is different: it is an explicit opt-out, and combined with
405
- * declaration emit it produces a confusing "Source file not found" from the
406
- * tsc-based pipeline, so it errors here instead.
402
+ * Errors the build when the tsconfig it builds with
403
+ * does not set `isolatedDeclarations: true`.
404
+ *
405
+ * This is required.
406
+ * Declarations for `.gts` / `.gjs` (template tag) modules can only be emitted
407
+ * by the isolated-declarations pipeline,
408
+ * which reads compiled modules from the bundler's module graph.
409
+ *
410
+ * The `tsc`-based pipeline reads source files from disk.
411
+ * The compiled modules don't exist there, so it fails with "Source file not found".
412
+ *
413
+ * Failing fast here, rather than only when declaration emit happens to run,
414
+ * keeps the project honest.
415
+ * Editors and `tsc` / `ember-tsc` then check the same rules the build enforces:
416
+ * exported values need explicit type annotations,
417
+ * e.g. `export const X: TOC<Sig> = <template>...`
418
+ *
419
+ * The tsconfig checked is the one tsdown's `tsconfig` option points at,
420
+ * not necessarily `tsconfig.json`.
421
+ *
422
+ * So a library whose package also holds dev-only code (a demo app, in-package tests) can:
423
+ * - keep a permissive `tsconfig.json` covering everything,
424
+ * for editors and `tsc --noEmit`
425
+ * - point the build at a `tsconfig.publish.json` that covers only the publishable sources
426
+ *
427
+ * Isolated declarations then constrain exactly the code that gets declarations emitted,
428
+ * and nothing else.
429
+ *
430
+ * Projects with no tsconfig (JavaScript libraries) or without the `typescript` package
431
+ * have no declarations to emit, so there is nothing to check.
432
+ *
433
+ * `tsconfig: false` is different.
434
+ * It is an explicit opt-out.
435
+ * Combined with declaration emit, it produces a confusing "Source file not found"
436
+ * from the tsc-based pipeline, so it errors here instead.
407
437
  */
408
438
  function emberIsolatedDeclarations() {
409
439
  let tsconfigOption;
@@ -437,9 +467,10 @@ function emberIsolatedDeclarations() {
437
467
  //#region src/transform.ts
438
468
  const processor = new Preprocessor();
439
469
  /**
440
- * `.d.ts` files emitted for `.gts` source reference the original `.gts`
441
- * specifiers. Consumers can't resolve those, so we rewrite them back to
442
- * extension-less specifiers.
470
+ * `.d.ts` files emitted for `.gts` source reference the original `.gts` specifiers.
471
+ *
472
+ * Consumers can't resolve those,
473
+ * so we rewrite them back to extension-less specifiers.
443
474
  */
444
475
  function fixDeclarationImports(content) {
445
476
  return content.replace(/from\s+'([^']+)\.gts'/g, "from '$1'").replace(/from\s+"([^"]+)\.gts"/g, "from \"$1\"").replace(/import\("([^"]+)\.gts"\)/g, "import(\"$1\")").replace(/import\('([^']+)\.gts'\)/g, "import('$1')");
@@ -459,10 +490,12 @@ async function fixDtsExtensionsInDir(dir) {
459
490
  /**
460
491
  * A sourcemap mapping every generated line to the same line of the input.
461
492
  *
462
- * `AAAA` is the [0, 0, 0, 0] VLQ segment (first line maps to source 0, line 0,
463
- * column 0); `AACA` is [0, 0, +1, 0] (each following line advances the source
464
- * line by one). Exact at line granularity, which is all the specifier rewrite
465
- * can disturb.
493
+ * - `AAAA` is the [0, 0, 0, 0] VLQ segment
494
+ * (first line maps to source 0, line 0, column 0)
495
+ * - `AACA` is [0, 0, +1, 0]
496
+ * (each following line advances the source line by one)
497
+ *
498
+ * Exact at line granularity, which is all the specifier rewrite can disturb.
466
499
  */
467
500
  function lineIdentityMap(id, source) {
468
501
  return {
@@ -474,8 +507,10 @@ function lineIdentityMap(id, source) {
474
507
  };
475
508
  }
476
509
  /**
477
- * Maps `.gts` -> `.ts` and `.gjs` -> `.js` (so rolldown can identify them as
478
- * ts/js) and preprocesses `<template>` via content-tag.
510
+ * Preprocesses `<template>` via content-tag, and maps
511
+ * `.gts` → `.ts`
512
+ * `.gjs` → `.js`
513
+ * so rolldown can identify them as ts / js.
479
514
  */
480
515
  function emberTransform() {
481
516
  return {
@@ -566,33 +601,45 @@ function emberTransform() {
566
601
  //#endregion
567
602
  //#region index.ts
568
603
  /**
569
- * A batteries-included plugin for building Ember v2 libraries (addons) with
570
- * rolldown (or tsdown, which is built on rolldown).
571
- *
572
- * It bundles everything needed to compile `.gts`/`.gjs` and template-tag
573
- * (`<template>`) source into publishable output:
574
- *
575
- * - `emberConfig()` — applies sensible tsdown defaults for a library build
576
- * (sourcemaps, `clean`, `dts`, `.js`/`.d.ts` extensions, quiet logging);
577
- * anything you set explicitly still wins.
578
- * - `emberIsolatedDeclarations()` — errors when a tsconfig.json is present
579
- * without `isolatedDeclarations: true` (required: it is the only
580
- * declaration pipeline that can see compiled template-tag modules).
581
- * - `emberExternals()` — keeps your dependencies, peerDependencies, and the
582
- * ember virtual packages external, so consuming apps resolve them.
583
- * - `emberBundle()` — bundle mode only, in place of `emberExternals()`:
584
- * aliases the ember virtual packages into ember-source,
604
+ * A batteries-included plugin for building Ember v2 libraries (addons)
605
+ * with rolldown, or with tsdown (which is built on rolldown).
606
+ *
607
+ * It bundles everything needed to compile `.gts` / `.gjs` and
608
+ * template-tag (`<template>`) source into publishable output:
609
+ *
610
+ * - `emberConfig()`
611
+ * applies sensible tsdown defaults for a library build
612
+ * (sourcemaps, `clean`, `dts`, `.js` / `.d.ts` extensions, quiet logging).
613
+ * Anything you set explicitly still wins.
614
+ *
615
+ * - `emberIsolatedDeclarations()`
616
+ * errors when a tsconfig.json is present without `isolatedDeclarations: true`.
617
+ * That is the only declaration pipeline that can see compiled template-tag modules.
618
+ *
619
+ * - `emberExternals()`
620
+ * keeps your dependencies, peerDependencies, and the ember virtual packages external,
621
+ * so consuming apps resolve them.
622
+ *
623
+ * - `emberBundle()`
624
+ * bundle mode only, in place of `emberExternals()`.
625
+ * Aliases the ember virtual packages into ember-source,
585
626
  * whose export conditions pick the build to bundle.
586
- * - `emberTransform()` — preprocesses `<template>` via content-tag and maps
587
- * `.gts`/`.gjs` to `.ts`/`.js` so rolldown can understand them.
588
- * - `emberBabel()` — runs babel (template compilation, decorators, type
589
- * stripping) with `babelHelpers: "bundled"`, but only on the files that
590
- * actually need it (via `maybeBabel`); everything else stays on the fast
591
- * native transform. The library's own `babel.config.js` is used when it
592
- * exists; no config file is required.
593
- *
594
- * Usage in `tsdown.config.js` (import `defineConfig` from `tsdown` — or from
595
- * `rolldown` for a `rolldown.config.js` — so it carries the correct types):
627
+ *
628
+ * - `emberTransform()`
629
+ * preprocesses `<template>` via content-tag,
630
+ * and maps `.gts` / `.gjs` to `.ts` / `.js` so rolldown can understand them.
631
+ *
632
+ * - `emberBabel()`
633
+ * runs babel (template compilation, decorators, type stripping)
634
+ * with `babelHelpers: "bundled"`.
635
+ * Only the files that need it go through babel (via `maybeBabel`).
636
+ * Everything else stays on the fast native transform.
637
+ * The library's own `babel.config.js` is used when it exists.
638
+ * No config file is required.
639
+ *
640
+ * Usage in `tsdown.config.js`.
641
+ * Import `defineConfig` from `tsdown` (or from `rolldown` for a `rolldown.config.js`)
642
+ * so it carries the correct types:
596
643
  *
597
644
  * ```js
598
645
  * import { defineConfig } from "tsdown";