@10up/build 1.0.0-alpha.1
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 +508 -0
- package/bin/10up-build.js +11 -0
- package/config/postcss.config.js +36 -0
- package/dist/build.d.ts +11 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +315 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +103 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +230 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/block-json.d.ts +18 -0
- package/dist/plugins/block-json.d.ts.map +1 -0
- package/dist/plugins/block-json.js +172 -0
- package/dist/plugins/block-json.js.map +1 -0
- package/dist/plugins/copy-assets.d.ts +15 -0
- package/dist/plugins/copy-assets.d.ts.map +1 -0
- package/dist/plugins/copy-assets.js +62 -0
- package/dist/plugins/copy-assets.js.map +1 -0
- package/dist/plugins/sass-plugin.d.ts +17 -0
- package/dist/plugins/sass-plugin.d.ts.map +1 -0
- package/dist/plugins/sass-plugin.js +163 -0
- package/dist/plugins/sass-plugin.js.map +1 -0
- package/dist/plugins/wp-dependency-extraction.d.ts +27 -0
- package/dist/plugins/wp-dependency-extraction.d.ts.map +1 -0
- package/dist/plugins/wp-dependency-extraction.js +306 -0
- package/dist/plugins/wp-dependency-extraction.js.map +1 -0
- package/dist/types.d.ts +540 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/entry-detection.d.ts +13 -0
- package/dist/utils/entry-detection.d.ts.map +1 -0
- package/dist/utils/entry-detection.js +218 -0
- package/dist/utils/entry-detection.js.map +1 -0
- package/dist/utils/externals.d.ts +62 -0
- package/dist/utils/externals.d.ts.map +1 -0
- package/dist/utils/externals.js +152 -0
- package/dist/utils/externals.js.map +1 -0
- package/dist/utils/paths.d.ts +40 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +70 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/watch.d.ts +13 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +214 -0
- package/dist/watch.js.map +1 -0
- package/package.json +73 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @10up/build
|
|
3
|
+
*
|
|
4
|
+
* This module contains all TypeScript interfaces and types used throughout
|
|
5
|
+
* the build tool. These types define the configuration schema, build results,
|
|
6
|
+
* and internal data structures.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
* @module types
|
|
10
|
+
*/
|
|
11
|
+
import type { Plugin } from 'esbuild';
|
|
12
|
+
/**
|
|
13
|
+
* Path configuration for source and output directories.
|
|
14
|
+
*
|
|
15
|
+
* These paths are relative to the project root (where package.json is located).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```json
|
|
19
|
+
* {
|
|
20
|
+
* "paths": {
|
|
21
|
+
* "blocksDir": "./includes/blocks/",
|
|
22
|
+
* "srcDir": "./assets/",
|
|
23
|
+
* "copyAssetsDir": "./assets/",
|
|
24
|
+
* "blocksStyles": "./assets/css/blocks/",
|
|
25
|
+
* "globalStylesDir": "./assets/css/globals/",
|
|
26
|
+
* "globalMixinsDir": "./assets/css/mixins/"
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface PathsConfig {
|
|
32
|
+
/**
|
|
33
|
+
* Directory containing block.json files for WordPress blocks.
|
|
34
|
+
* The build tool recursively searches this directory for block metadata.
|
|
35
|
+
* @default "./includes/blocks/"
|
|
36
|
+
*/
|
|
37
|
+
blocksDir: string;
|
|
38
|
+
/**
|
|
39
|
+
* Output directory for compiled assets.
|
|
40
|
+
* @default "./dist/"
|
|
41
|
+
*/
|
|
42
|
+
distDir: string;
|
|
43
|
+
/**
|
|
44
|
+
* Source directory for JavaScript, TypeScript, and CSS assets.
|
|
45
|
+
* @default "./assets/"
|
|
46
|
+
*/
|
|
47
|
+
srcDir: string;
|
|
48
|
+
/**
|
|
49
|
+
* Directory containing static assets (images, fonts, etc.) to copy to output.
|
|
50
|
+
* Files with extensions like .jpg, .png, .svg, .woff2 are automatically copied.
|
|
51
|
+
* @default "./assets/"
|
|
52
|
+
*/
|
|
53
|
+
copyAssetsDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* Directory containing block-specific stylesheets for auto-enqueue feature.
|
|
56
|
+
* Used when `loadBlockSpecificStyles` is enabled.
|
|
57
|
+
* @default "./assets/css/blocks/"
|
|
58
|
+
*/
|
|
59
|
+
blocksStyles: string;
|
|
60
|
+
/**
|
|
61
|
+
* Directory containing global CSS files with custom properties and custom media queries.
|
|
62
|
+
* These files are injected into all stylesheets via postcss-global-data.
|
|
63
|
+
* @default "./assets/css/globals/"
|
|
64
|
+
*/
|
|
65
|
+
globalStylesDir: string;
|
|
66
|
+
/**
|
|
67
|
+
* Directory containing PostCSS mixin definition files.
|
|
68
|
+
* Mixins defined here can be used in any stylesheet with `@mixin name;`.
|
|
69
|
+
* @default "./assets/css/mixins/"
|
|
70
|
+
*/
|
|
71
|
+
globalMixinsDir: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Output filename patterns for generated assets.
|
|
75
|
+
*
|
|
76
|
+
* Supports placeholders:
|
|
77
|
+
* - `[name]` - Entry point name
|
|
78
|
+
* - `[dir]` - Directory structure from entry
|
|
79
|
+
* - `[hash]` - Content hash for cache busting
|
|
80
|
+
* - `[contenthash]` - Content-based hash
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```json
|
|
84
|
+
* {
|
|
85
|
+
* "filenames": {
|
|
86
|
+
* "js": "js/[name].js",
|
|
87
|
+
* "css": "css/[name].css"
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export interface FilenamesConfig {
|
|
93
|
+
/**
|
|
94
|
+
* Pattern for JavaScript output files.
|
|
95
|
+
* @default "js/[name].js"
|
|
96
|
+
*/
|
|
97
|
+
js: string;
|
|
98
|
+
/**
|
|
99
|
+
* Pattern for JavaScript chunk files (code splitting).
|
|
100
|
+
* @default "js/[name].[contenthash].chunk.js"
|
|
101
|
+
*/
|
|
102
|
+
jsChunk: string;
|
|
103
|
+
/**
|
|
104
|
+
* Pattern for CSS output files.
|
|
105
|
+
* @default "css/[name].css"
|
|
106
|
+
*/
|
|
107
|
+
css: string;
|
|
108
|
+
/**
|
|
109
|
+
* Pattern for block JavaScript files.
|
|
110
|
+
* @default "blocks/[name].js"
|
|
111
|
+
*/
|
|
112
|
+
block: string;
|
|
113
|
+
/**
|
|
114
|
+
* Pattern for block CSS files.
|
|
115
|
+
* @default "blocks/[name].css"
|
|
116
|
+
*/
|
|
117
|
+
blockCSS: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Configuration for externalizing custom package namespaces.
|
|
121
|
+
*
|
|
122
|
+
* This allows you to externalize packages from custom npm scopes
|
|
123
|
+
* (like @woocommerce/* or @your-plugin/*) similar to how @wordpress/*
|
|
124
|
+
* packages are handled.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```json
|
|
128
|
+
* {
|
|
129
|
+
* "externalNamespaces": {
|
|
130
|
+
* "@woocommerce": {
|
|
131
|
+
* "global": "wc",
|
|
132
|
+
* "handlePrefix": "wc"
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* This would transform:
|
|
139
|
+
* - `import { Button } from '@woocommerce/components'`
|
|
140
|
+
* - To use global: `wc.components`
|
|
141
|
+
* - With script handle: `wc-components`
|
|
142
|
+
*/
|
|
143
|
+
export interface ExternalNamespaceConfig {
|
|
144
|
+
/**
|
|
145
|
+
* The global variable prefix where the package is available at runtime.
|
|
146
|
+
* For `@woocommerce/components`, if global is "wc", the runtime reference
|
|
147
|
+
* will be `wc.components`.
|
|
148
|
+
*/
|
|
149
|
+
global: string;
|
|
150
|
+
/**
|
|
151
|
+
* The prefix for WordPress script handles.
|
|
152
|
+
* For `@woocommerce/components`, if handlePrefix is "wc", the handle
|
|
153
|
+
* will be `wc-components`.
|
|
154
|
+
*/
|
|
155
|
+
handlePrefix: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Main build configuration object.
|
|
159
|
+
*
|
|
160
|
+
* This interface defines all configuration options available for the build tool.
|
|
161
|
+
* Configuration is typically read from `package.json["10up-toolkit"]`.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```json
|
|
165
|
+
* {
|
|
166
|
+
* "10up-toolkit": {
|
|
167
|
+
* "entry": {
|
|
168
|
+
* "admin": "./assets/js/admin/admin.js"
|
|
169
|
+
* },
|
|
170
|
+
* "useBlockAssets": true,
|
|
171
|
+
* "wpDependencyExternals": true
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export interface BuildConfig {
|
|
177
|
+
/**
|
|
178
|
+
* Entry points for scripts and styles.
|
|
179
|
+
* Keys become output filenames, values are source file paths.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```json
|
|
183
|
+
* {
|
|
184
|
+
* "admin": "./assets/js/admin/admin.js",
|
|
185
|
+
* "frontend": "./assets/js/frontend/frontend.js",
|
|
186
|
+
* "admin-style": "./assets/css/admin/admin-style.scss"
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
entry: Record<string, string>;
|
|
191
|
+
/**
|
|
192
|
+
* Entry points for ES modules (output as .mjs files).
|
|
193
|
+
* These are built with `format: 'esm'` and support code splitting.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```json
|
|
197
|
+
* {
|
|
198
|
+
* "interactivity-module": "./assets/js/interactivity/module.ts"
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
moduleEntry: Record<string, string>;
|
|
203
|
+
/**
|
|
204
|
+
* Path configuration for source and output directories.
|
|
205
|
+
* @see {@link PathsConfig}
|
|
206
|
+
*/
|
|
207
|
+
paths: PathsConfig;
|
|
208
|
+
/**
|
|
209
|
+
* Output filename patterns.
|
|
210
|
+
* @see {@link FilenamesConfig}
|
|
211
|
+
*/
|
|
212
|
+
filenames: FilenamesConfig;
|
|
213
|
+
/**
|
|
214
|
+
* Enable automatic entry detection from block.json files.
|
|
215
|
+
* When enabled, the build tool scans `paths.blocksDir` for block.json
|
|
216
|
+
* files and automatically creates entries for script/style assets.
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
useBlockAssets: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Enable ES module output for script modules.
|
|
222
|
+
* When enabled, entries in `moduleEntry` are built as ES modules.
|
|
223
|
+
* @default false
|
|
224
|
+
*/
|
|
225
|
+
useScriptModules: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Enable WordPress dependency externalization.
|
|
228
|
+
* When enabled:
|
|
229
|
+
* - @wordpress/* imports are externalized to WordPress globals
|
|
230
|
+
* - .asset.php files are generated with dependency arrays
|
|
231
|
+
* - Vendor packages (react, lodash, etc.) are also externalized
|
|
232
|
+
* @default true
|
|
233
|
+
*/
|
|
234
|
+
wpDependencyExternals: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Enable automatic loading of block-specific stylesheets.
|
|
237
|
+
* Scans `paths.blocksStyles` for stylesheets matching core block names.
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
|
+
loadBlockSpecificStyles: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Enable Hot Module Replacement in watch mode.
|
|
243
|
+
* Starts a WebSocket server for live reload notifications.
|
|
244
|
+
* @default false
|
|
245
|
+
*/
|
|
246
|
+
hot: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Port for the HMR WebSocket server.
|
|
249
|
+
* @default 8887
|
|
250
|
+
*/
|
|
251
|
+
devServerPort: number;
|
|
252
|
+
/**
|
|
253
|
+
* Development URL for the WordPress site.
|
|
254
|
+
* Used for proxy configuration in development mode.
|
|
255
|
+
* @default ""
|
|
256
|
+
*/
|
|
257
|
+
devURL: string;
|
|
258
|
+
/**
|
|
259
|
+
* Generate source maps for debugging.
|
|
260
|
+
* Always enabled in development mode regardless of this setting.
|
|
261
|
+
* @default false
|
|
262
|
+
*/
|
|
263
|
+
sourcemap: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Public path for assets (used in generated URLs).
|
|
266
|
+
* @default "/dist/"
|
|
267
|
+
*/
|
|
268
|
+
publicPath: string;
|
|
269
|
+
/**
|
|
270
|
+
* Custom package namespaces to externalize.
|
|
271
|
+
* @see {@link ExternalNamespaceConfig}
|
|
272
|
+
*/
|
|
273
|
+
externalNamespaces: Record<string, ExternalNamespaceConfig>;
|
|
274
|
+
/**
|
|
275
|
+
* PostCSS configuration (auto-detected).
|
|
276
|
+
* @see {@link PostCSSConfig}
|
|
277
|
+
*/
|
|
278
|
+
postcss?: PostCSSConfig;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* PostCSS configuration options.
|
|
282
|
+
*
|
|
283
|
+
* The build tool automatically detects postcss.config.js in the project root.
|
|
284
|
+
* If not found, it uses the default configuration with global styles and mixins.
|
|
285
|
+
*/
|
|
286
|
+
export interface PostCSSConfig {
|
|
287
|
+
/**
|
|
288
|
+
* Path to the PostCSS configuration file.
|
|
289
|
+
* If not specified, uses the default configuration.
|
|
290
|
+
*/
|
|
291
|
+
configPath?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Directory containing global CSS files.
|
|
294
|
+
* Overrides the default from paths.globalStylesDir.
|
|
295
|
+
*/
|
|
296
|
+
globalStylesDir?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Directory containing mixin definition files.
|
|
299
|
+
* Overrides the default from paths.globalMixinsDir.
|
|
300
|
+
*/
|
|
301
|
+
globalMixinsDir?: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Detected entry points categorized by type.
|
|
305
|
+
*
|
|
306
|
+
* The entry detection process scans:
|
|
307
|
+
* 1. `buildfiles.config.js` or `config.entry`
|
|
308
|
+
* 2. `config.moduleEntry` for ES modules
|
|
309
|
+
* 3. block.json files (if `useBlockAssets` is enabled)
|
|
310
|
+
*/
|
|
311
|
+
export interface DetectedEntries {
|
|
312
|
+
/**
|
|
313
|
+
* Regular JavaScript/TypeScript entries (IIFE output).
|
|
314
|
+
* Key is the output name, value is the source file path.
|
|
315
|
+
*/
|
|
316
|
+
scripts: Record<string, string>;
|
|
317
|
+
/**
|
|
318
|
+
* ES Module entries (.mjs output).
|
|
319
|
+
* Key is the output name, value is the source file path.
|
|
320
|
+
*/
|
|
321
|
+
modules: Record<string, string>;
|
|
322
|
+
/**
|
|
323
|
+
* Standalone CSS/SCSS entries.
|
|
324
|
+
* Key is the output name, value is the source file path.
|
|
325
|
+
*/
|
|
326
|
+
styles: Record<string, string>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Result of resolving an external package.
|
|
330
|
+
*
|
|
331
|
+
* Used by the dependency extraction plugin to determine how to
|
|
332
|
+
* externalize a package and track it as a dependency.
|
|
333
|
+
*/
|
|
334
|
+
export interface ExternalResolution {
|
|
335
|
+
/**
|
|
336
|
+
* The global variable path where the package is available.
|
|
337
|
+
* For @wordpress/blocks, this would be "wp.blocks".
|
|
338
|
+
*/
|
|
339
|
+
global: string;
|
|
340
|
+
/**
|
|
341
|
+
* The WordPress script handle for the package.
|
|
342
|
+
* For @wordpress/blocks, this would be "wp-blocks".
|
|
343
|
+
*/
|
|
344
|
+
handle: string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Dependency information for a single entry point.
|
|
348
|
+
*
|
|
349
|
+
* Used internally to track which WordPress packages are imported
|
|
350
|
+
* by each entry point, for .asset.php generation.
|
|
351
|
+
*/
|
|
352
|
+
export interface DependencyInfo {
|
|
353
|
+
/**
|
|
354
|
+
* Set of WordPress script handles that this entry depends on.
|
|
355
|
+
* Example: Set(['wp-blocks', 'wp-element', 'wp-i18n'])
|
|
356
|
+
*/
|
|
357
|
+
dependencies: Set<string>;
|
|
358
|
+
/**
|
|
359
|
+
* Content hash for cache busting.
|
|
360
|
+
* Generated from the output file content.
|
|
361
|
+
*/
|
|
362
|
+
version: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Result returned from the build function.
|
|
366
|
+
*
|
|
367
|
+
* Contains information about the build success, timing, and any errors.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* const result = await build();
|
|
372
|
+
* if (result.success) {
|
|
373
|
+
* console.log(`Built in ${result.duration}ms`);
|
|
374
|
+
* } else {
|
|
375
|
+
* console.error('Build failed:', result.errors);
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
export interface BuildResult {
|
|
380
|
+
/**
|
|
381
|
+
* Whether the build completed successfully.
|
|
382
|
+
*/
|
|
383
|
+
success: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Build duration in milliseconds.
|
|
386
|
+
*/
|
|
387
|
+
duration: number;
|
|
388
|
+
/**
|
|
389
|
+
* Count of entries built by type.
|
|
390
|
+
*/
|
|
391
|
+
entries: {
|
|
392
|
+
/** Number of IIFE script entries built */
|
|
393
|
+
scripts: number;
|
|
394
|
+
/** Number of ES module entries built */
|
|
395
|
+
modules: number;
|
|
396
|
+
/** Number of stylesheet entries built */
|
|
397
|
+
styles: number;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Error messages if the build failed.
|
|
401
|
+
* Only present when `success` is false.
|
|
402
|
+
*/
|
|
403
|
+
errors?: string[];
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Options for watch mode.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* await watch({
|
|
411
|
+
* hot: true,
|
|
412
|
+
* port: 8887,
|
|
413
|
+
* onRebuild: (result) => {
|
|
414
|
+
* console.log('Rebuilt:', result.success);
|
|
415
|
+
* }
|
|
416
|
+
* });
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
export interface WatchOptions {
|
|
420
|
+
/**
|
|
421
|
+
* Enable Hot Module Replacement.
|
|
422
|
+
* When enabled, starts a WebSocket server for live reload.
|
|
423
|
+
* @default false (uses config.hot)
|
|
424
|
+
*/
|
|
425
|
+
hot?: boolean;
|
|
426
|
+
/**
|
|
427
|
+
* Port for the HMR WebSocket server.
|
|
428
|
+
* @default 8887 (uses config.devServerPort)
|
|
429
|
+
*/
|
|
430
|
+
port?: number;
|
|
431
|
+
/**
|
|
432
|
+
* Callback invoked after each rebuild.
|
|
433
|
+
* Useful for custom notifications or logging.
|
|
434
|
+
*/
|
|
435
|
+
onRebuild?: (result: BuildResult) => void;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* CLI command handler function type.
|
|
439
|
+
*
|
|
440
|
+
* Each CLI command (build, start, watch) is implemented as a handler
|
|
441
|
+
* that receives command-line arguments and returns a Promise.
|
|
442
|
+
*
|
|
443
|
+
* @param args - Command-line arguments (excluding the command name)
|
|
444
|
+
*/
|
|
445
|
+
export type CommandHandler = (args: string[]) => Promise<void>;
|
|
446
|
+
/**
|
|
447
|
+
* Map of CLI commands to their handlers.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link CommandHandler}
|
|
450
|
+
*/
|
|
451
|
+
export interface Commands {
|
|
452
|
+
/** Production build command */
|
|
453
|
+
build: CommandHandler;
|
|
454
|
+
/** Development mode with HMR */
|
|
455
|
+
start: CommandHandler;
|
|
456
|
+
/** Watch mode without HMR */
|
|
457
|
+
watch: CommandHandler;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* WordPress block.json metadata structure.
|
|
461
|
+
*
|
|
462
|
+
* This interface represents the relevant fields from block.json
|
|
463
|
+
* that the build tool uses for entry detection and transformation.
|
|
464
|
+
*
|
|
465
|
+
* @see {@link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/}
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* ```json
|
|
469
|
+
* {
|
|
470
|
+
* "name": "my-plugin/my-block",
|
|
471
|
+
* "editorScript": "file:./index.js",
|
|
472
|
+
* "editorStyle": "file:./editor.css",
|
|
473
|
+
* "style": "file:./style.css",
|
|
474
|
+
* "viewScript": "file:./view.js",
|
|
475
|
+
* "viewScriptModule": "file:./view-module.js"
|
|
476
|
+
* }
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
export interface BlockMetadata {
|
|
480
|
+
/**
|
|
481
|
+
* Block name in namespace/block-name format.
|
|
482
|
+
*/
|
|
483
|
+
name?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Block version for cache busting.
|
|
486
|
+
* Auto-generated from style file hashes if not provided.
|
|
487
|
+
*/
|
|
488
|
+
version?: string;
|
|
489
|
+
/**
|
|
490
|
+
* Script loaded on both editor and frontend.
|
|
491
|
+
* Can be a handle, URL, or file: path.
|
|
492
|
+
*/
|
|
493
|
+
script?: string | string[];
|
|
494
|
+
/**
|
|
495
|
+
* Script loaded only in the editor.
|
|
496
|
+
* Typically the main block registration script.
|
|
497
|
+
*/
|
|
498
|
+
editorScript?: string | string[];
|
|
499
|
+
/**
|
|
500
|
+
* Script loaded only on the frontend.
|
|
501
|
+
* For interactive functionality.
|
|
502
|
+
*/
|
|
503
|
+
viewScript?: string | string[];
|
|
504
|
+
/**
|
|
505
|
+
* ES Module loaded on both editor and frontend.
|
|
506
|
+
* Output as .mjs file.
|
|
507
|
+
*/
|
|
508
|
+
scriptModule?: string | string[];
|
|
509
|
+
/**
|
|
510
|
+
* ES Module loaded only on the frontend.
|
|
511
|
+
* For WordPress Interactivity API usage.
|
|
512
|
+
*/
|
|
513
|
+
viewScriptModule?: string | string[];
|
|
514
|
+
/**
|
|
515
|
+
* Stylesheet loaded on both editor and frontend.
|
|
516
|
+
*/
|
|
517
|
+
style?: string | string[];
|
|
518
|
+
/**
|
|
519
|
+
* Stylesheet loaded only in the editor.
|
|
520
|
+
*/
|
|
521
|
+
editorStyle?: string | string[];
|
|
522
|
+
/**
|
|
523
|
+
* Stylesheet loaded only on the frontend.
|
|
524
|
+
*/
|
|
525
|
+
viewStyle?: string | string[];
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Extended esbuild plugin interface with dependency tracking.
|
|
529
|
+
*
|
|
530
|
+
* Used by the WordPress dependency extraction plugin to expose
|
|
531
|
+
* tracked dependencies for testing and debugging.
|
|
532
|
+
*/
|
|
533
|
+
export interface DependencyExtractionPlugin extends Plugin {
|
|
534
|
+
/**
|
|
535
|
+
* Get all tracked dependencies across entry points.
|
|
536
|
+
* @returns Map of entry point paths to their dependency info
|
|
537
|
+
*/
|
|
538
|
+
getDependencies: () => Map<string, DependencyInfo>;
|
|
539
|
+
}
|
|
540
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,a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IAE1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,MAAM;IACzD;;;OAGG;IACH,eAAe,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACnD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @10up/build
|
|
3
|
+
*
|
|
4
|
+
* This module contains all TypeScript interfaces and types used throughout
|
|
5
|
+
* the build tool. These types define the configuration schema, build results,
|
|
6
|
+
* and internal data structures.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
* @module types
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point detection for WordPress blocks and build files
|
|
3
|
+
*/
|
|
4
|
+
import type { BuildConfig, DetectedEntries } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Detect all entry points for the build
|
|
7
|
+
*/
|
|
8
|
+
export declare function detectEntries(config: BuildConfig): Promise<DetectedEntries>;
|
|
9
|
+
/**
|
|
10
|
+
* Get block-specific style entries (for loadBlockSpecificStyles option)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBlockSpecificStyles(config: BuildConfig): Record<string, string>;
|
|
13
|
+
//# sourceMappingURL=entry-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-detection.d.ts","sourceRoot":"","sources":["../../src/utils/entry-detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAiB,MAAM,aAAa,CAAC;AAiB/E;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CA0BjF;AAoMD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBlF"}
|