@cloudbase/lowcode-builder 1.9.1 → 1.9.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.
@@ -14,7 +14,7 @@ const BASE_DEPS = {
14
14
  const CLOUDBASE_DEPS = {
15
15
  '@cloudbase/oauth': '0.1.1-alpha.15',
16
16
  '@cloudbase/weda-client': '1.1.6',
17
- '@cloudbase/weda-cloud-sdk': '1.0.68',
17
+ '@cloudbase/weda-cloud-sdk': '1.0.70',
18
18
  };
19
19
  function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }) {
20
20
  const deps = {};
@@ -17,6 +17,7 @@ const net_1 = require("../util/net");
17
17
  const config_1 = require("../config");
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  const materials_1 = require("../mp/materials");
20
+ const common_3 = require("@cloudbase/lowcode-generator/lib/generator/types/common");
20
21
  const pkg = require('../../../package.json');
21
22
  async function buildWedaConfig({ output, domain = undefined, isPrivateMode = undefined, endpointType = undefined, buildTypeList = [common_1.BuildType.WEB], }) {
22
23
  if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
@@ -101,6 +102,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
101
102
  runtimeDynamicConfig = data;
102
103
  }
103
104
  }
105
+ const officialLib = dependencies.find((item) => item.name === cals_1.OFFICIAL_LIB_KEY);
104
106
  const buildContext = {
105
107
  uin: account === null || account === void 0 ? void 0 : account.uin,
106
108
  projDir: appBuildDir,
@@ -119,6 +121,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
119
121
  disabled: (_c = cals.extra) === null || _c === void 0 ? void 0 : _c.disabled,
120
122
  statusPageId: ((_d = cals.extra) === null || _d === void 0 ? void 0 : _d.statusPageId) || undefined,
121
123
  privatelinkConfig: privatelinkConfig ? { uin: account === null || account === void 0 ? void 0 : account.uin, ...privatelinkConfig } : undefined,
124
+ enableOfficialLibNPM: !!((0, common_3.buildAsLibByBuildType)(buildTypeList) && officialLib),
122
125
  };
123
126
  console.log('domain', domain);
124
127
  console.log('应用名', appKey);
@@ -309,6 +312,7 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
309
312
  deployOptions: inputs.deployOptions,
310
313
  appId: inputs.appId || inputs.appKey,
311
314
  getWebRootPath: getWebRootPath || _getWebRootPath,
315
+ webOptions: inputs.webOptions,
312
316
  };
313
317
  if (inputs.mainAppSerializeData) {
314
318
  inputs.mainAppSerializeData = normalizeCals(inputs.mainAppSerializeData, normalizeCalsOptions);
@@ -345,7 +349,7 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
345
349
  return inputs;
346
350
  }
347
351
  exports.normalizeInputs = normalizeInputs;
