test(bgm): cover emitted shape and multi-package collection
Add a SerializedPackage type for the JSON the plugin emits, and tests that assert the maps serialize to plain objects, that the packages module returns every package, and that buildStart watches def files. Add a second fixture package to exercise multi-package collection.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import * as path from 'node:path';
|
||||
import type { Plugin } from 'vite';
|
||||
import { collectPackages, loadDefs } from './collect.js';
|
||||
import type { Package } from './types.js';
|
||||
import type { Package, SerializedPackage } from './types.js';
|
||||
|
||||
const VIRTUAL_PREFIX = '\0bgm:';
|
||||
/** Public specifier for the module that lists every package. */
|
||||
@@ -73,7 +73,7 @@ export function bgm(options: BgmOptions): Plugin {
|
||||
* Serialize a `Package` for JSON emission. The parts/surfaces/setups are
|
||||
* `Map`s, which `JSON.stringify` would otherwise turn into `{}`.
|
||||
*/
|
||||
function toJson(pkg: Package): Record<string, unknown> {
|
||||
function toJson(pkg: Package): SerializedPackage {
|
||||
return {
|
||||
meta: pkg.meta,
|
||||
parts: Object.fromEntries(pkg.parts),
|
||||
|
||||
Reference in New Issue
Block a user