@nullvoxpopuli/ember-rolldown 1.1.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/README.md CHANGED
@@ -20,10 +20,15 @@ modern TypeScript when type-checking: 6+ with `lib` covering `es2025` (e.g.
20
20
 
21
21
  ## Usage
22
22
 
23
+ Import `defineConfig` from the bundler you're using — `tsdown` or `rolldown` —
24
+ so it carries that tool's own config types; `@nullvoxpopuli/ember-rolldown`
25
+ provides `ember()` (the defaults travel with the plugin, not `defineConfig`).
26
+
23
27
  In your `tsdown.config.js` (recommended — emits declarations):
24
28
 
25
29
  ```js
26
- import { defineConfig, ember } from "@nullvoxpopuli/ember-rolldown";
30
+ import { defineConfig } from "tsdown";
31
+ import { ember } from "@nullvoxpopuli/ember-rolldown";
27
32
 
28
33
  export default defineConfig({
29
34
  entry: ["./src/index.ts"],
package/dist/index.js CHANGED
@@ -87,6 +87,60 @@ function emberBabel(options = {}) {
87
87
  });
88
88
  }
89
89
  //#endregion
90
+ //#region src/config.ts
91
+ /**
92
+ * Sensible defaults for an Ember v2 library, applied through plugin hooks so
93
+ * they travel with `ember()` — you get them whether you use this package's
94
+ * `defineConfig`, tsdown's, or a plain `tsdown.config.js` / `rolldown.config.js`.
95
+ *
96
+ * Every value is applied with `??=`, so anything you set explicitly wins.
97
+ *
98
+ * Under tsdown, the full set applies via the `tsdownConfig` hook (analogous to
99
+ * Vite's `config` hook):
100
+ *
101
+ * - `sourcemap` — emit sourcemaps alongside the output.
102
+ * - `clean` — wipe `dist/` between builds.
103
+ * - `dts` — emit `.d.ts` declarations (via isolated declarations).
104
+ * - `outExtensions` — `.js`/`.d.ts` rather than tsdown's default `.mjs`/`.d.mts`,
105
+ * since exports maps conventionally point at `.js`/`.d.ts`.
106
+ * - `report` — off; the size report is noise for a library build.
107
+ * - `deps.neverBundle` — leave node builtins and the ember virtual packages to
108
+ * the consuming app (`emberExternals()` handles the rest).
109
+ *
110
+ * A plain rolldown build has no notion of `clean`/`dts`/`outExtensions`/`report`
111
+ * (those are tsdown-level concepts), so only the options with rolldown
112
+ * equivalents are applied there, via rolldown's own `outputOptions` hook:
113
+ *
114
+ * - `output.sourcemap` — on (output option).
115
+ *
116
+ * Externals are handled by `emberExternals()` (a `resolveId` hook) in both cases.
117
+ */
118
+ function emberConfig() {
119
+ return {
120
+ name: "ember:config",
121
+ tsdownConfig(config) {
122
+ config.sourcemap ??= true;
123
+ config.clean ??= true;
124
+ config.dts ??= true;
125
+ config.outExtensions ??= () => ({
126
+ js: ".js",
127
+ dts: ".d.ts"
128
+ });
129
+ config.report ??= false;
130
+ config.deps ??= {};
131
+ config.deps.neverBundle ??= [
132
+ "node:*",
133
+ "@ember/*",
134
+ "@glimmer/*"
135
+ ];
136
+ },
137
+ outputOptions(options) {
138
+ options.sourcemap ??= true;
139
+ return options;
140
+ }
141
+ };
142
+ }
143
+ //#endregion
90
144
  //#region src/externals.ts
91
145
  const { emberVirtualPackages, emberVirtualPeerDeps, packageName, templateCompilationModules } = pkg;
92
146
  const compilationModules = new Set(templateCompilationModules.map((m) => m.module));
@@ -287,42 +341,6 @@ function emberTransform() {
287
341
  };
288
342
  }
289
343
  //#endregion
290
- //#region src/define-config.ts
291
- /**
292
- * tsdown's config, set up for an Ember v2 library: builds your entry to
293
- * `dist/*.js` and `dist/*.d.ts` with sourcemaps, cleaning `dist/` between
294
- * builds and leaving the ember virtual packages to the consuming app.
295
- *
296
- * You choose the `entry` and the `plugins` (e.g. `ember()`); any tsdown
297
- * option you pass wins.
298
- *
299
- * ```js
300
- * import { defineConfig, ember } from "@nullvoxpopuli/ember-rolldown";
301
- *
302
- * export default defineConfig({
303
- * entry: ["./src/index.ts"],
304
- * plugins: [ember()],
305
- * });
306
- * ```
307
- */
308
- function defineConfig(config) {
309
- return {
310
- sourcemap: true,
311
- clean: true,
312
- dts: true,
313
- outExtensions: () => ({
314
- js: ".js",
315
- dts: ".d.ts"
316
- }),
317
- neverBundle: [
318
- "node:*",
319
- "@ember/*",
320
- "@glimmer/*"
321
- ],
322
- ...config
323
- };
324
- }
325
- //#endregion
326
344
  //#region index.ts
327
345
  /**
328
346
  * A batteries-included plugin for building Ember v2 libraries (addons) with
@@ -331,6 +349,9 @@ function defineConfig(config) {
331
349
  * It bundles everything needed to compile `.gts`/`.gjs` and template-tag
332
350
  * (`<template>`) source into publishable output:
333
351
  *
352
+ * - `emberConfig()` — applies sensible tsdown defaults for a library build
353
+ * (sourcemaps, `clean`, `dts`, `.js`/`.d.ts` extensions, quiet logging);
354
+ * anything you set explicitly still wins.
334
355
  * - `emberIsolatedDeclarations()` — errors when a tsconfig.json is present
335
356
  * without `isolatedDeclarations: true` (required: it is the only
336
357
  * declaration pipeline that can see compiled template-tag modules).
@@ -344,20 +365,22 @@ function defineConfig(config) {
344
365
  * native transform. The library's own `babel.config.js` is used when it
345
366
  * exists; no config file is required.
346
367
  *
347
- * Usage in `tsdown.config.js` / `rolldown.config.js`:
368
+ * Usage in `tsdown.config.js` (import `defineConfig` from `tsdown` — or from
369
+ * `rolldown` for a `rolldown.config.js` — so it carries the correct types):
348
370
  *
349
371
  * ```js
372
+ * import { defineConfig } from "tsdown";
350
373
  * import { ember } from "@nullvoxpopuli/ember-rolldown";
351
374
  *
352
375
  * export default defineConfig({
353
376
  * entry: ["./src/index.ts"],
354
- * dts: true,
355
377
  * plugins: [ember()],
356
378
  * });
357
379
  * ```
358
380
  */
359
381
  function ember(config = {}) {
360
382
  return [
383
+ emberConfig(),
361
384
  emberIsolatedDeclarations(),
362
385
  emberExternals(),
363
386
  emberTransform(),
@@ -365,4 +388,4 @@ function ember(config = {}) {
365
388
  ];
366
389
  }
367
390
  //#endregion
368
- export { defineConfig, ember };
391
+ export { ember };
package/index.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import type { Plugin } from "rolldown";
2
2
 
3
3
  import { emberBabel, type BabelOptions } from "./src/babel.ts";
4
+ import { emberConfig } from "./src/config.ts";
4
5
  import { emberExternals } from "./src/externals.ts";
5
6
  import { emberIsolatedDeclarations } from "./src/isolated-declarations.ts";
6
7
  import { emberTransform } from "./src/transform.ts";
7
8
 
8
- export { defineConfig } from "./src/define-config.ts";
9
-
10
9
  interface Config {
11
10
  /**
12
11
  * Options for the babel step; see `BabelOptions`.
@@ -21,6 +20,9 @@ interface Config {
21
20
  * It bundles everything needed to compile `.gts`/`.gjs` and template-tag
22
21
  * (`<template>`) source into publishable output:
23
22
  *
23
+ * - `emberConfig()` — applies sensible tsdown defaults for a library build
24
+ * (sourcemaps, `clean`, `dts`, `.js`/`.d.ts` extensions, quiet logging);
25
+ * anything you set explicitly still wins.
24
26
  * - `emberIsolatedDeclarations()` — errors when a tsconfig.json is present
25
27
  * without `isolatedDeclarations: true` (required: it is the only
26
28
  * declaration pipeline that can see compiled template-tag modules).
@@ -34,20 +36,22 @@ interface Config {
34
36
  * native transform. The library's own `babel.config.js` is used when it
35
37
  * exists; no config file is required.
36
38
  *
37
- * Usage in `tsdown.config.js` / `rolldown.config.js`:
39
+ * Usage in `tsdown.config.js` (import `defineConfig` from `tsdown` — or from
40
+ * `rolldown` for a `rolldown.config.js` — so it carries the correct types):
38
41
  *
39
42
  * ```js
43
+ * import { defineConfig } from "tsdown";
40
44
  * import { ember } from "@nullvoxpopuli/ember-rolldown";
41
45
  *
42
46
  * export default defineConfig({
43
47
  * entry: ["./src/index.ts"],
44
- * dts: true,
45
48
  * plugins: [ember()],
46
49
  * });
47
50
  * ```
48
51
  */
49
52
  export function ember(config: Config = {}): Plugin[] {
50
53
  return [
54
+ emberConfig(),
51
55
  emberIsolatedDeclarations(),
52
56
  emberExternals(),
53
57
  emberTransform(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullvoxpopuli/ember-rolldown",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Meta plugin for building ember v2 libraries/addons with rolldown & tsdown.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/config.ts ADDED
@@ -0,0 +1,50 @@
1
+ import type { TsdownPlugin, UserConfig } from "tsdown";
2
+
3
+ /**
4
+ * Sensible defaults for an Ember v2 library, applied through plugin hooks so
5
+ * they travel with `ember()` — you get them whether you use this package's
6
+ * `defineConfig`, tsdown's, or a plain `tsdown.config.js` / `rolldown.config.js`.
7
+ *
8
+ * Every value is applied with `??=`, so anything you set explicitly wins.
9
+ *
10
+ * Under tsdown, the full set applies via the `tsdownConfig` hook (analogous to
11
+ * Vite's `config` hook):
12
+ *
13
+ * - `sourcemap` — emit sourcemaps alongside the output.
14
+ * - `clean` — wipe `dist/` between builds.
15
+ * - `dts` — emit `.d.ts` declarations (via isolated declarations).
16
+ * - `outExtensions` — `.js`/`.d.ts` rather than tsdown's default `.mjs`/`.d.mts`,
17
+ * since exports maps conventionally point at `.js`/`.d.ts`.
18
+ * - `report` — off; the size report is noise for a library build.
19
+ * - `deps.neverBundle` — leave node builtins and the ember virtual packages to
20
+ * the consuming app (`emberExternals()` handles the rest).
21
+ *
22
+ * A plain rolldown build has no notion of `clean`/`dts`/`outExtensions`/`report`
23
+ * (those are tsdown-level concepts), so only the options with rolldown
24
+ * equivalents are applied there, via rolldown's own `outputOptions` hook:
25
+ *
26
+ * - `output.sourcemap` — on (output option).
27
+ *
28
+ * Externals are handled by `emberExternals()` (a `resolveId` hook) in both cases.
29
+ */
30
+ export function emberConfig(): TsdownPlugin {
31
+ return {
32
+ name: "ember:config",
33
+
34
+ tsdownConfig(config: UserConfig) {
35
+ config.sourcemap ??= true;
36
+ config.clean ??= true;
37
+ config.dts ??= true;
38
+ config.outExtensions ??= () => ({ js: ".js", dts: ".d.ts" });
39
+ config.report ??= false;
40
+
41
+ config.deps ??= {};
42
+ config.deps.neverBundle ??= ["node:*", "@ember/*", "@glimmer/*"];
43
+ },
44
+
45
+ outputOptions(options) {
46
+ options.sourcemap ??= true;
47
+ return options;
48
+ },
49
+ };
50
+ }
@@ -1,32 +0,0 @@
1
- import type { UserConfig } from "tsdown";
2
-
3
- /**
4
- * tsdown's config, set up for an Ember v2 library: builds your entry to
5
- * `dist/*.js` and `dist/*.d.ts` with sourcemaps, cleaning `dist/` between
6
- * builds and leaving the ember virtual packages to the consuming app.
7
- *
8
- * You choose the `entry` and the `plugins` (e.g. `ember()`); any tsdown
9
- * option you pass wins.
10
- *
11
- * ```js
12
- * import { defineConfig, ember } from "@nullvoxpopuli/ember-rolldown";
13
- *
14
- * export default defineConfig({
15
- * entry: ["./src/index.ts"],
16
- * plugins: [ember()],
17
- * });
18
- * ```
19
- */
20
- export function defineConfig(config: UserConfig): UserConfig {
21
- return {
22
- sourcemap: true,
23
- clean: true,
24
- dts: true,
25
- // tsdown's extensions are .mjs/.d.mts otherwise, even in type-module
26
- // packages; exports maps conventionally point at .js/.d.ts
27
- outExtensions: () => ({ js: ".js", dts: ".d.ts" }),
28
- // provided by the consuming app
29
- neverBundle: ["node:*", "@ember/*", "@glimmer/*"],
30
- ...config,
31
- };
32
- }