348
- function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath }) {
352
+ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath, webOptions }) {
349
353
  var _a;
350
354
  if (!cals.extra) {
351
355
  cals.extra = {};
@@ -365,6 +369,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
365
369
  if (cals.extra.miniprogramPlugins) {
366
370
  cals.extra.miniprogramPlugins = [];
367
371
  }
372
+ const { gatewayConfig = {} } = webOptions || {};
368
373
  let { appConfig = {} } = cals.extra;
369
374
  let { window = {} } = appConfig;
370
375
  let path = getWebRootPath({ appId, name: cals.name, deployOptions });
@@ -380,7 +385,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
380
385
  ? `app/${appId}${(deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) !== types_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
381
386
  : (0, common_1.buildAsXPageByBuildType)(buildTypeList)
382
387
  ? '/'
383
- : path,
388
+ : gatewayConfig.path || path,
384
389
  },
385
390
  };
386
391
  }
@@ -44,7 +44,6 @@ async function runCopy(appBuildDir, webRuntimeAppData, i18nConfig) {
44
44
  const dstFile = path.join(appBuildDir, entry);
45
45
  await fs_extra_1.default.copy(path.join(config_1.appTemplateDir, entry), dstFile);
46
46
  }
47
- await (0, generateFiles_1.writeFile)(path.join(appBuildDir, 'mainAppData.json'), JSON.stringify(webRuntimeAppData, null, 2));
48
47
  const fileDir = path.join(appBuildDir, 'src/i18n/');
49
48
  if (!fs_extra_1.default.existsSync(fileDir)) {
50
49
  fs_extra_1.default.mkdirSync(fileDir, { recursive: true });
@@ -46,14 +46,16 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
46
46
  const junk = __importStar(require("../util/junk"));
47
47
  const url_1 = require("url");
48
48
  const semver = __importStar(require("semver"));
49
+ const lodash_1 = require("lodash");
50
+ const common_3 = require("@cloudbase/lowcode-generator/lib/generator/types/common");
49
51
  let BabelTransform = (code, options) => code;
50
52
  if (!process.env.IS_WEB_WORKER) {
51
53
  let transform = require('../../utils/transform');
52
54
  BabelTransform = transform.BabelTransform;
53
55
  }
54
56
  async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, ignoreInstall = false, cdnEndpoints, }) {
55
- var _a, _b, _c, _d, _e, _f;
56
- const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, } = buildContext;
57
+ var _a, _b, _c, _d, _e, _f, _g, _h;
58
+ const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, enableOfficialLibNPM, } = buildContext;
57
59
  if (!deployOptions.mode || deployOptions.mode === types_1.DEPLOY_MODE.DYNAMIC) {
58
60
  deployOptions.mode = types_1.DEPLOY_MODE.PREVIEW;
59
61
  }
@@ -80,17 +82,23 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
80
82
  var _a;
81
83
  return (_a = used.component['$template']) === null || _a === void 0 ? void 0 : _a.has(item.id);
82
84
  });
85
+ const officialLib = dependencies.find((lib) => lib.name === config_1.OFFICIAL_LIB_KEY);
86
+ if (enableOfficialLibNPM) {
87
+ if (!((_d = (_c = cals.extra) === null || _c === void 0 ? void 0 : _c.npmDependencies) === null || _d === void 0 ? void 0 : _d[cals_1.OFFICIAL_LIB_NPM_PACKAGENAME])) {
88
+ (0, lodash_1.set)(cals, `extra.npmDependencies.${cals_1.OFFICIAL_LIB_NPM_PACKAGENAME}`, officialLib === null || officialLib === void 0 ? void 0 : officialLib.version);
89
+ }
90
+ }
83
91
  // 处理应用数据
84
92
  const mainAppData = (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(cals, dependencies));
85
93
  if (!mainAppData.extra) {
86
94
  mainAppData.extra = { domain };
87
95
  }
88
- if (!((_c = mainAppData.extra) === null || _c === void 0 ? void 0 : _c.domain)) {
96
+ if (!((_e = mainAppData.extra) === null || _e === void 0 ? void 0 : _e.domain)) {
89
97
  mainAppData.extra.domain = domain;
90
98
  }
91
- const subAppDataList = ((_d = subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map) === null || _d === void 0 ? void 0 : _d.call(subAppCalsList, (sub) => (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(sub, dependencies)))) || [];
99
+ const subAppDataList = ((_f = subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map) === null || _f === void 0 ? void 0 : _f.call(subAppCalsList, (sub) => (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(sub, dependencies)))) || [];
92
100
  // 前置操作
93
- const { publicPath, basename, assets = '', _indexPage } = ((_e = mainAppData.appConfig) === null || _e === void 0 ? void 0 : _e.window) || {};
101
+ const { publicPath, basename, assets = '', _indexPage } = ((_g = mainAppData.appConfig) === null || _g === void 0 ? void 0 : _g.window) || {};
94
102
  // 获取 插入的cdn 资源
95
103
  const jsAssets = await (0, generate_1.handleAssets)({
96
104
  appBuildDir: buildDir,
@@ -107,6 +115,9 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
107
115
  // 注意需要包涵官方的(gsd),部分平台方法需要由其补充
108
116
  return lib.name === config_1.OFFICIAL_LIB_KEY || !!(((_a = used.component) === null || _a === void 0 ? void 0 : _a[lib.name]) || ((_b = used.action) === null || _b === void 0 ? void 0 : _b[lib.name]));
109
117
  }), materialsDir, runtime, ignoreInstall);
118
+ if (enableOfficialLibNPM) {
119
+ await fs_extra_1.default.remove(path_1.default.join(h5BuildDir, 'src', 'libraries', `${officialLib === null || officialLib === void 0 ? void 0 : officialLib.name}@${officialLib === null || officialLib === void 0 ? void 0 : officialLib.version}`));
120
+ }
110
121
  const h5LibDirPath = path_1.default.resolve(h5BuildDir, 'src', 'libraries');
111
122
  const libNames = fs_extra_1.default.readdirSync(h5LibDirPath).filter((name) => name !== '.DS_Store');
112
123
  let libNameWithVue;
@@ -172,100 +183,102 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
172
183
  privatelinkConfig,
173
184
  });
174
185
  console.timeEnd(runGenerateTag);
175
- // // 构建 NPM 包
176
- await (0, npm_1.handleNPM)({
177
- appKey,
178
- mainAppData,
179
- subAppDataList,
180
- appBuildDir: h5BuildDir,
181
- dependencies: processedDependencies,
182
- mode,
183
- devTool,
184
- ignoreInstall,
185
- vueVersion,
186
- });
187
- // 生成主题文件
188
- await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
189
- // 生成 webpack 配置
190
- const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
191
- buildContext,
192
- cals,
193
- appKey,
194
- mainAppData,
195
- subAppDataList,
196
- appBuildDir: h5BuildDir,
197
- assets: jsAssets,
198
- buildTypeList,
199
- mode,
200
- devTool,
201
- publicPath,
202
- domain,
203
- cdnEndpoints,
204
- vueVersion,
205
- });
206
- if (typeof libNameWithVue === 'string' && !fs_extra_1.default.existsSync(path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'))) {
207
- fs_extra_1.default.symlinkSync(path_1.default.resolve(h5BuildDir, 'src', 'libraries', libNameWithVue, 'node_modules', 'vue'), path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'));
208
- }
209
- await new Promise((resolve, reject) => {
210
- // 开始编译前清理一下 lowcode 内容
211
- (0, compile_1.startCompile)({
186
+ if (!(0, common_3.buildAsLibByBuildType)(buildTypeList)) {
187
+ // // 构建 NPM 包
188
+ await (0, npm_1.handleNPM)({
189
+ appKey,
190
+ mainAppData,
191
+ subAppDataList,
212
192
  appBuildDir: h5BuildDir,
213
- configPath: webpackConfigPath,
193
+ dependencies: processedDependencies,
194
+ mode,
195
+ devTool,
196
+ ignoreInstall,
197
+ vueVersion,
198
+ });
199
+ // 生成主题文件
200
+ await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
201
+ // 生成 webpack 配置
202
+ const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
203
+ buildContext,
204
+ cals,
214
205
  appKey,
215
- webpackMode: mode,
216
- }, function (err, data) {
217
- if (err) {
218
- reject(err);
219
- }
220
- else {
221
- resolve(data);
222
- }
206
+ mainAppData,
207
+ subAppDataList,
208
+ appBuildDir: h5BuildDir,
209
+ assets: jsAssets,
210
+ buildTypeList,
211
+ mode,
212
+ devTool,
213
+ publicPath,
214
+ domain,
215
+ cdnEndpoints,
216
+ vueVersion,
223
217
  });
224
- });
225
- const MAINIFAST_FILENAME = 'weda-manifest.json';
226
- const preHeatUrls = fs_extra_1.default
227
- .readdirSync(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR))
228
- .filter((file) => junk.not(file) && file !== MAINIFAST_FILENAME)
229
- .map((file) => {
230
- if (/LICENSE\.txt$/.test(file) || /\.map$/.test(file)) {
231
- return '';
232
- }
233
- try {
234
- const url = new url_1.URL(publicPath);
235
- return `${url.origin}${path_1.default.posix.join(url.pathname, file)}`;
218
+ if (typeof libNameWithVue === 'string' && !fs_extra_1.default.existsSync(path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'))) {
219
+ fs_extra_1.default.symlinkSync(path_1.default.resolve(h5BuildDir, 'src', 'libraries', libNameWithVue, 'node_modules', 'vue'), path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'));
236
220
  }
237
- catch (e) {
238
- return path_1.default.posix.join(publicPath || '', file);
239
- }
240
- })
241
- .filter((item) => !!item);
242
- // 普通 web 模式,且非hash模式,根据页面生成多份入口
243
- if (!((_f = cals.extra) === null || _f === void 0 ? void 0 : _f.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
244
- preHeatUrls.push(path_1.default.posix.join(basename || ''));
245
- await Promise.all([
246
- ...(cals.items || []).map((page) => {
247
- preHeatUrls.push(path_1.default.posix.join(basename || '', page.id));
248
- preHeatUrls.push(path_1.default.posix.join(basename || '', page.id, '/'));
249
- return fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, page.id, 'index.html'));
250
- }),
251
- ...(subAppCalsList || []).reduce((list, cals) => {
252
- const { rootPath } = cals.extra || {};
253
- const packageName = (0, util_1.normalizePackageName)(rootPath);
254
- if (packageName) {
255
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName));
256
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, '/'));
257
- list.push(fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, packageName, 'index.html')));
258
- (cals.items || []).forEach((page) => {
259
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id));
260
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id, '/'));
261
- list.push(fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, packageName, page.id, 'index.html')));
262
- });
221
+ await new Promise((resolve, reject) => {
222
+ // 开始编译前清理一下 lowcode 内容
223
+ (0, compile_1.startCompile)({
224
+ appBuildDir: h5BuildDir,
225
+ configPath: webpackConfigPath,
226
+ appKey,
227
+ webpackMode: mode,
228
+ }, function (err, data) {
229
+ if (err) {
230
+ reject(err);
263
231
  }
264
- return list;
265
- }, []),
266
- ]);
232
+ else {
233
+ resolve(data);
234
+ }
235
+ });
236
+ });
237
+ const MAINIFAST_FILENAME = 'weda-manifest.json';
238
+ const preHeatUrls = fs_extra_1.default
239
+ .readdirSync(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR))
240
+ .filter((file) => junk.not(file) && file !== MAINIFAST_FILENAME)
241
+ .map((file) => {
242
+ if (/LICENSE\.txt$/.test(file) || /\.map$/.test(file)) {
243
+ return '';
244
+ }
245
+ try {
246
+ const url = new url_1.URL(publicPath);
247
+ return `${url.origin}${path_1.default.posix.join(url.pathname, file)}`;
248
+ }
249
+ catch (e) {
250
+ return path_1.default.posix.join(publicPath || '', file);
251
+ }
252
+ })
253
+ .filter((item) => !!item);
254
+ // 普通 web 模式,且非hash模式,根据页面生成多份入口
255
+ if (!((_h = cals.extra) === null || _h === void 0 ? void 0 : _h.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
256
+ preHeatUrls.push(path_1.default.posix.join(basename || ''));
257
+ await Promise.all([
258
+ ...(cals.items || []).map((page) => {
259
+ preHeatUrls.push(path_1.default.posix.join(basename || '', page.id));
260
+ preHeatUrls.push(path_1.default.posix.join(basename || '', page.id, '/'));
261
+ return fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, page.id, 'index.html'));
262
+ }),
263
+ ...(subAppCalsList || []).reduce((list, cals) => {
264
+ const { rootPath } = cals.extra || {};
265
+ const packageName = (0, util_1.normalizePackageName)(rootPath);
266
+ if (packageName) {
267
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName));
268
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, '/'));
269
+ list.push(fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, packageName, 'index.html')));
270
+ (cals.items || []).forEach((page) => {
271
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id));
272
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id, '/'));
273
+ list.push(fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, packageName, page.id, 'index.html')));
274
+ });
275
+ }
276
+ return list;
277
+ }, []),
278
+ ]);
279
+ }
280
+ await fs_extra_1.default.writeFile(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, MAINIFAST_FILENAME), JSON.stringify({ preHeatUrls }, undefined, 2));
267
281
  }
268
- await fs_extra_1.default.writeFile(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'weda-manifest.json'), JSON.stringify({ preHeatUrls }, undefined, 2));
269
282
  return h5BuildDir;
270
283
  }
271
284
  catch (e) {
@@ -60,10 +60,6 @@ async function generatePackageJSON(dependencies = {}, appBuildDir, appKey, mode,
60
60
  vueVersion: vueVersion === 3 ? '^3' : '^2',
61
61
  }));
62
62
  const packageInfo = await fs_extra_1.default.readJSON(dstTempPath);
63
- // weapps-sdk 要与 builder template 版本一致
64
- // govcloud 包废弃
65
- // dependencies['@govcloud/weapps-sdk'] =
66
- // packageInfo.dependencies['@govcloud/weapps-sdk'];
67
63
  Object.keys(dependencies).forEach((key) => {
68
64
  const version = dependencies[key];
69
65
  if (packageInfo.dependencies[key] !== version) {
@@ -39,14 +39,6 @@ async function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList,
39
39
  cdnEndpoints,
40
40
  publicPath,
41
41
  });
42
- if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
43
- if (mode !== common_1.WebpackModeType.PRODUCTION) {
44
- await (0, webpack_1.generateWebpackWebDevServerFile)({
45
- appBuildDir,
46
- buildTypeList,
47
- });
48
- }
49
- }
50
42
  console.timeEnd('runWebpackCore');
51
43
  return webWebpackConfigPath;
52
44
  }
@@ -82,6 +82,10 @@ export interface IAppCommonBuildContext extends ICommonBuildContext {
82
82
  * 自定义状态页Id
83
83
  */
84
84
  statusPageId?: string;
85
+ /**
86
+ * use official lib npm
87
+ */
88
+ enableOfficialLibNPM?: boolean;
85
89
  }
86
90
  export interface IMpCommonBuildContext extends ICommonBuildContext {
87
91
  /**
@@ -50,7 +50,6 @@ export declare function downloadAndWriteTabBarIcon(iconPath: any, pagePath: any,
50
50
  export declare function getMainAppDataByList(allAppDataList: IWebRuntimeAppData[]): IWebRuntimeAppData | undefined;
51
51
  export declare function getHomePageInstance(pageInstanceList: any): any;
52
52
  export declare function getPageName(name: string): string;
53
- export declare function getWebpackWebBuildParams(appId: string, appBuildDir: string, publicPath?: string, mode?: WebpackModeType, buildTypeList?: BuildType[], extraDefine?: {}, assets?: string[], vueVersion?: number): any;
54
53
  export declare function downloadAndInstallDependencies(dependencies: IMaterialItem[] | undefined, materialsDir: string, installOptions?: IInstallOpts): Promise<void>;
55
54
  export declare function downloadDependencies(targetDir: string, srcZipUrl: string): Promise<void>;
56
55
  /**
@@ -77,9 +76,5 @@ interface IFixNodeModulesMap {
77
76
  '@cloudbase/js-sdk'?: boolean;
78
77
  }
79
78
  export declare function getMaterialNodeModulesPathList(dependencies: IMaterialItem[] | undefined, materialsDir: string, base?: string): string[];
80
- export declare function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }: {
81
- appBuildDir: any;
82
- buildTypeList: any;
83
- }): Promise<void>;
84
79
  export declare function downloadAssets(targetDir: string, assetUrl: string): Promise<unknown>;
85
80
  export {};
@@ -3,10 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getWebpackWebBuildParams = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
6
+ exports.downloadAssets = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const lodash_1 = require("lodash");
10
9
  const util_1 = require("../util");
11
10
  const axios_1 = __importDefault(require("axios"));
12
11
  const compressing_1 = __importDefault(require("compressing"));
@@ -41,13 +40,22 @@ async function fixAppJson(appBuildDir) {
41
40
  exports.fixAppJson = fixAppJson;
42
41
  async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets = [], vueVersion = 0, }) {
43
42
  let mainAppData = getMainAppDataByList(allAppDataList);
44
- let extraDefine = {
45
- 'process.env.historyType': `"${mainAppData.historyType || types_1.HISTORY_TYPE.BROWSER}"`,
46
- };
47
- const params = getWebpackWebBuildParams(appId, appBuildDir, publicPath, mode, buildTypeList, extraDefine, assets, vueVersion);
48
43
  const webpackConfigPath = path_1.default.resolve(appBuildDir, './webpack/webpack.web.prod.js');
49
- const paramsString = JSON.stringify(params, null, 2);
50
- const webpackConfigContent = `const params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
44
+ const paramsString = JSON.stringify({
45
+ output: {
46
+ path: exports.OUTPUT_DIR,
47
+ publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
48
+ },
49
+ definePlugin: {
50
+ 'process.env.historyType': `"${mainAppData.historyType || types_1.HISTORY_TYPE.BROWSER}"`,
51
+ },
52
+ devtool: ['app-nvzcvt10', 'app-msa2ihs9', 'app-PMoFiTuX'].includes(appId)
53
+ ? 'source-map'
54
+ : mode !== common_1.WebpackModeType.PRODUCTION
55
+ ? 'eval'
56
+ : false,
57
+ }, null, 2);
58
+ const webpackConfigContent = `params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
51
59
  await (0, generateFiles_1.writeFile)(webpackConfigPath, webpackConfigContent);
52
60
  return webpackConfigPath;
53
61
  }
@@ -119,46 +127,6 @@ function getPageName(name) {
119
127
  return `${name}`;
120
128
  }
121
129
  exports.getPageName = getPageName;
122
- function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = common_1.WebpackModeType.NONE, buildTypeList = [common_1.BuildType.WEB], extraDefine = {}, assets = [], vueVersion = 0) {
123
- return {
124
- context: appBuildDir,
125
- mode: mode !== common_1.WebpackModeType.PRODUCTION ? 'development' : mode,
126
- watch: false,
127
- entry: path_1.default.resolve(appBuildDir, 'src/index.jsx'),
128
- output: {
129
- path: path_1.default.resolve(appBuildDir, exports.OUTPUT_DIR),
130
- filename: '[name].[hash].bundle.js',
131
- chunkFilename: '[name].[contenthash].chunk.js',
132
- publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
133
- pathinfo: false,
134
- // clean: mode === WebpackModeType.PRODUCTION,
135
- },
136
- htmlTemplatePath: path_1.default.resolve(appBuildDir, './index.html'),
137
- externals: {
138
- react: 'window.React',
139
- 'react-dom': 'window.ReactDOM',
140
- mobx: 'window.mobx',
141
- '@cloudbase/js-sdk': 'window.cloudbase',
142
- '@cloudbase/weda-cloud-sdk/dist/h5': 'window.CloudSDK',
143
- '@cloudbase/weda-cloud-sdk': 'window.CloudSDK',
144
- '@cloudbase/weda-client': 'window.WedaClientSDK',
145
- '@zxing/library': 'window.ZXing',
146
- '@cloudbase/lowcode-render': 'window["weda-render"]',
147
- },
148
- resolveModules: [path_1.default.resolve(appBuildDir), 'node_modules'],
149
- definePlugin: {
150
- 'process.env.buildType': `"${buildTypeList[0]}"`,
151
- ...extraDefine,
152
- },
153
- devtool: ['app-nvzcvt10', 'app-msa2ihs9', 'app-PMoFiTuX'].includes(appId)
154
- ? 'source-map'
155
- : mode !== common_1.WebpackModeType.PRODUCTION
156
- ? 'eval'
157
- : false,
158
- vueVersion,
159
- };
160
- }
161
- exports.getWebpackWebBuildParams = getWebpackWebBuildParams;
162
130
  async function downloadAndInstallDependencies(dependencies = [], materialsDir, installOptions = {}) {
163
131
  const localPkg = (0, util_1.getCurrentPackageJson)();
164
132
  await Promise.all(dependencies.map(async (item) => {
@@ -369,22 +337,6 @@ function getMaterialNodeModulesPathList(dependencies = [], materialsDir, base) {
369
337
  });
370
338
  }
371
339
  exports.getMaterialNodeModulesPathList = getMaterialNodeModulesPathList;
372
- // 生成devServer 核心依赖
373
- async function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }) {
374
- const dest = path_1.default.resolve(appBuildDir, `./webpack/devServer.js`);
375
- const template = await fs_extra_1.default.readFile(path_1.default.resolve(config_1.appTemplateDir, './webpack/devServer.js'), {
376
- encoding: 'utf8',
377
- });
378
- const jsContent = (0, lodash_1.template)(template, {
379
- interpolate: /<%=([\s\S]+?)%>/g,
380
- })({
381
- isApp: buildTypeList.includes(common_1.BuildType.APP),
382
- isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
383
- });
384
- await fs_extra_1.default.ensureFile(dest);
385
- await fs_extra_1.default.writeFile(dest, jsContent);
386
- }
387
- exports.generateWebpackWebDevServerFile = generateWebpackWebDevServerFile;
388
340
  // 下载js 文件
389
341
  async function downloadAssets(targetDir, assetUrl) {
390
342
  const isExist = fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'package.json'));
@@ -10,7 +10,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style");
11
11
  const generateFiles_1 = require("./generateFiles");
12
12
  const cals_1 = require("@cloudbase/cals");
13
- const compare_versions_1 = __importDefault(require("compare-versions"));
14
13
  const config_1 = require("../config");
15
14
  const os_1 = __importDefault(require("os"));
16
15
  var common_1 = require("@cloudbase/lowcode-generator/lib/generator/util/common");
@@ -184,7 +183,6 @@ exports.isOfficialComponentLib = isOfficialComponentLib;
184
183
  */
185
184
  function canUseVite(mode, devTool) {
186
185
  return false;
187
- return devTool === 'vite' && mode !== 'production' && (0, compare_versions_1.default)(process.version, '12.0.0') >= 0;
188
186
  }
189
187
  exports.canUseVite = canUseVite;
190
188
  function deepDealComponentSchemaJson(schema, dealFn) {