@kanso-labs/unplugin-style-dictionary 0.8.0 → 0.10.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/types.d.ts CHANGED
@@ -122,9 +122,21 @@ export interface UnpluginStyleDictionaryOptions {
122
122
  *
123
123
  * If not provided, the root directory is searched for 'sd.config.json',
124
124
  * 'config.json', 'sd.config.js' and 'sd.config.mjs', in that order. The
125
- * first one that exists wins, and the rest are not looked at.
125
+ * first one that *looks like a Style Dictionary configuration* wins — it has
126
+ * to declare at least one of `platforms`, `source`, `include` or `tokens` —
127
+ * and the path it picked is announced, so which file a build used is
128
+ * answerable from the console. A candidate that fails that check is reported
129
+ * and skipped rather than adopted, because `config.json` is an extremely
130
+ * common name for something else entirely.
131
+ *
132
+ * **`false` turns discovery off.** Two of the four names are modules rather
133
+ * than data, and reading a module means running it: a `sd.config.js` in the
134
+ * root is imported, freshly, on every watch event. Validation cannot prevent
135
+ * that, because the check can only look at what the import returned — so a
136
+ * project that names its configuration explicitly, or has none, should say
137
+ * `config: false` rather than rely on there being nothing to find.
126
138
  */
127
- config?: ((context: StyleDictionaryConfigContext) => Config | Config[] | Promise<Config | Config[]>) | Config | Config[] | string | string[];
139
+ config?: ((context: StyleDictionaryConfigContext) => Config | Config[] | Promise<Config | Config[]>) | Config | Config[] | false | string | string[];
128
140
  /**
129
141
  * Whether a failed rebuild is pushed to Vite's error overlay.
130
142
  *
@@ -237,6 +249,50 @@ export interface UnpluginStyleDictionaryOptions {
237
249
  * @default undefined
238
250
  */
239
251
  onBuildStart?: () => Promise<void> | void;
252
+ /**
253
+ * Which platforms to build, by the names the configuration defines.
254
+ *
255
+ * Every rebuild used to compile every platform. Measured on a six-platform
256
+ * configuration (css, scss, js, ios, android, flutter), with the timer around
257
+ * the build call alone:
258
+ *
259
+ * ```
260
+ * tokens all platforms css only saved
261
+ * 500 12 ms 1 ms 10 ms
262
+ * 3000 36 ms 2 ms 34 ms
263
+ * 10000 103 ms 4 ms 99 ms
264
+ * 30000 330 ms 12 ms 319 ms
265
+ * ```
266
+ *
267
+ * So a dev server serving a web app paid for Objective-C headers, Android
268
+ * XML and Dart classes on every token save, and the cost grows with the
269
+ * token count.
270
+ *
271
+ * Two shapes. An array selects the same platforms for every build. An object
272
+ * splits the first compile from the watch rebuilds, which is the common
273
+ * want — build everything once, then rebuild only what the page uses:
274
+ *
275
+ * ```typescript
276
+ * platforms: ['css']
277
+ * platforms: { watch: ['css'] }
278
+ * ```
279
+ *
280
+ * An omitted key means every platform, so `{ watch: ['css'] }` builds all of
281
+ * them once and then only css. A name the configuration does not define is an
282
+ * error, matching Style Dictionary's own CLI — "Must be defined in the
283
+ * config".
284
+ *
285
+ * **Unselected platforms keep whatever they last wrote.** Their files are not
286
+ * removed and not refreshed, so a one-shot build that scopes platforms ships
287
+ * stale output for the rest. Scope the watch half rather than the build half
288
+ * unless that is what you want.
289
+ *
290
+ * @default undefined, which builds every platform
291
+ */
292
+ platforms?: string[] | {
293
+ build?: string[];
294
+ watch?: string[];
295
+ };
240
296
  /**
241
297
  * Whether the table of generated files and their sizes is produced.
242
298
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanso-labs/unplugin-style-dictionary",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Compile Style Dictionary design tokens ahead of your bundler (Vite, Rolldown, Rollup, or Webpack) from a single unplugin-based plugin, with automatic watching and rebuilding under Vite",
5
5
  "keywords": [
6
6
  "unplugin",
@@ -36,6 +36,10 @@
36
36
  "types": "./dist/rollup.d.ts",
37
37
  "default": "./dist/rollup.js"
38
38
  },
39
+ "./rspack": {
40
+ "types": "./dist/rspack.d.ts",
41
+ "default": "./dist/rspack.js"
42
+ },
39
43
  "./webpack": {
40
44
  "types": "./dist/webpack.d.ts",
41
45
  "default": "./dist/webpack.js"
@@ -60,11 +64,13 @@
60
64
  "format": "oxfmt",
61
65
  "format:check": "oxfmt --check",
62
66
  "lint": "oxlint --type-aware . && eslint . && npm run format:check",
63
- "package:check": "publint && node scripts/check-package.mjs",
64
- "prepare": "husky",
67
+ "package:check": "publint && attw --pack . --profile esm-only && node scripts/check-package.mjs",
68
+ "peers:check": "node scripts/check-peers.mjs",
69
+ "prepare": "husky || true",
65
70
  "test": "vitest run",
66
71
  "test:coverage": "vitest run --coverage"
67
72
  },
73
+ "author": "Kanso Labs <kanso.labs.org@gmail.com>",
68
74
  "dependencies": {
69
75
  "json5": "2.2.3",
70
76
  "picomatch": "4.0.7",
@@ -72,10 +78,12 @@
72
78
  "unplugin": "3.4.0"
73
79
  },
74
80
  "devDependencies": {
81
+ "@arethetypeswrong/cli": "0.18.5",
75
82
  "@codecov/rollup-plugin": "2.0.1",
76
83
  "@commitlint/cli": "21.2.2",
77
84
  "@commitlint/config-conventional": "21.2.2",
78
85
  "@eslint/js": "10.0.1",
86
+ "@rspack/core": "2.2.6",
79
87
  "@types/node": "26.6.1",
80
88
  "@types/picomatch": "4.0.3",
81
89
  "@types/semver": "7.8.0",
@@ -103,6 +111,7 @@
103
111
  "webpack": "5.111.0"
104
112
  },
105
113
  "peerDependencies": {
114
+ "@rspack/core": "*",
106
115
  "rolldown": "*",
107
116
  "rollup": "*",
108
117
  "style-dictionary": "^5.0.0",
@@ -110,6 +119,9 @@
110
119
  "webpack": "*"
111
120
  },
112
121
  "peerDependenciesMeta": {
122
+ "@rspack/core": {
123
+ "optional": true
124
+ },
113
125
  "rolldown": {
114
126
  "optional": true
115
127
  },