A build-time bundler plugin (v0.2.1) that scans TypeScript types and auto-generates faker-based mock data, replacing createMock<T>() calls with inline object literals. Supports Vite, Rollup, webpack, and esbuild. Handles interfaces, type aliases, enums, unions, intersections, tuples, utility types (Partial, Required, etc.), and field name inference (e.g., *Id → UUID). No runtime overhead; types reference project + node_modules. Caveats: optional fields omitted ~30% of the time, advanced utility types (Extract, Exclude) generate empty objects. Requires Node >=20.11.0 and one of the supported bundlers (vite >=4, rollup >=3, webpack >=5, esbuild >=0.18).
npm install unplugin-ts-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up unplugin-ts-mock with Vite, defines a User interface, and uses createMock and createMockList to generate mock data at build time.
Override specific fields after creation (e.g., user.name = 'Fixed Name') if deterministic values are required.
Manually define mocks for types using these utilities, or avoid them in mock-generating contexts.
Update Node.js to version 20.11.0 or higher.
Monitor peer dependency requirements; upgrade bundlers accordingly.
Rename your own imports or avoid manual imports of enums that the plugin auto-injects.
Ensure TypeScript is installed and a valid tsconfig.json exists in your project root.
Run 'npm install unplugin-ts-mock' and import using the correct framework subpath: 'unplugin-ts-mock/vite', 'unplugin-ts-mock/webpack', etc.
Install faker explicitly: 'npm install @faker-js/faker'.
Ensure the plugin is correctly configured in your bundler and that you provide a type argument: createMock<YourType>()