fix: build issues

This commit is contained in:
2023-11-01 15:22:32 +01:00
parent c7555e1918
commit 4bdd4b20d0
15 changed files with 188 additions and 74 deletions

View File

@@ -6,7 +6,21 @@ import {createGenerator} from 'ts-json-schema-generator';
export type SchemaConsumer = (this: PluginContext, schema: JSONSchema7) => Record<string, string | Buffer>;
export const jsonSchema: EsbuildPlugin = {
/**
* ESBuild Plugin for directly importing schemas
*
* Schemas will be bundled in the output, but because each schema is compiled individually,
* the resulting output can be substantially bigger and take longer to compile.
* @example
* interface Foo {}
* import {default as fooSchema} from 'schema:#Foo'
* @example
* // ./my-type.ts
* interface Bar {}
* // ./schema-consumer.ts
* import {default as barSchema} from 'schema:./my-type.js#Bar'
*/
export const esbuildJsonSchemaPlugin: EsbuildPlugin = {
name: 'json-schema',
setup(build) {
const fileRegex = /^schema:/;