mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +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;
|
inStrictMode?: boolean;
|
||||||
/** 一些额外的上下文数据 */
|
/** 一些额外的上下文数据 */
|
||||||
extraContextData?: Record<string, unknown>;
|
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 {
|
export class ProjectBuilder implements IProjectBuilder {
|
||||||
@ -67,7 +72,12 @@ export class ProjectBuilder implements IProjectBuilder {
|
|||||||
/** 一些额外的上下文数据 */
|
/** 一些额外的上下文数据 */
|
||||||
readonly extraContextData: IContextData;
|
readonly extraContextData: IContextData;
|
||||||
|
|
||||||
constructor({
|
constructor(builderOptions: ProjectBuilderInitOptions) {
|
||||||
|
let customBuilderOptions = builderOptions;
|
||||||
|
if (typeof builderOptions.customizeBuilderOptions === 'function') {
|
||||||
|
customBuilderOptions = builderOptions.customizeBuilderOptions(builderOptions);
|
||||||
|
}
|
||||||
|
const {
|
||||||
template,
|
template,
|
||||||
plugins,
|
plugins,
|
||||||
postProcessors,
|
postProcessors,
|
||||||
@ -76,7 +86,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
|||||||
projectPostProcessors = [],
|
projectPostProcessors = [],
|
||||||
inStrictMode = false,
|
inStrictMode = false,
|
||||||
extraContextData = {},
|
extraContextData = {},
|
||||||
}: ProjectBuilderInitOptions) {
|
} = customBuilderOptions;
|
||||||
this.template = template;
|
this.template = template;
|
||||||
this.plugins = plugins;
|
this.plugins = plugins;
|
||||||
this.postProcessors = postProcessors;
|
this.postProcessors = postProcessors;
|
||||||
|
|||||||
@ -91,6 +91,7 @@ export default function createIceJsProjectBuilder(
|
|||||||
packageJSON: [icejs.plugins.packageJSON()],
|
packageJSON: [icejs.plugins.packageJSON()],
|
||||||
},
|
},
|
||||||
postProcessors: [prettier()],
|
postProcessors: [prettier()],
|
||||||
|
customizeBuilderOptions: options?.customizeBuilderOptions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ export default function createRaxProjectBuilder(
|
|||||||
packageJSON: [raxApp.plugins.packageJSON(options)],
|
packageJSON: [raxApp.plugins.packageJSON(options)],
|
||||||
},
|
},
|
||||||
postProcessors: [prettier()],
|
postProcessors: [prettier()],
|
||||||
|
customizeBuilderOptions: options?.customizeBuilderOptions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import {
|
|||||||
|
|
||||||
import { IParseResult } from './intermediate';
|
import { IParseResult } from './intermediate';
|
||||||
import { IScopeBindings } from '../utils/ScopeBindings';
|
import { IScopeBindings } from '../utils/ScopeBindings';
|
||||||
|
import type { ProjectBuilderInitOptions } from '../generator/ProjectBuilder';
|
||||||
|
|
||||||
export enum FileType {
|
export enum FileType {
|
||||||
CSS = 'css',
|
CSS = 'css',
|
||||||
@ -167,6 +168,11 @@ export interface IProjectBuilderOptions {
|
|||||||
* - expr: 求值的表达式
|
* - expr: 求值的表达式
|
||||||
*/
|
*/
|
||||||
evalErrorsHandler?: string;
|
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 {
|
export interface IProjectBuilder {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user