mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-10 18:03:01 +00:00
feat: add a hook for customizing project builder options
This commit is contained in:
parent
c4bfeaa201
commit
7ddc155f0a
@ -40,6 +40,11 @@ export interface ProjectBuilderInitOptions {
|
||||
inStrictMode?: boolean;
|
||||
/** 一些额外的上下文数据 */
|
||||
extraContextData?: Record<string, unknown>;
|
||||
/**
|
||||
* Hook which is used to customize original options, we can reorder/add/remove plugins/processors
|
||||
* of the existing solution.
|
||||
*/
|
||||
customizeBuilderOptions?(originalOptions: ProjectBuilderInitOptions): ProjectBuilderInitOptions;
|
||||
}
|
||||
|
||||
export class ProjectBuilder implements IProjectBuilder {
|
||||
@ -67,16 +72,21 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
/** 一些额外的上下文数据 */
|
||||
readonly extraContextData: IContextData;
|
||||
|
||||
constructor({
|
||||
template,
|
||||
plugins,
|
||||
postProcessors,
|
||||
schemaParser = new SchemaParser(),
|
||||
projectPreProcessors = [],
|
||||
projectPostProcessors = [],
|
||||
inStrictMode = false,
|
||||
extraContextData = {},
|
||||
}: ProjectBuilderInitOptions) {
|
||||
constructor(builderOptions: ProjectBuilderInitOptions) {
|
||||
let customBuilderOptions = builderOptions;
|
||||
if (typeof builderOptions.customizeBuilderOptions === 'function') {
|
||||
customBuilderOptions = builderOptions.customizeBuilderOptions(builderOptions);
|
||||
}
|
||||
const {
|
||||
template,
|
||||
plugins,
|
||||
postProcessors,
|
||||
schemaParser = new SchemaParser(),
|
||||
projectPreProcessors = [],
|
||||
projectPostProcessors = [],
|
||||
inStrictMode = false,
|
||||
extraContextData = {},
|
||||
} = customBuilderOptions;
|
||||
this.template = template;
|
||||
this.plugins = plugins;
|
||||
this.postProcessors = postProcessors;
|
||||
|
||||
@ -91,6 +91,7 @@ export default function createIceJsProjectBuilder(
|
||||
packageJSON: [icejs.plugins.packageJSON()],
|
||||
},
|
||||
postProcessors: [prettier()],
|
||||
customizeBuilderOptions: options?.customizeBuilderOptions,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ export default function createRaxProjectBuilder(
|
||||
packageJSON: [raxApp.plugins.packageJSON(options)],
|
||||
},
|
||||
postProcessors: [prettier()],
|
||||
customizeBuilderOptions: options?.customizeBuilderOptions,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import {
|
||||
|
||||
import { IParseResult } from './intermediate';
|
||||
import { IScopeBindings } from '../utils/ScopeBindings';
|
||||
import type { ProjectBuilderInitOptions } from '../generator/ProjectBuilder';
|
||||
|
||||
export enum FileType {
|
||||
CSS = 'css',
|
||||
@ -167,6 +168,11 @@ export interface IProjectBuilderOptions {
|
||||
* - expr: 求值的表达式
|
||||
*/
|
||||
evalErrorsHandler?: string;
|
||||
/**
|
||||
* Hook which is used to customize original options, we can reorder/add/remove plugins/processors
|
||||
* of the existing solution.
|
||||
*/
|
||||
customizeBuilderOptions?(originalOptions: ProjectBuilderInitOptions): ProjectBuilderInitOptions;
|
||||
}
|
||||
|
||||
export interface IProjectBuilder {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user