@fastkit/plugboy 1.2.2 → 1.4.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 +108 -0
- package/dist/cli.mjs +2 -2
- package/dist/plugboy.d.mts +87 -3
- package/dist/plugboy.mjs +1 -1
- package/dist/{workspace-B66AR1T-.mjs → workspace-B6BoRqWL.mjs} +297 -60
- package/dist/workspace-B6BoRqWL.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/workspace-B66AR1T-.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -145,6 +145,114 @@ export default defineWorkspaceConfig({
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
#### Build Target
|
|
149
|
+
|
|
150
|
+
`target` is passed straight through to tsdown and decides which JavaScript
|
|
151
|
+
syntax is downleveled. Pass a single target, an array of targets, or `false` to
|
|
152
|
+
disable every transformation.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
export default defineWorkspaceConfig({
|
|
156
|
+
// A library expected to run on both Node.js and browsers declares the lower
|
|
157
|
+
// bound of each: the output satisfies every listed environment.
|
|
158
|
+
target: ['node20.19', 'chrome111', 'firefox114', 'safari16.4']
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Set it in `plugboy.project.ts` to apply one target to every workspace; a
|
|
163
|
+
workspace that declares its own `target` replaces the project value outright
|
|
164
|
+
(target lists are not merged). When neither layer sets it, tsdown falls back to
|
|
165
|
+
the package's `engines.node` field, and applies no transformation at all when
|
|
166
|
+
that field is absent.
|
|
167
|
+
|
|
168
|
+
Only *syntax* is lowered — runtime APIs (`structuredClone`, `Array#at`, …) are
|
|
169
|
+
never polyfilled. The value also becomes the default for `css.target` below,
|
|
170
|
+
where every non-browser entry of the list is ignored.
|
|
171
|
+
|
|
172
|
+
#### CSS Options
|
|
173
|
+
|
|
174
|
+
`css` is passed straight through to tsdown and controls how stylesheets are
|
|
175
|
+
processed and emitted — the output file name, preprocessor options, CSS modules,
|
|
176
|
+
syntax lowering, and so on.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
export default defineWorkspaceConfig({
|
|
180
|
+
css: {
|
|
181
|
+
// Name of the single emitted stylesheet.
|
|
182
|
+
fileName: 'my-package.css',
|
|
183
|
+
// Lower CSS syntax for browsers only, independently of `target`.
|
|
184
|
+
target: ['chrome111', 'firefox114', 'safari16.4']
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Set it in `plugboy.project.ts` to apply defaults to every workspace; a workspace
|
|
190
|
+
value is shallow-merged over the project one, so it only needs to restate the
|
|
191
|
+
keys it changes.
|
|
192
|
+
|
|
193
|
+
Plugins may seed defaults here during workspace setup — the vanilla-extract
|
|
194
|
+
plugin, for instance, owns `splitting` and `fileName` so the emitted file matches
|
|
195
|
+
the CSS export plugboy declares. A configured value always wins over a plugin
|
|
196
|
+
default, so check the plugin's documentation before overriding a key it manages.
|
|
197
|
+
|
|
198
|
+
#### CSS Optimization
|
|
199
|
+
|
|
200
|
+
`optimizeCSS` applies plugboy's own postcss pass on top of whatever tsdown
|
|
201
|
+
produced: duplicate `@layer` / `@media` blocks are merged, and the selectors
|
|
202
|
+
listed in `combineRules` are combined into a single rule. Pass `false` to disable
|
|
203
|
+
it.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
export default defineWorkspaceConfig({
|
|
207
|
+
optimizeCSS: {
|
|
208
|
+
combineRules: {
|
|
209
|
+
rules: [':root']
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
It runs in `writeBundle`, on the stylesheets on disk, so it covers **every**
|
|
216
|
+
stylesheet the build writes — including the ones tsdown's own CSS pipeline emits,
|
|
217
|
+
which it does after every plugin has had its say.
|
|
218
|
+
|
|
219
|
+
#### Preserved at the top of a stylesheet
|
|
220
|
+
|
|
221
|
+
Two things tsdown's CSS pipeline would rewrite are restored afterwards, in this
|
|
222
|
+
order, above every rule:
|
|
223
|
+
|
|
224
|
+
1. **The authored `@layer` order.** lightningcss prunes a name from an
|
|
225
|
+
`@layer a, b, c;` statement once a block for it appears in the same
|
|
226
|
+
stylesheet. For a library that is wrong whenever the statement also orders
|
|
227
|
+
layers owned by *other* packages — the pruned layer's position then depends on
|
|
228
|
+
where its block happens to land relative to those. plugboy reads the statements
|
|
229
|
+
before the transform and re-emits them verbatim.
|
|
230
|
+
2. **External `@import`s.** A bare package specifier (e.g.
|
|
231
|
+
`@import url('material-symbols/rounded.css') layer(...)`) stays external
|
|
232
|
+
instead of being inlined, so the consumer's bundler resolves it and the
|
|
233
|
+
imported package's own relative asset URLs keep working.
|
|
234
|
+
|
|
235
|
+
Both are captured from every stylesheet in the module graph, whether its contents
|
|
236
|
+
were authored or generated by a plugin — vanilla-extract emits its `@layer`
|
|
237
|
+
statements into a virtual module, and those are covered too.
|
|
238
|
+
|
|
239
|
+
#### One stylesheet per CSS entry
|
|
240
|
+
|
|
241
|
+
Every entry with `css: true` gets a `./<entry>.css` export, and each of those files
|
|
242
|
+
is guaranteed to exist and to be usable on its own.
|
|
243
|
+
|
|
244
|
+
With several such entries the build emits one stylesheet per output *chunk*
|
|
245
|
+
(`css.splitting`), which does not line up: CSS reached from more than one entry is
|
|
246
|
+
moved into a shared chunk and emitted under a hashed name that no export points at,
|
|
247
|
+
and an entry whose CSS comes only from there gets no stylesheet at all. plugboy
|
|
248
|
+
rebuilds each entry's stylesheet from its own CSS plus the CSS of every chunk it
|
|
249
|
+
imports, dependencies first, and drops the leftover per-chunk files. Shared CSS is
|
|
250
|
+
duplicated into each entry that needs it, which is what makes a single
|
|
251
|
+
`./<entry>.css` import complete.
|
|
252
|
+
|
|
253
|
+
This is skipped when `css.inject` is on, since the JavaScript then imports the
|
|
254
|
+
per-chunk stylesheets by name.
|
|
255
|
+
|
|
148
256
|
### defineProjectConfig
|
|
149
257
|
|
|
150
258
|
#### Workspace Management
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as getWorkspace, t as generateWorkspace } from "./workspace-
|
|
1
|
+
import { i as getWorkspace, t as generateWorkspace } from "./workspace-B6BoRqWL.mjs";
|
|
2
2
|
import { cac } from "cac";
|
|
3
3
|
//#region package.json
|
|
4
|
-
var version = "1.
|
|
4
|
+
var version = "1.4.0";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/cli.ts
|
|
7
7
|
async function main() {
|
package/dist/plugboy.d.mts
CHANGED
|
@@ -559,7 +559,7 @@ type WorkspaceEntries = Record<string, WorkspaceEntry>;
|
|
|
559
559
|
* @remarks The configuration must be `{ [id]: [Entry setting: }`. `"." ` is treated as a special ID and is the target of the main export.
|
|
560
560
|
*/
|
|
561
561
|
type RawWorkspaceEntries = Record<string, RawWorkspaceEntry>;
|
|
562
|
-
declare const TSDOWN_SYNC_OPTIONS: ["define", "skipNodeModulesBundle", "onSuccess", "copy", "deps"];
|
|
562
|
+
declare const TSDOWN_SYNC_OPTIONS: ["define", "skipNodeModulesBundle", "onSuccess", "copy", "deps", "target"];
|
|
563
563
|
type TSDownSyncOption = (typeof TSDOWN_SYNC_OPTIONS)[number];
|
|
564
564
|
interface TSDownSyncOptions extends Pick<UserConfig, TSDownSyncOption> {}
|
|
565
565
|
/**
|
|
@@ -617,6 +617,40 @@ interface UserWorkspaceConfig extends TSDownSyncOptions {
|
|
|
617
617
|
* `stub`.
|
|
618
618
|
*/
|
|
619
619
|
copy?: UserConfig['copy'];
|
|
620
|
+
/**
|
|
621
|
+
* tsdown's `target` option — the environment(s) the output syntax is
|
|
622
|
+
* downleveled for.
|
|
623
|
+
*
|
|
624
|
+
* @remarks
|
|
625
|
+
* Inherited from the project configuration when omitted. A value set here
|
|
626
|
+
* replaces the project default outright (a target list describes one
|
|
627
|
+
* environment set, so merging the two would be meaningless).
|
|
628
|
+
*
|
|
629
|
+
* Note that this only lowers *syntax*; runtime APIs are never polyfilled.
|
|
630
|
+
* Unset at both layers, tsdown falls back to `engines.node` of the package,
|
|
631
|
+
* and applies no transformation at all when that field is absent.
|
|
632
|
+
*
|
|
633
|
+
* @example `['node20.19', 'chrome111']`
|
|
634
|
+
*/
|
|
635
|
+
target?: UserConfig['target'];
|
|
636
|
+
/**
|
|
637
|
+
* tsdown's `css` option — how stylesheets are processed and emitted.
|
|
638
|
+
*
|
|
639
|
+
* @remarks
|
|
640
|
+
* Shallow-merged over the project configuration, so a workspace only needs to
|
|
641
|
+
* restate the keys it changes.
|
|
642
|
+
*
|
|
643
|
+
* Plugins may seed defaults here during workspace setup (e.g. the
|
|
644
|
+
* vanilla-extract plugin sets `splitting` / `fileName`, which it needs to own
|
|
645
|
+
* to keep its CSS pipeline intact). A value declared in the configuration
|
|
646
|
+
* always wins over such a default — consult the plugin's documentation before
|
|
647
|
+
* overriding a key it manages.
|
|
648
|
+
*
|
|
649
|
+
* `css.target` defaults to {@link UserWorkspaceConfig.target}.
|
|
650
|
+
*
|
|
651
|
+
* @see {@link CssOptions}
|
|
652
|
+
*/
|
|
653
|
+
css?: CssOptions;
|
|
620
654
|
/**
|
|
621
655
|
* CSS optimization options
|
|
622
656
|
*
|
|
@@ -631,7 +665,7 @@ interface UserWorkspaceConfig extends TSDownSyncOptions {
|
|
|
631
665
|
/**
|
|
632
666
|
* Workspace Configuration
|
|
633
667
|
*/
|
|
634
|
-
interface ResolvedWorkspaceConfig extends Required<Omit<UserWorkspaceConfig, 'entries' | 'hooks' | 'plugins' | 'dts' | 'publicDir' | 'optimizeCSS' | TSDownSyncOption>>, TSDownSyncOptions {
|
|
668
|
+
interface ResolvedWorkspaceConfig extends Required<Omit<UserWorkspaceConfig, 'entries' | 'hooks' | 'plugins' | 'dts' | 'publicDir' | 'optimizeCSS' | 'css' | TSDownSyncOption>>, TSDownSyncOptions {
|
|
635
669
|
/**
|
|
636
670
|
* Configuration of all entries in the workspace
|
|
637
671
|
*
|
|
@@ -659,6 +693,12 @@ interface ResolvedWorkspaceConfig extends Required<Omit<UserWorkspaceConfig, 'en
|
|
|
659
693
|
* (`true` → `'public'`).
|
|
660
694
|
*/
|
|
661
695
|
publicDir: string | false;
|
|
696
|
+
/**
|
|
697
|
+
* tsdown's `css` option — how stylesheets are processed and emitted.
|
|
698
|
+
*
|
|
699
|
+
* @see {@link CssOptions}
|
|
700
|
+
*/
|
|
701
|
+
css?: CssOptions;
|
|
662
702
|
/**
|
|
663
703
|
* CSS optimization options
|
|
664
704
|
*
|
|
@@ -738,6 +778,17 @@ interface WorkspaceSetupContext {
|
|
|
738
778
|
* @see {@link NormalizedDTSSettings}
|
|
739
779
|
*/
|
|
740
780
|
dts: NormalizedDTSSettings;
|
|
781
|
+
/**
|
|
782
|
+
* tsdown's `css` option, seeded from the project and workspace
|
|
783
|
+
* configurations.
|
|
784
|
+
*
|
|
785
|
+
* @remarks
|
|
786
|
+
* Plugins may extend this during workspace setup, but must merge rather than
|
|
787
|
+
* assign, and must let the configured value win — a plugin default belongs
|
|
788
|
+
* *under* `...ctx.css`, never over it.
|
|
789
|
+
*
|
|
790
|
+
* @see {@link CssOptions}
|
|
791
|
+
*/
|
|
741
792
|
css?: CssOptions;
|
|
742
793
|
/**
|
|
743
794
|
* CSS optimization options
|
|
@@ -863,11 +914,34 @@ interface UserProjectConfig {
|
|
|
863
914
|
* @see {@link OptimizeCSSOptions}
|
|
864
915
|
*/
|
|
865
916
|
optimizeCSS?: OptimizeCSSOptions | boolean;
|
|
917
|
+
/**
|
|
918
|
+
* tsdown's `target` option — the environment(s) the output syntax is
|
|
919
|
+
* downleveled for.
|
|
920
|
+
*
|
|
921
|
+
* @remarks
|
|
922
|
+
* Applies to every workspace in the project. A workspace that declares its
|
|
923
|
+
* own `target` replaces this value outright (a target list describes one
|
|
924
|
+
* environment set, so merging the two would be meaningless).
|
|
925
|
+
*
|
|
926
|
+
* @example `['node20.19', 'chrome111']`
|
|
927
|
+
*/
|
|
928
|
+
target?: UserConfig['target'];
|
|
929
|
+
/**
|
|
930
|
+
* tsdown's `css` option — how stylesheets are processed and emitted.
|
|
931
|
+
*
|
|
932
|
+
* @remarks
|
|
933
|
+
* Applies to every workspace in the project. A workspace's own `css` is
|
|
934
|
+
* shallow-merged over this value, so it only needs to restate the keys it
|
|
935
|
+
* changes.
|
|
936
|
+
*
|
|
937
|
+
* @see {@link CssOptions}
|
|
938
|
+
*/
|
|
939
|
+
css?: CssOptions;
|
|
866
940
|
}
|
|
867
941
|
/**
|
|
868
942
|
* Project Configuration
|
|
869
943
|
*/
|
|
870
|
-
interface ResolvedProjectConfig extends Required<Omit<UserProjectConfig, 'scripts' | 'tsconfig' | 'hooks' | 'plugins' | 'dts' | 'optimizeCSS'>> {
|
|
944
|
+
interface ResolvedProjectConfig extends Required<Omit<UserProjectConfig, 'scripts' | 'tsconfig' | 'hooks' | 'plugins' | 'dts' | 'optimizeCSS' | 'target' | 'css'>> {
|
|
871
945
|
/**
|
|
872
946
|
* Workspace script templates list
|
|
873
947
|
* @remarks Used to create a new workspace with the `plugboy gen` CLI command.
|
|
@@ -901,6 +975,16 @@ interface ResolvedProjectConfig extends Required<Omit<UserProjectConfig, 'script
|
|
|
901
975
|
* @see {@link OptimizeCSSOptions}
|
|
902
976
|
*/
|
|
903
977
|
optimizeCSS: OptimizeCSSOptions | false;
|
|
978
|
+
/**
|
|
979
|
+
* tsdown's `target` option applied to every workspace in the project, unless
|
|
980
|
+
* the workspace declares its own.
|
|
981
|
+
*/
|
|
982
|
+
target?: UserConfig['target'];
|
|
983
|
+
/**
|
|
984
|
+
* tsdown's `css` option applied to every workspace in the project, with the
|
|
985
|
+
* workspace's own `css` shallow-merged over it.
|
|
986
|
+
*/
|
|
987
|
+
css?: CssOptions;
|
|
904
988
|
}
|
|
905
989
|
type ProjectPackageJson = RequiredPackageJSON<ProjectRequiredField>;
|
|
906
990
|
/**
|
package/dist/plugboy.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as resolveOptimizeCSSOptions, A as resolveRawExposeEntriesSettings, B as resolveBundledConfigOutputFile, C as findProjectPlugin, D as loadProjectConfig, E as isProjectPackageJson, F as getFilename, G as mergeChunkAddons, H as stripDanglingDTSSourceMaps, I as isFileNotFoundException, J as isPromise, K as mergeExternals, L as pathExists, M as findConfig, N as findFile, O as resolveUserProjectConfig, P as getDirname, Q as WORKSPACE_REQUIRED_FIELDS, R as rmrf, S as extractProjectPlugins, T as defineProjectConfig, U as exitHook, V as DANGLING_DTS_SOURCE_MAP_RE, W as collectExternalStringPrefixes, X as PROJECT_REQUIRED_FIELDS, Y as resolveListable, Z as TSDOWN_SYNC_OPTIONS, _ as loadWorkspaceConfig, a as syncWorkspacePackageFields, b as resolveUserWorkspaceConfig, c as Builder, d as getWorkspacePackageJson, et as mergeDTSSettingsList, f as Path, g as isWorkspacePackageJson, h as defineWorkspaceConfig, i as getWorkspace, it as createHooksDefaults, j as copyDirSync, k as exposeEntries, l as findWorkspacePackages, m as resolveUserHooks, n as PlugboyWorkspace, nt as normalizeDTSPreserveTypeTarget, o as PlugboyProject, p as buildHooks, q as mergeNoExternals, r as WORKSPACE_PACKAGE_SYNC_FIELDS, rt as normalizeDTSSettings, s as getProject, t as generateWorkspace, tt as normalizeDTSPreserveTypeSettings, u as getProjectPackageJson, v as resolveRawWorkspaceEntries, w as resolveUserPluginOption, x as definePlugin, y as resolveRawWorkspaceEntry, z as writeFileAtomic } from "./workspace-
|
|
1
|
+
import { $ as resolveOptimizeCSSOptions, A as resolveRawExposeEntriesSettings, B as resolveBundledConfigOutputFile, C as findProjectPlugin, D as loadProjectConfig, E as isProjectPackageJson, F as getFilename, G as mergeChunkAddons, H as stripDanglingDTSSourceMaps, I as isFileNotFoundException, J as isPromise, K as mergeExternals, L as pathExists, M as findConfig, N as findFile, O as resolveUserProjectConfig, P as getDirname, Q as WORKSPACE_REQUIRED_FIELDS, R as rmrf, S as extractProjectPlugins, T as defineProjectConfig, U as exitHook, V as DANGLING_DTS_SOURCE_MAP_RE, W as collectExternalStringPrefixes, X as PROJECT_REQUIRED_FIELDS, Y as resolveListable, Z as TSDOWN_SYNC_OPTIONS, _ as loadWorkspaceConfig, a as syncWorkspacePackageFields, b as resolveUserWorkspaceConfig, c as Builder, d as getWorkspacePackageJson, et as mergeDTSSettingsList, f as Path, g as isWorkspacePackageJson, h as defineWorkspaceConfig, i as getWorkspace, it as createHooksDefaults, j as copyDirSync, k as exposeEntries, l as findWorkspacePackages, m as resolveUserHooks, n as PlugboyWorkspace, nt as normalizeDTSPreserveTypeTarget, o as PlugboyProject, p as buildHooks, q as mergeNoExternals, r as WORKSPACE_PACKAGE_SYNC_FIELDS, rt as normalizeDTSSettings, s as getProject, t as generateWorkspace, tt as normalizeDTSPreserveTypeSettings, u as getProjectPackageJson, v as resolveRawWorkspaceEntries, w as resolveUserPluginOption, x as definePlugin, y as resolveRawWorkspaceEntry, z as writeFileAtomic } from "./workspace-B6BoRqWL.mjs";
|
|
2
2
|
export { Builder, DANGLING_DTS_SOURCE_MAP_RE, PROJECT_REQUIRED_FIELDS, Path, PlugboyProject, PlugboyWorkspace, TSDOWN_SYNC_OPTIONS, WORKSPACE_PACKAGE_SYNC_FIELDS, WORKSPACE_REQUIRED_FIELDS, buildHooks, collectExternalStringPrefixes, copyDirSync, createHooksDefaults, definePlugin, defineProjectConfig, defineWorkspaceConfig, exitHook, exposeEntries, extractProjectPlugins, findConfig, findFile, findProjectPlugin, findWorkspacePackages, generateWorkspace, getDirname, getFilename, getProject, getProjectPackageJson, getWorkspace, getWorkspacePackageJson, isFileNotFoundException, isProjectPackageJson, isPromise, isWorkspacePackageJson, loadProjectConfig, loadWorkspaceConfig, mergeChunkAddons, mergeDTSSettingsList, mergeExternals, mergeNoExternals, normalizeDTSPreserveTypeSettings, normalizeDTSPreserveTypeTarget, normalizeDTSSettings, pathExists, resolveBundledConfigOutputFile, resolveListable, resolveOptimizeCSSOptions, resolveRawExposeEntriesSettings, resolveRawWorkspaceEntries, resolveRawWorkspaceEntry, resolveUserHooks, resolveUserPluginOption, resolveUserProjectConfig, resolveUserWorkspaceConfig, rmrf, stripDanglingDTSSourceMaps, syncWorkspacePackageFields, writeFileAtomic };
|