@kubb/core 2.0.0-beta.1 → 2.0.0-beta.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.cjs +24 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -40
- package/dist/index.d.ts +24 -40
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/PluginManager.ts +26 -8
- package/src/build.ts +0 -10
- package/src/plugin.ts +4 -4
- package/src/types.ts +22 -41
package/dist/index.d.cts
CHANGED
|
@@ -167,7 +167,7 @@ declare class PluginManager {
|
|
|
167
167
|
}): Promise<void>;
|
|
168
168
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
169
169
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>]>(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput;
|
|
170
|
-
static get hooks(): readonly ["
|
|
170
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
interface Cache<TStore extends object = object> {
|
|
@@ -282,7 +282,6 @@ type CLIOptions = {
|
|
|
282
282
|
*/
|
|
283
283
|
logLevel?: LogLevel;
|
|
284
284
|
};
|
|
285
|
-
type KubbPluginKind = 'schema' | 'controller';
|
|
286
285
|
type KubbUnionPlugins = PluginUnion;
|
|
287
286
|
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
288
287
|
type PluginFactoryOptions<
|
|
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
|
|
|
290
289
|
* Name to be used for the plugin, this will also be used for they key.
|
|
291
290
|
*/
|
|
292
291
|
TName extends string = string,
|
|
293
|
-
/**
|
|
294
|
-
* @type "schema" | "controller"
|
|
295
|
-
*/
|
|
296
|
-
TKind extends KubbPluginKind = KubbPluginKind,
|
|
297
292
|
/**
|
|
298
293
|
* Options of the plugin.
|
|
299
294
|
*/
|
|
@@ -316,55 +311,47 @@ TResolvePathOptions extends object = object,
|
|
|
316
311
|
*/
|
|
317
312
|
TAppMeta = unknown> = {
|
|
318
313
|
name: TName;
|
|
319
|
-
kind: TKind;
|
|
320
314
|
/**
|
|
321
315
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
322
316
|
*/
|
|
323
|
-
key: [
|
|
317
|
+
key: [name: TName | string, identifier?: string | number];
|
|
324
318
|
options: TOptions;
|
|
325
319
|
resolvedOptions: TResolvedOptions;
|
|
326
320
|
api: TAPI;
|
|
327
321
|
resolvePathOptions: TResolvePathOptions;
|
|
328
322
|
appMeta: {
|
|
329
323
|
pluginManager: PluginManager;
|
|
330
|
-
plugin: KubbPlugin<PluginFactoryOptions<TName,
|
|
324
|
+
plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
|
|
331
325
|
} & TAppMeta;
|
|
332
326
|
};
|
|
333
327
|
type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
|
|
334
328
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
335
329
|
/**
|
|
336
330
|
* Unique name used for the plugin
|
|
331
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
337
332
|
* @example @kubb/typescript
|
|
338
333
|
*/
|
|
339
334
|
name: TOptions['name'];
|
|
340
|
-
/**
|
|
341
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
key?: TOptions['key'];
|
|
345
335
|
/**
|
|
346
336
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
347
337
|
*/
|
|
348
338
|
options: TOptions['resolvedOptions'];
|
|
339
|
+
/**
|
|
340
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
341
|
+
* Can be used to validate depended plugins.
|
|
342
|
+
*/
|
|
343
|
+
pre?: Array<string>;
|
|
344
|
+
/**
|
|
345
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
346
|
+
*/
|
|
347
|
+
post?: Array<string>;
|
|
349
348
|
} & (TOptions['api'] extends never ? {
|
|
350
349
|
api?: never;
|
|
351
350
|
} : {
|
|
352
351
|
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
|
|
353
|
-
}) & (TOptions['kind'] extends never ? {
|
|
354
|
-
kind?: never;
|
|
355
|
-
} : {
|
|
356
|
-
/**
|
|
357
|
-
* Kind/type for the plugin
|
|
358
|
-
*
|
|
359
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
360
|
-
*
|
|
361
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
362
|
-
* @default undefined
|
|
363
|
-
*/
|
|
364
|
-
kind: TOptions['kind'];
|
|
365
352
|
});
|
|
366
353
|
type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
367
|
-
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any
|
|
354
|
+
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
|
|
368
355
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
369
356
|
/**
|
|
370
357
|
* Unique name used for the plugin
|
|
@@ -377,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
377
364
|
*/
|
|
378
365
|
key: TOptions['key'];
|
|
379
366
|
/**
|
|
380
|
-
*
|
|
367
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
368
|
+
* Can be used to validate depended plugins.
|
|
381
369
|
*/
|
|
382
|
-
|
|
370
|
+
pre?: Array<string>;
|
|
371
|
+
/**
|
|
372
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
373
|
+
*/
|
|
374
|
+
post?: Array<string>;
|
|
383
375
|
/**
|
|
384
|
-
*
|
|
385
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
386
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
387
|
-
* @default undefined
|
|
376
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
388
377
|
*/
|
|
389
|
-
|
|
378
|
+
options: TOptions['resolvedOptions'];
|
|
390
379
|
} & (TOptions['api'] extends never ? {
|
|
391
380
|
api?: never;
|
|
392
381
|
} : {
|
|
@@ -394,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
394
383
|
});
|
|
395
384
|
type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
396
385
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
397
|
-
/**
|
|
398
|
-
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
399
|
-
* @type hookParallel
|
|
400
|
-
*/
|
|
401
|
-
validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
402
386
|
/**
|
|
403
387
|
* Start of the lifecycle of a plugin.
|
|
404
388
|
* @type hookParallel
|
|
@@ -739,4 +723,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
|
739
723
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
740
724
|
type Plugin = keyof Plugins;
|
|
741
725
|
|
|
742
|
-
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type
|
|
726
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, SchemaGenerator, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
package/dist/index.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ declare class PluginManager {
|
|
|
167
167
|
}): Promise<void>;
|
|
168
168
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
169
169
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>]>(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput;
|
|
170
|
-
static get hooks(): readonly ["
|
|
170
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
interface Cache<TStore extends object = object> {
|
|
@@ -282,7 +282,6 @@ type CLIOptions = {
|
|
|
282
282
|
*/
|
|
283
283
|
logLevel?: LogLevel;
|
|
284
284
|
};
|
|
285
|
-
type KubbPluginKind = 'schema' | 'controller';
|
|
286
285
|
type KubbUnionPlugins = PluginUnion;
|
|
287
286
|
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
288
287
|
type PluginFactoryOptions<
|
|
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
|
|
|
290
289
|
* Name to be used for the plugin, this will also be used for they key.
|
|
291
290
|
*/
|
|
292
291
|
TName extends string = string,
|
|
293
|
-
/**
|
|
294
|
-
* @type "schema" | "controller"
|
|
295
|
-
*/
|
|
296
|
-
TKind extends KubbPluginKind = KubbPluginKind,
|
|
297
292
|
/**
|
|
298
293
|
* Options of the plugin.
|
|
299
294
|
*/
|
|
@@ -316,55 +311,47 @@ TResolvePathOptions extends object = object,
|
|
|
316
311
|
*/
|
|
317
312
|
TAppMeta = unknown> = {
|
|
318
313
|
name: TName;
|
|
319
|
-
kind: TKind;
|
|
320
314
|
/**
|
|
321
315
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
322
316
|
*/
|
|
323
|
-
key: [
|
|
317
|
+
key: [name: TName | string, identifier?: string | number];
|
|
324
318
|
options: TOptions;
|
|
325
319
|
resolvedOptions: TResolvedOptions;
|
|
326
320
|
api: TAPI;
|
|
327
321
|
resolvePathOptions: TResolvePathOptions;
|
|
328
322
|
appMeta: {
|
|
329
323
|
pluginManager: PluginManager;
|
|
330
|
-
plugin: KubbPlugin<PluginFactoryOptions<TName,
|
|
324
|
+
plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
|
|
331
325
|
} & TAppMeta;
|
|
332
326
|
};
|
|
333
327
|
type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
|
|
334
328
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
335
329
|
/**
|
|
336
330
|
* Unique name used for the plugin
|
|
331
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
337
332
|
* @example @kubb/typescript
|
|
338
333
|
*/
|
|
339
334
|
name: TOptions['name'];
|
|
340
|
-
/**
|
|
341
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
key?: TOptions['key'];
|
|
345
335
|
/**
|
|
346
336
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
347
337
|
*/
|
|
348
338
|
options: TOptions['resolvedOptions'];
|
|
339
|
+
/**
|
|
340
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
341
|
+
* Can be used to validate depended plugins.
|
|
342
|
+
*/
|
|
343
|
+
pre?: Array<string>;
|
|
344
|
+
/**
|
|
345
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
346
|
+
*/
|
|
347
|
+
post?: Array<string>;
|
|
349
348
|
} & (TOptions['api'] extends never ? {
|
|
350
349
|
api?: never;
|
|
351
350
|
} : {
|
|
352
351
|
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
|
|
353
|
-
}) & (TOptions['kind'] extends never ? {
|
|
354
|
-
kind?: never;
|
|
355
|
-
} : {
|
|
356
|
-
/**
|
|
357
|
-
* Kind/type for the plugin
|
|
358
|
-
*
|
|
359
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
360
|
-
*
|
|
361
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
362
|
-
* @default undefined
|
|
363
|
-
*/
|
|
364
|
-
kind: TOptions['kind'];
|
|
365
352
|
});
|
|
366
353
|
type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
367
|
-
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any
|
|
354
|
+
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
|
|
368
355
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
369
356
|
/**
|
|
370
357
|
* Unique name used for the plugin
|
|
@@ -377,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
377
364
|
*/
|
|
378
365
|
key: TOptions['key'];
|
|
379
366
|
/**
|
|
380
|
-
*
|
|
367
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
368
|
+
* Can be used to validate depended plugins.
|
|
381
369
|
*/
|
|
382
|
-
|
|
370
|
+
pre?: Array<string>;
|
|
371
|
+
/**
|
|
372
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
373
|
+
*/
|
|
374
|
+
post?: Array<string>;
|
|
383
375
|
/**
|
|
384
|
-
*
|
|
385
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
386
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
387
|
-
* @default undefined
|
|
376
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
388
377
|
*/
|
|
389
|
-
|
|
378
|
+
options: TOptions['resolvedOptions'];
|
|
390
379
|
} & (TOptions['api'] extends never ? {
|
|
391
380
|
api?: never;
|
|
392
381
|
} : {
|
|
@@ -394,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
394
383
|
});
|
|
395
384
|
type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
396
385
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
397
|
-
/**
|
|
398
|
-
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
399
|
-
* @type hookParallel
|
|
400
|
-
*/
|
|
401
|
-
validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
402
386
|
/**
|
|
403
387
|
* Start of the lifecycle of a plugin.
|
|
404
388
|
* @type hookParallel
|
|
@@ -739,4 +723,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
|
739
723
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
740
724
|
type Plugin = keyof Plugins;
|
|
741
725
|
|
|
742
|
-
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type
|
|
726
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, SchemaGenerator, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
package/dist/index.js
CHANGED
|
@@ -1127,8 +1127,7 @@ var definePlugin = createPlugin((options) => {
|
|
|
1127
1127
|
return {
|
|
1128
1128
|
name: pluginName,
|
|
1129
1129
|
options,
|
|
1130
|
-
key: ["
|
|
1131
|
-
kind: "controller",
|
|
1130
|
+
key: ["core"],
|
|
1132
1131
|
api() {
|
|
1133
1132
|
return {
|
|
1134
1133
|
get config() {
|
|
@@ -1472,16 +1471,15 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1472
1471
|
}
|
|
1473
1472
|
getPluginsByKey(hookName, pluginKey) {
|
|
1474
1473
|
const plugins = [...this.plugins];
|
|
1475
|
-
const [
|
|
1474
|
+
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
1476
1475
|
const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
|
|
1477
|
-
const [
|
|
1476
|
+
const [name, identifier] = item.key;
|
|
1478
1477
|
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
1479
|
-
const kindCheck = kind === searchKind;
|
|
1480
1478
|
const nameCheck = name === searchPluginName;
|
|
1481
1479
|
if (searchIdentifier) {
|
|
1482
|
-
return identifierCheck &&
|
|
1480
|
+
return identifierCheck && nameCheck;
|
|
1483
1481
|
}
|
|
1484
|
-
return
|
|
1482
|
+
return nameCheck;
|
|
1485
1483
|
});
|
|
1486
1484
|
if (!pluginByPluginName?.length) {
|
|
1487
1485
|
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
@@ -1513,7 +1511,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1513
1511
|
}
|
|
1514
1512
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1515
1513
|
static get hooks() {
|
|
1516
|
-
return ["
|
|
1514
|
+
return ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
1517
1515
|
}
|
|
1518
1516
|
};
|
|
1519
1517
|
_core = new WeakMap();
|
|
@@ -1531,7 +1529,23 @@ getSortedPlugins_fn = function(hookName) {
|
|
|
1531
1529
|
}
|
|
1532
1530
|
return plugins.filter((item) => item[hookName]);
|
|
1533
1531
|
}
|
|
1534
|
-
return plugins
|
|
1532
|
+
return plugins.map((plugin) => {
|
|
1533
|
+
if (plugin.pre) {
|
|
1534
|
+
const isValid = plugin.pre.every((pluginName2) => plugins.find((pluginToFind) => pluginToFind.name === pluginName2));
|
|
1535
|
+
if (!isValid) {
|
|
1536
|
+
throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return plugin;
|
|
1540
|
+
}).sort((a, b) => {
|
|
1541
|
+
if (b.pre?.includes(a.name)) {
|
|
1542
|
+
return 1;
|
|
1543
|
+
}
|
|
1544
|
+
if (b.post?.includes(a.name)) {
|
|
1545
|
+
return -1;
|
|
1546
|
+
}
|
|
1547
|
+
return 0;
|
|
1548
|
+
});
|
|
1535
1549
|
};
|
|
1536
1550
|
_addExecutedToCallStack = new WeakSet();
|
|
1537
1551
|
addExecutedToCallStack_fn = function(executer) {
|
|
@@ -1622,7 +1636,7 @@ _parse = new WeakSet();
|
|
|
1622
1636
|
parse_fn = function(plugin, pluginManager, context) {
|
|
1623
1637
|
const usedPluginNames = __privateGet(pluginManager, _usedPluginNames);
|
|
1624
1638
|
setUniqueName(plugin.name, usedPluginNames);
|
|
1625
|
-
const key =
|
|
1639
|
+
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
1626
1640
|
if (plugin.name !== "core" && usedPluginNames[plugin.name] >= 2) {
|
|
1627
1641
|
pluginManager.logger.warn("Using multiple of the same plugin is an experimental feature");
|
|
1628
1642
|
}
|
|
@@ -1745,10 +1759,6 @@ ${code}`);
|
|
|
1745
1759
|
async function build(options) {
|
|
1746
1760
|
const pluginManager = await setup(options);
|
|
1747
1761
|
const { fileManager, logger } = pluginManager;
|
|
1748
|
-
await pluginManager.hookParallel({
|
|
1749
|
-
hookName: "validate",
|
|
1750
|
-
parameters: [pluginManager.plugins]
|
|
1751
|
-
});
|
|
1752
1762
|
await pluginManager.hookParallel({
|
|
1753
1763
|
hookName: "buildStart",
|
|
1754
1764
|
parameters: [options.config]
|
|
@@ -1764,10 +1774,6 @@ async function safeBuild(options) {
|
|
|
1764
1774
|
const pluginManager = await setup(options);
|
|
1765
1775
|
const { fileManager, logger } = pluginManager;
|
|
1766
1776
|
try {
|
|
1767
|
-
await pluginManager.hookParallel({
|
|
1768
|
-
hookName: "validate",
|
|
1769
|
-
parameters: [pluginManager.plugins]
|
|
1770
|
-
});
|
|
1771
1777
|
await pluginManager.hookParallel({
|
|
1772
1778
|
hookName: "buildStart",
|
|
1773
1779
|
parameters: [options.config]
|