UNPKG

@mega-apps/vue-addon-loader

Version:

Vue addon loader, for SFCs and components. You can use it for vue component online.

68 lines (66 loc) 2.23 kB
import { IModuleExport, ILoadModuleOptions, TLangProcessorHandler, IAbstractPath } from "./types"; export * from "./types"; /** * the version of the library (process.env.VERSION is set by webpack, at compile-time) */ export declare const version: string; /** * the version of Vue that is expected by the library */ export { vueVersion } from "./createSFCModule"; export { createCJSModule } from "./tools"; /** * 加载模块 * * 这是主要功能。 * 此函数仅用于加载应用程序的入口点。 * 如果由于某些原因需要在组件中使用它,请确保至少共享选项。 ' compiledCache '对象在所有调用之间。 * * This is the main function. * This function is intended to be used only to load the entry point of your application. * If for some reason you need to use it in your components, be sure to share at least the options.`compiledCache` object between all calls. * * @param path The path of the `.vue` file. If path is not a path (eg. an string ID), your [[getFileContent]] function must return a [[File]] object. * @param options The options * @returns A Promise of the component * * **example using `Vue.defineAsyncComponent`:** * * ```javascript * * const app = Vue.createApp({ * components: { * 'my-component': Vue.defineAsyncComponent( () => loadModule('./myComponent.vue', options) ) * }, * template: '<my-component></my-component>' * }); * * ``` * * **example using `await`:** * * ```javascript * ;(async () => { * * const app = Vue.createApp({ * components: { * 'my-component': await loadModule('./myComponent.vue', options) * }, * template: '<my-component></my-component>' * }); * * })() * .catch(ex => console.error(ex)); * * ``` * */ export declare function loadModule(path: IAbstractPath, options?: ILoadModuleOptions): Promise<IModuleExport>; /** * Convert a function to template processor interface (consolidate) * * 构建模板处理器,将源码 */ export declare function buildTemplateProcessor(processor: TLangProcessorHandler): { render: (source: string, preprocessOptions: string, cb: (_err: any, _res: any) => void) => void; };