UNPKG

ali-outcode-new

Version:

first

46 lines 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const lowcode_code_generator_1 = require("@alilc/lowcode-code-generator"); const pluginFactory = (config) => { const cfg = Object.assign({ fileType: lowcode_code_generator_1.FileType.JSX }, config); const plugin = (pre) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { var _a, _b; const next = Object.assign({}, pre); const ir = next.ir; if (((_a = ir.methodsModule) === null || _a === void 0 ? void 0 : _a.type) !== 'JSModule' || !((_b = ir.methodsModule) === null || _b === void 0 ? void 0 : _b.source)) { return next; } // 创建 methods.jsx next.chunks.push({ type: lowcode_code_generator_1.ChunkType.STRING, subModule: 'methods', fileType: cfg.fileType, name: lowcode_code_generator_1.COMMON_CHUNK_NAME.CustomContent, content: ir.methodsModule.source, linkAfter: [], }); // 引入对应的模块 next.chunks.push({ type: lowcode_code_generator_1.ChunkType.STRING, fileType: cfg.fileType, name: lowcode_code_generator_1.COMMON_CHUNK_NAME.InternalDepsImport, content: "import __$$methodsModule from './methods';", linkAfter: [...lowcode_code_generator_1.DEFAULT_LINK_AFTER[lowcode_code_generator_1.COMMON_CHUNK_NAME.InternalDepsImport]], }); // 将导出的东东都放到 class 上实例方法部分 next.chunks.push({ type: lowcode_code_generator_1.ChunkType.STRING, fileType: cfg.fileType, name: lowcode_code_generator_1.CLASS_DEFINE_CHUNK_NAME.ConstructorContent, content: 'Object.assign(this, __$$methodsModule);', linkAfter: [ ...lowcode_code_generator_1.DEFAULT_LINK_AFTER[lowcode_code_generator_1.CLASS_DEFINE_CHUNK_NAME.ConstructorContent], ], }); return next; }); return plugin; }; exports.default = pluginFactory; //# sourceMappingURL=example.js.map