@10up/wp-vite-plugins 1.0.0-alpha.0 → 1.0.0-alpha.2

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
@@ -174,7 +174,36 @@ interface WpExternalsOptions {
174
174
  * Example: `['ignite-wp-navigation', 'ignite-*']`
175
175
  */
176
176
  scriptModuleNamespaces?: string[];
177
+ /**
178
+ * Bare package names to **force-bundle**: their externalization is
179
+ * suppressed and their imports are rewritten to resolve against the
180
+ * installed package's ESM entry instead.
181
+ *
182
+ * The escape hatch for packages whose WP metadata does not match what
183
+ * WordPress core actually registers. Merges with (never replaces)
184
+ * `DEFAULT_BUNDLED_PACKAGES`.
185
+ *
186
+ * Bare names only — `@wordpress/dataviews/wp` and other subpath entries
187
+ * throw at config time, because force-bundling is a whole-package verdict.
188
+ *
189
+ * Example: `['@wordpress/icons', 'some-lying-package']`
190
+ */
191
+ bundle?: string[];
177
192
  }
193
+ /**
194
+ * Packages that claim externalizability they don't have. Same rationale as
195
+ * core's `dependency-extraction-webpack-plugin` keeping a hardcoded
196
+ * `BUNDLED_PACKAGES` list: the metadata is wrong with respect to what core
197
+ * registers, and there is nowhere else to record that.
198
+ *
199
+ * `@wordpress/icons@10.x` ships `wpScript: true`, but WordPress core registers
200
+ * no `wp-icons` script — it's absent from `script-loader-packages.php`. Trusting
201
+ * the metadata produces two failures at once: `window.wp.icons` is undefined,
202
+ * *and* the unregistered `wp-icons` dependency makes WordPress refuse to
203
+ * enqueue the script at all. (`@wordpress/icons@11.x` dropped `wpScript`, so
204
+ * without this list the behavior depends on which copy the resolver hoists.)
205
+ */
206
+ declare const DEFAULT_BUNDLED_PACKAGES: string[];
178
207
  declare function wpExternals(options?: WpExternalsOptions): Plugin[];
179
208
 
180
209
  interface WpOptions {
@@ -195,11 +224,21 @@ interface WpOptions {
195
224
  externals?: WpExternalsOptions | false;
196
225
  /** Disable the auto-included script-IIFE helper. Default: enabled in script mode. */
197
226
  iife?: false;
227
+ /**
228
+ * Disable the auto-included per-entry module duplication. Default: enabled
229
+ * in script mode. Without it, a module two script entries share becomes a
230
+ * shared chunk each entry `import`s — invalid as a classic script.
231
+ */
232
+ scriptDedupe?: false;
198
233
  /** Disable the auto-included CSS-only-chunk cleanup. Default: always enabled. */
199
234
  cleanCssChunks?: false;
235
+ /** Disable the auto-included CSS-only-entry `.asset.php` sidecars. Default: always enabled. */
236
+ cssAssetInfo?: false;
200
237
  }
201
238
  declare function wp(options?: WpOptions): Plugin[];
202
239
 
240
+ declare function wpScriptDedupe(): Plugin;
241
+
203
242
  /**
204
243
  * vite-plugin-wp-script-iife
205
244
  *
@@ -208,6 +247,15 @@ declare function wp(options?: WpOptions): Plugin[];
208
247
  * bodies, defeating the global-scope isolation needed when WP enqueues
209
248
  * these as classic <script> tags.
210
249
  *
250
+ * It is also the gate that guarantees the output *is* a valid classic script:
251
+ * every chunk is parsed before it's wrapped, and one that doesn't compile fails
252
+ * the build instead of shipping a file the browser cannot load. The two causes
253
+ * worth diagnosing by name are a live `import`/`export` statement (a shared
254
+ * chunk Rolldown refused to duplicate) and an `import.meta` reference (Vite's
255
+ * dynamic-import preload helper). The `import.meta` members that helper touches
256
+ * are rewritten to classic-script-safe expressions through an injected
257
+ * `define`, so the failure only fires for cases the define can't reach.
258
+ *
211
259
  * Only run this in script mode. Module-mode entries (`wp_register_script_module`)
212
260
  * must stay as bare ESM for WP's import map to resolve them at runtime.
213
261
  */
@@ -228,4 +276,6 @@ declare function wpScriptIife(): Plugin;
228
276
 
229
277
  declare function wpCleanCssChunks(): Plugin;
230
278
 
231
- export { type ExternalNamespace, type WpAdminPagesOptions, type WpAdminPagesPhpOptions, type WpBlockStylesOptions, type WpBlocksOptions, type WpCopyAssetsOptions, type WpExternalsOptions, type WpOptions, wp, wpAdminPages, wpBlockStyles, wpBlocks, wpCleanCssChunks, wpCopyAssets, wpExternals, wpScriptIife };
279
+ declare function wpCssAssetInfo(): Plugin;
280
+
281
+ export { DEFAULT_BUNDLED_PACKAGES, type ExternalNamespace, type WpAdminPagesOptions, type WpAdminPagesPhpOptions, type WpBlockStylesOptions, type WpBlocksOptions, type WpCopyAssetsOptions, type WpExternalsOptions, type WpOptions, wp, wpAdminPages, wpBlockStyles, wpBlocks, wpCleanCssChunks, wpCopyAssets, wpCssAssetInfo, wpExternals, wpScriptDedupe, wpScriptIife };