@omnia/tooling-vue 8.0.20-vnext → 8.0.22-vnext
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.
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wctypings.d.ts +67 -5
- package/internal-do-not-import-from-here/config/omnia.vendor.manifest.json +1 -1
- package/internal-do-not-import-from-here/shared.d.ts +1 -18
- package/internal-do-not-import-from-here/shared.js +4 -41
- package/internal-do-not-import-from-here/swc/extract-doc-plugin/package.json +14 -0
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.d.ts +1 -0
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +9 -0
- package/internal-do-not-import-from-here/tasks/bundle.js +330 -108
- package/internal-do-not-import-from-here/tasks/vendor.js +160 -17
- package/internal-do-not-import-from-here/vite/hmr/transformers/internal/dynamicBundle.js +7 -1
- package/internal-do-not-import-from-here/vite/index.js +4 -0
- package/internal-do-not-import-from-here/vite/middlewares/HmrMiddleware.js +3 -1
- package/internal-do-not-import-from-here/vite/middlewares/StaticFileMiddleware.js +22 -2
- package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +1 -1
- package/internal-do-not-import-from-here/webpack-loaders/ts-loader.d.ts +1 -1
- package/internal-do-not-import-from-here/webpack-loaders/ts-loader.js +1 -8
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +1 -1
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +23 -28
- package/package.json +7 -6
- package/internal-do-not-import-from-here/1cacb55c-202b-4cd7-819d-11bad92fa9cb.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/1cacb55c-202b-4cd7-819d-11bad92fa9cb.wctypings.d.ts +0 -11
- package/internal-do-not-import-from-here/1cacb55c-202b-4cd7-819d-11bad92fa9cb.wctypings.js +0 -2
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/cc000000-0000-cccc-0000-0000000000cc.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/webpack-loaders/jsx-loader.d.ts +0 -8
- package/internal-do-not-import-from-here/webpack-loaders/jsx-loader.js +0 -61
- package/internal-do-not-import-from-here/webpack-loaders/vue-tsx-hot-loader.d.ts +0 -1
- package/internal-do-not-import-from-here/webpack-loaders/vue-tsx-hot-loader.js +0 -44
|
@@ -9,15 +9,18 @@ const globby = tslib_1.__importStar(require("globby"));
|
|
|
9
9
|
const terser_1 = require("terser");
|
|
10
10
|
const ts_loader_1 = tslib_1.__importDefault(require("../webpack-loaders/ts-loader"));
|
|
11
11
|
const tsx_loader_1 = tslib_1.__importDefault(require("../webpack-loaders/tsx-loader"));
|
|
12
|
+
const index_1 = require("../../composers/models/index");
|
|
12
13
|
const fx_models_1 = require("@omnia/fx-models");
|
|
13
14
|
const $ = tslib_1.__importStar(require("../variables"));
|
|
14
15
|
const shared_1 = require("../shared");
|
|
15
16
|
const tooling_1 = require("@omnia/tooling");
|
|
17
|
+
const core_1 = require("@swc/core");
|
|
16
18
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
17
19
|
const ConcatSource = require('webpack-core/lib/ConcatSource');
|
|
18
20
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
19
21
|
const isEqual = require('lodash/isEqual');
|
|
20
|
-
|
|
22
|
+
const vendorProdId = "aaf89b2d-5ea8-4b79-946a-8c1e89f713a3";
|
|
23
|
+
let outDirManifestMetadata = "client/tooling/vue/output_manifests", _manifestsEntry = {}, _registeredReferenceManifests = [], serviceId = null, _modulesStats = {}, _manifestsStats = {}, keepTrackbuildOptions = {}, _transformResourcepaths = [], _wcDefinitions = {};
|
|
21
24
|
if ($.isExtensionEnv) {
|
|
22
25
|
outDirManifestMetadata = "node_modules/@omnia/tooling-vue/internal-do-not-import-from-here/output_manifests";
|
|
23
26
|
}
|
|
@@ -35,7 +38,7 @@ $.tooling.core.registerBuildTask({
|
|
|
35
38
|
order: 2,
|
|
36
39
|
task: function () {
|
|
37
40
|
return new Promise(function (resolve, reject) {
|
|
38
|
-
|
|
41
|
+
buildEntries()
|
|
39
42
|
.then((result) => {
|
|
40
43
|
let startTime = new Date().getTime();
|
|
41
44
|
tooling_1.utils.log("Typescript checking...");
|
|
@@ -64,7 +67,7 @@ $.tooling.core.registerServeTask({
|
|
|
64
67
|
fsExtra.removeSync("node_modules/tiptap-commands/node_modules");
|
|
65
68
|
fsExtra.removeSync("node_modules/tiptap-utils/node_modules");
|
|
66
69
|
}
|
|
67
|
-
|
|
70
|
+
buildEntries(true)
|
|
68
71
|
.then(resolve, reject);
|
|
69
72
|
});
|
|
70
73
|
}
|
|
@@ -192,18 +195,21 @@ function clean() {
|
|
|
192
195
|
resolve();
|
|
193
196
|
});
|
|
194
197
|
}
|
|
195
|
-
function
|
|
196
|
-
return new Promise(function (resolve, reject) {
|
|
198
|
+
function buildEntries(serve = false) {
|
|
199
|
+
return new Promise(async function (resolve, reject) {
|
|
197
200
|
try {
|
|
198
201
|
var startTime = new Date().getTime();
|
|
199
202
|
var componentRegistry = $.composers.ComponentRegistry;
|
|
200
203
|
let componentRegistrations = componentRegistry.getRegistrations();
|
|
204
|
+
const serviceInfo = $.composers.ServiceManifestRegistry.getServiceInfo();
|
|
205
|
+
if (serviceInfo.serviceType === index_1.ServiceTypes.WebApp) {
|
|
206
|
+
await generateComponentTypingsAndDoc(componentRegistrations);
|
|
207
|
+
}
|
|
201
208
|
$.tooling.logTime("Found [" + componentRegistrations.length + "] component registrations", startTime);
|
|
202
209
|
var resourceRegistry = $.composers.ResourceRegistry;
|
|
203
210
|
let resourceBundlesWithBuildOptions = resourceRegistry.getRegisteredResourceBundles(shared_1.convertManifestPathToEntryPath);
|
|
204
211
|
$.tooling.logTime("Found [" + (resourceBundlesWithBuildOptions ? Object.keys(resourceBundlesWithBuildOptions).length : 0) + "] resource bundles", startTime);
|
|
205
212
|
let resourceEntries = {};
|
|
206
|
-
let wcDefinitionsPath, wcTypingsPath;
|
|
207
213
|
for (let key in resourceBundlesWithBuildOptions) {
|
|
208
214
|
let resource = resourceBundlesWithBuildOptions[key];
|
|
209
215
|
let manifest = $.composers.LoadableManifestRegistry.getRegisteredManifest(key);
|
|
@@ -215,47 +221,6 @@ function buildWebpackEntries(serve = false) {
|
|
|
215
221
|
console.log("debug " + key + " has build options for paths " + resource.paths + " buildoptions: " + JSON.stringify(resource.buildOptions));
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
|
-
//We only support typings for registered web components
|
|
219
|
-
wcDomProps = extractTypingsForComponents(componentRegistrations);
|
|
220
|
-
if (Object.keys(wcDomProps).length > 0) {
|
|
221
|
-
let wcDomPropsDesc = `Extracted web component typings for ${Object.keys(wcDomProps).length} component(s)`;
|
|
222
|
-
$.tooling.logTime(wcDomPropsDesc, startTime);
|
|
223
|
-
}
|
|
224
|
-
if ($.isExtensionEnv) {
|
|
225
|
-
wcDefinitionsPath = $.path.resolve(__dirname, "../wcdefinitions.json");
|
|
226
|
-
wcTypingsPath = $.path.resolve(__dirname, "../wctypings.ts");
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
wcDefinitionsPath = $.path.resolve(__dirname, `../${getServiceId().toLowerCase()}.wcdefinitions.json`);
|
|
230
|
-
wcTypingsPath = $.path.resolve(__dirname, `../${getServiceId().toLowerCase()}.wctypings.ts`);
|
|
231
|
-
}
|
|
232
|
-
fsExtra.writeJsonSync(wcDefinitionsPath, wcDomProps);
|
|
233
|
-
let wcTypings = `
|
|
234
|
-
//{{importWC}}
|
|
235
|
-
declare global {
|
|
236
|
-
namespace JSX {
|
|
237
|
-
interface Element { }
|
|
238
|
-
interface ElementClass { }
|
|
239
|
-
|
|
240
|
-
interface IntrinsicElements {
|
|
241
|
-
//{{elementName}}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
`;
|
|
246
|
-
if ($.isExtensionEnv) {
|
|
247
|
-
wcTypings = `import { VueComponentBaseProps } from "@omnia/fx/ux";
|
|
248
|
-
${wcTypings}`;
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
wcTypings = `import { VueComponentBaseProps } from "../../../client/fx/ux/index";
|
|
252
|
-
${wcTypings}`;
|
|
253
|
-
}
|
|
254
|
-
componentRegistrations.forEach(wc => {
|
|
255
|
-
wcTypings = generateWebComponentTypings(wc, wcTypings);
|
|
256
|
-
});
|
|
257
|
-
fsExtra.outputFileSync(wcTypingsPath, wcTypings);
|
|
258
|
-
wcDomProps = $.merge(wcDomProps, getRegisteredWebComponentDefinitions());
|
|
259
224
|
let componentEntries = createVueEntryFormRegistrations(componentRegistrations);
|
|
260
225
|
var entries = $.merge(componentEntries, resourceEntries);
|
|
261
226
|
if (checkDuplicateWebpackEntryPoints(entries)) {
|
|
@@ -291,6 +256,231 @@ declare global {
|
|
|
291
256
|
}
|
|
292
257
|
});
|
|
293
258
|
}
|
|
259
|
+
async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
260
|
+
tooling_1.utils.log("Generate components typings and documentation running...");
|
|
261
|
+
var startTime = new Date().getTime();
|
|
262
|
+
let DefineVueType;
|
|
263
|
+
(function (DefineVueType) {
|
|
264
|
+
DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
|
|
265
|
+
DefineVueType[DefineVueType["Model"] = 1] = "Model";
|
|
266
|
+
DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
|
|
267
|
+
DefineVueType[DefineVueType["Emit"] = 4] = "Emit";
|
|
268
|
+
})(DefineVueType || (DefineVueType = {}));
|
|
269
|
+
const docResult = {};
|
|
270
|
+
function getPropertyFunctionTypeAsString(type) {
|
|
271
|
+
let params = "";
|
|
272
|
+
if (type.params?.length > 0) {
|
|
273
|
+
type.params.forEach(p => {
|
|
274
|
+
params += `${p.value}:${getPropertyType(p.typeAnnotation)}, `;
|
|
275
|
+
});
|
|
276
|
+
params = params.replace(/,\s*$/, "");
|
|
277
|
+
}
|
|
278
|
+
return `(${params}) => ${getPropertyType(type.typeAnnotation)}`;
|
|
279
|
+
}
|
|
280
|
+
function getPropertyType(tsType) {
|
|
281
|
+
let result = "";
|
|
282
|
+
if (tsType.type === "TsTypeAnnotation") {
|
|
283
|
+
return getPropertyType(tsType.typeAnnotation);
|
|
284
|
+
}
|
|
285
|
+
switch (tsType.type) {
|
|
286
|
+
case "TsLiteralType":
|
|
287
|
+
result = tsType.literal.value;
|
|
288
|
+
break;
|
|
289
|
+
case "TsKeywordType":
|
|
290
|
+
result = tsType.kind;
|
|
291
|
+
break;
|
|
292
|
+
case "TsTypeReference":
|
|
293
|
+
result = tsType.typeName.value;
|
|
294
|
+
break;
|
|
295
|
+
case "TsFunctionType":
|
|
296
|
+
result = getPropertyFunctionTypeAsString(tsType);
|
|
297
|
+
break;
|
|
298
|
+
default:
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
function getNameProperty(ce, result) {
|
|
304
|
+
const identifier = ce.callee?.property?.value;
|
|
305
|
+
if (identifier) {
|
|
306
|
+
switch (identifier) {
|
|
307
|
+
case "name":
|
|
308
|
+
result.name = ce.arguments[0].expression.value;
|
|
309
|
+
getNameProperty(ce.callee.object, result);
|
|
310
|
+
break;
|
|
311
|
+
case "vModel":
|
|
312
|
+
result.type = DefineVueType.Model;
|
|
313
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
314
|
+
result.name = result.name ? `v-model:${result.name}` : result.name;
|
|
315
|
+
break;
|
|
316
|
+
case "slots":
|
|
317
|
+
result.type = DefineVueType.Slot;
|
|
318
|
+
result.propertyTypeAsObject = {};
|
|
319
|
+
ce.typeArguments.params[0].members
|
|
320
|
+
.forEach(m => {
|
|
321
|
+
result.propertyTypeAsObject[m.key.value] = getPropertyType(m.typeAnnotation);
|
|
322
|
+
});
|
|
323
|
+
break;
|
|
324
|
+
case "prop":
|
|
325
|
+
// console.log(
|
|
326
|
+
// ce.typeArguments.params[0],
|
|
327
|
+
// ce.typeArguments.params[0].typeAnnotation?.typeAnnotation,
|
|
328
|
+
// )
|
|
329
|
+
result.type = DefineVueType.Prop;
|
|
330
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
331
|
+
break;
|
|
332
|
+
case "emit":
|
|
333
|
+
result.type = DefineVueType.Emit;
|
|
334
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
335
|
+
break;
|
|
336
|
+
default:
|
|
337
|
+
getNameProperty(ce.callee.object, result);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async function buildDoc(wc) {
|
|
342
|
+
try {
|
|
343
|
+
const wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
|
|
344
|
+
const wcParseResult = await (0, core_1.parseFile)(wcPath, {
|
|
345
|
+
syntax: 'typescript',
|
|
346
|
+
target: 'es2020',
|
|
347
|
+
tsx: true,
|
|
348
|
+
decorators: true,
|
|
349
|
+
dynamicImport: true
|
|
350
|
+
});
|
|
351
|
+
wcParseResult.body.forEach(b => {
|
|
352
|
+
if (b.type === 'ExportDefaultExpression'
|
|
353
|
+
&& b.expression.callee?.value === "defineVueWebComponent") {
|
|
354
|
+
b.expression.arguments[0].expression
|
|
355
|
+
.properties?.filter(p => p.key.value === "props"
|
|
356
|
+
|| p.key.value === "emits")
|
|
357
|
+
?.forEach(propsIdentifier => {
|
|
358
|
+
if (propsIdentifier) {
|
|
359
|
+
propsIdentifier.value
|
|
360
|
+
.properties?.forEach(p => {
|
|
361
|
+
const em = p.arguments;
|
|
362
|
+
if (em?.callee?.property?.value === "doc$") {
|
|
363
|
+
const PropertyResult = {
|
|
364
|
+
type: null,
|
|
365
|
+
propertyTypeAsString: "",
|
|
366
|
+
name: ""
|
|
367
|
+
};
|
|
368
|
+
getNameProperty(em, PropertyResult);
|
|
369
|
+
if (!docResult[wc.componentOptions.elementName]) {
|
|
370
|
+
docResult[wc.componentOptions.elementName] = {
|
|
371
|
+
emits: {},
|
|
372
|
+
models: {},
|
|
373
|
+
props: {},
|
|
374
|
+
slots: {}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
switch (PropertyResult.type) {
|
|
378
|
+
case DefineVueType.Prop:
|
|
379
|
+
docResult[wc.componentOptions.elementName].props[PropertyResult.name] = {
|
|
380
|
+
type: PropertyResult.propertyTypeAsString,
|
|
381
|
+
description: em.arguments[0].expression.value
|
|
382
|
+
};
|
|
383
|
+
break;
|
|
384
|
+
case DefineVueType.Model:
|
|
385
|
+
docResult[wc.componentOptions.elementName].models[PropertyResult.name] = {
|
|
386
|
+
type: PropertyResult.propertyTypeAsString,
|
|
387
|
+
description: em.arguments[0].expression.value
|
|
388
|
+
};
|
|
389
|
+
break;
|
|
390
|
+
case DefineVueType.Emit:
|
|
391
|
+
docResult[wc.componentOptions.elementName].emits[PropertyResult.name] = {
|
|
392
|
+
type: PropertyResult.propertyTypeAsString,
|
|
393
|
+
description: em.arguments[0].expression.value
|
|
394
|
+
};
|
|
395
|
+
break;
|
|
396
|
+
case DefineVueType.Slot:
|
|
397
|
+
em.arguments[0].expression
|
|
398
|
+
.properties
|
|
399
|
+
.forEach(p => {
|
|
400
|
+
const slotName = p.key.value;
|
|
401
|
+
docResult[wc.componentOptions.elementName].slots[slotName] = {
|
|
402
|
+
type: PropertyResult.propertyTypeAsObject[slotName],
|
|
403
|
+
description: p.value.value
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
break;
|
|
407
|
+
default:
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
catch (ex) {
|
|
418
|
+
tooling_1.utils.log(`Have a exception when extract doc$ for web component manifest -> ${wc.manifestPath}`, tooling_1.utils.LogTypes.Error);
|
|
419
|
+
console.error(ex);
|
|
420
|
+
throw new Error("Exit, have an exception.");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
let wcTypingsPath = "", docPath = $.path.resolve(__dirname, "ComponentDocRegistrations.ts");
|
|
424
|
+
;
|
|
425
|
+
if ($.isExtensionEnv) {
|
|
426
|
+
wcTypingsPath = $.path.resolve(__dirname, "../wctypings.ts");
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
wcTypingsPath = $.path.resolve(__dirname, `../${getServiceId().toLowerCase()}.wctypings.ts`);
|
|
430
|
+
}
|
|
431
|
+
let wcTypings = `
|
|
432
|
+
//{{importWC}}
|
|
433
|
+
declare global {
|
|
434
|
+
namespace JSX {
|
|
435
|
+
interface Element { }
|
|
436
|
+
interface ElementClass { }
|
|
437
|
+
|
|
438
|
+
interface IntrinsicElements {
|
|
439
|
+
//{{elementName}}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
`;
|
|
444
|
+
if ($.isExtensionEnv) {
|
|
445
|
+
wcTypings = `import { VueComponentBaseProps } from "@omnia/fx/ux";
|
|
446
|
+
${wcTypings}`;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
wcTypings = `import { VueComponentBaseProps } from "../../../client/fx/ux/index";
|
|
450
|
+
${wcTypings}`;
|
|
451
|
+
}
|
|
452
|
+
await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
|
|
453
|
+
wcTypings = generateWebComponentTypings(wc, wcTypings);
|
|
454
|
+
await buildDoc(wc);
|
|
455
|
+
});
|
|
456
|
+
if (Object.keys(docResult).length > 0) {
|
|
457
|
+
fsExtra.outputFileSync(docPath, `
|
|
458
|
+
import { extendApi } from "@omnia/fx";
|
|
459
|
+
import { ComponentDoc } from "@omnia/fx-models";
|
|
460
|
+
|
|
461
|
+
extendApi(api => api.fx.docs.registrations, api => {
|
|
462
|
+
|
|
463
|
+
const registrations: { [elementName: string]: ComponentDoc } = ${JSON.stringify(docResult)}
|
|
464
|
+
|
|
465
|
+
Object.keys(registrations).forEach(elementName => {
|
|
466
|
+
api.register(elementName, registrations[elementName]);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
`);
|
|
470
|
+
// create dynamic doc manifest
|
|
471
|
+
$.composers.ManifestRegistry.setCurrentManifestPath(`${path_1.default.relative(tooling_1.utils.root(""), path_1.default.resolve(__dirname))}/`);
|
|
472
|
+
$.composers
|
|
473
|
+
.Composer
|
|
474
|
+
.registerManifest(getBuildOption().dynamicDocManifestId || new fx_models_1.Guid(`${tooling_1.utils.generateGuid()}`), "omnia.fx.docs.components.registraions")
|
|
475
|
+
.registerResources({
|
|
476
|
+
resourcePaths: ["./ComponentDocRegistrations.ts"]
|
|
477
|
+
})
|
|
478
|
+
.extendApi(api => api.fx.docs.registrations);
|
|
479
|
+
$.composers.ManifestRegistry.setCurrentManifestPath();
|
|
480
|
+
}
|
|
481
|
+
fsExtra.outputFileSync(wcTypingsPath, wcTypings);
|
|
482
|
+
tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
|
|
483
|
+
}
|
|
294
484
|
function buildManifestMetadatas(entries) {
|
|
295
485
|
return new Promise(function (resolve, reject) {
|
|
296
486
|
try {
|
|
@@ -307,7 +497,15 @@ function buildManifestMetadatas(entries) {
|
|
|
307
497
|
return;
|
|
308
498
|
}
|
|
309
499
|
$.tooling.log('Build manifests metadata running...', $.tooling.LogTypes.HeadLine);
|
|
310
|
-
let
|
|
500
|
+
let webpackConfigs = [];
|
|
501
|
+
Object.keys(entries).forEach((id) => {
|
|
502
|
+
var entry = {};
|
|
503
|
+
entry[id] = entries[id];
|
|
504
|
+
var vueWebpackConfig = createWebpackConfigForManifestMetadata(entry, outputDir);
|
|
505
|
+
webpackConfigs.push(vueWebpackConfig);
|
|
506
|
+
});
|
|
507
|
+
let compiler = $.webpack(webpackConfigs);
|
|
508
|
+
compiler.run((err, stats) => {
|
|
311
509
|
Object.keys(entries).forEach((entry) => {
|
|
312
510
|
let manifestPath = outputDir + "/" + entry + '.manifest.json';
|
|
313
511
|
if ($.fs.existsSync($.tooling.utils.root(manifestPath))) {
|
|
@@ -321,17 +519,6 @@ function buildManifestMetadatas(entries) {
|
|
|
321
519
|
$.fs.writeFileSync(manifestPath, JSON.stringify(manifestJson));
|
|
322
520
|
}
|
|
323
521
|
});
|
|
324
|
-
};
|
|
325
|
-
let webpackConfigs = [];
|
|
326
|
-
Object.keys(entries).forEach((id) => {
|
|
327
|
-
var entry = {};
|
|
328
|
-
entry[id] = entries[id];
|
|
329
|
-
var vueWebpackConfig = createWebpackConfigForManifestMetadata(entry, outputDir);
|
|
330
|
-
webpackConfigs.push(vueWebpackConfig);
|
|
331
|
-
});
|
|
332
|
-
let compiler = $.webpack(webpackConfigs);
|
|
333
|
-
compiler.run((err, stats) => {
|
|
334
|
-
updateMetadataFiles();
|
|
335
522
|
$.del.sync([outputDir + '/*.js']);
|
|
336
523
|
if (err) {
|
|
337
524
|
$.tooling.logTime(`Build manifests metadata have an exception`, startTime);
|
|
@@ -386,16 +573,33 @@ function beforeBundleManifest(entries) {
|
|
|
386
573
|
isRunBuildMetadata = !isEqual(entries, cachedEntries);
|
|
387
574
|
}
|
|
388
575
|
if (isRunBuildMetadata) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
|
|
576
|
+
// cleanup before generate
|
|
577
|
+
del_1.default.sync(outDirManifestMetadata);
|
|
578
|
+
const entriesToBuild = {};
|
|
579
|
+
const resourceRegistrations = Object.keys($.composers.ResourceRegistry.getResourceRegistrations());
|
|
580
|
+
const wcRegistrations = Object.keys($.composers.ComponentRegistry.getComponentRegistrations());
|
|
581
|
+
Object.keys(entries).forEach(name => {
|
|
582
|
+
if (resourceRegistrations.find(rk => name.indexOf(rk) > -1)) {
|
|
583
|
+
entriesToBuild[name] = entries[name];
|
|
584
|
+
}
|
|
585
|
+
// generate manifest metadata for wc
|
|
586
|
+
else if (wcRegistrations.find(rk => name.indexOf(rk) > -1)) {
|
|
587
|
+
const manifestPath = $.tooling.utils.root(outDirManifestMetadata + "/" + name + '.manifest.json');
|
|
588
|
+
const content = {
|
|
589
|
+
name: `omniaWebpackJsonp['${getServiceId()}']['${$.tooling.utils.getGuidValue(name)}']`,
|
|
590
|
+
content: {
|
|
591
|
+
[entries[name][0]]: {
|
|
592
|
+
id: entries[name][0].toLowerCase(),
|
|
593
|
+
buildMeta: {
|
|
594
|
+
exportsType: "namespace"
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
fsExtra.ensureFileSync(manifestPath);
|
|
600
|
+
fsExtra.writeJsonSync(manifestPath, content);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
399
603
|
buildManifestMetadatas(entriesToBuild).then(() => {
|
|
400
604
|
fsExtra.ensureFileSync(cachedEntriesPath);
|
|
401
605
|
fsExtra.writeJsonSync(cachedEntriesPath, entries);
|
|
@@ -544,15 +748,31 @@ function minifyBundles() {
|
|
|
544
748
|
let promises = [];
|
|
545
749
|
jsPaths.forEach(filePath => {
|
|
546
750
|
promises.push(new Promise(async (resolve, reject) => {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
751
|
+
try {
|
|
752
|
+
$.tooling.log(`Minify Js -> ${filePath}`);
|
|
753
|
+
// only minify for omnia.vendor.prod
|
|
754
|
+
if (filePath.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1) {
|
|
755
|
+
let content = await fsExtra.readFile(filePath, 'utf8');
|
|
756
|
+
let outFileName = `${filePath.substring(0, filePath.length - 3)}.min.js`;
|
|
757
|
+
if (filePath.indexOf(vendorProdId) > -1) {
|
|
758
|
+
content = content.replace(new RegExp(vendorProdId, "g"), fx_models_1.OmniaResourceManifests.Vendor.toString());
|
|
759
|
+
outFileName = `${$.tooling.utils.root($.tooling.composer.OmniaOutput.OutputBundlePath)}/omnia.vendor_6270b632-1f44-4146-bace-137131c0471b.min.js`;
|
|
760
|
+
}
|
|
761
|
+
let minified = await (0, terser_1.minify)(content, {
|
|
762
|
+
sourceMap: false,
|
|
763
|
+
ecma: 2020 // will remove es5 when not support IE 11
|
|
764
|
+
});
|
|
765
|
+
await fsExtra.writeFile(outFileName, minified.code, 'utf8');
|
|
766
|
+
$.tooling.log(`Minify Js Done -> ${filePath}`);
|
|
767
|
+
}
|
|
768
|
+
resolve();
|
|
769
|
+
}
|
|
770
|
+
catch (ex) {
|
|
771
|
+
tooling_1.utils.log(`Have a exception when minify the file -> ${filePath}`, tooling_1.utils.LogTypes.Error);
|
|
772
|
+
console.error(ex);
|
|
773
|
+
resolve();
|
|
774
|
+
throw new Error("Exit, have an exception.");
|
|
775
|
+
}
|
|
556
776
|
}));
|
|
557
777
|
});
|
|
558
778
|
Promise.all(promises).then(() => {
|
|
@@ -606,7 +826,12 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
606
826
|
}
|
|
607
827
|
}));
|
|
608
828
|
}
|
|
609
|
-
let modifyContent = [
|
|
829
|
+
let modifyContent = [
|
|
830
|
+
{
|
|
831
|
+
pattern: /\.doc\$(.*\))/g,
|
|
832
|
+
replacement: ''
|
|
833
|
+
}
|
|
834
|
+
];
|
|
610
835
|
if (buildOption.bundleOptions && buildOption.bundleOptions.removeSourceMap) {
|
|
611
836
|
modifyContent.push({
|
|
612
837
|
pattern: /# sourceMappingURL=(.*\.map)/g,
|
|
@@ -628,15 +853,18 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
628
853
|
transform(data, opts) {
|
|
629
854
|
// build manifets stats to detect duplicate bundle
|
|
630
855
|
let entryName = Object.keys(data.assetsByChunkName)[0];
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
856
|
+
// ignore omnia.vendor.prod
|
|
857
|
+
if (entryName.indexOf(vendorProdId) === -1) {
|
|
858
|
+
_manifestsStats[entryName] = [];
|
|
859
|
+
data.modules.filter(m => typeof m.id === 'string'
|
|
860
|
+
&& m.id.trim().length > 0
|
|
861
|
+
&& m.id.indexOf('dll-reference') === -1
|
|
862
|
+
&& m.identifier.indexOf('from dll-reference') === -1).forEach(module => {
|
|
863
|
+
_manifestsStats[entryName].push(module.id);
|
|
864
|
+
_modulesStats[module.id] = _modulesStats[module.id] || new Set();
|
|
865
|
+
_modulesStats[module.id].add(entryName);
|
|
866
|
+
});
|
|
867
|
+
}
|
|
640
868
|
}
|
|
641
869
|
}));
|
|
642
870
|
}
|
|
@@ -672,7 +900,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
672
900
|
alias: Object.assign({}, $.tooling.core.getWebpackResolveAlias(), (getBuildOption()?.moduleOptions?.alias || {}), {
|
|
673
901
|
'axios$': 'axios/dist/axios.js',
|
|
674
902
|
'typestyle$': 'typestyle/lib.es2015/index.js',
|
|
675
|
-
'vue$': 'vue/dist/vue.esm-bundler.js',
|
|
903
|
+
'vue$': 'vue/dist/vue.runtime.esm-bundler.js',
|
|
676
904
|
'@microsoft/signalr$': '@microsoft/signalr/dist/webworker/signalr.js',
|
|
677
905
|
}),
|
|
678
906
|
},
|
|
@@ -696,9 +924,8 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
696
924
|
fullySpecified: false, // disable the behaviour
|
|
697
925
|
},
|
|
698
926
|
},
|
|
699
|
-
...(0, ts_loader_1.default)(
|
|
700
|
-
...(0, tsx_loader_1.default)(
|
|
701
|
-
// ...jsxLoader(getBuildOption().enableTreeShaking, wcDomProps, hotModuleReload),
|
|
927
|
+
...(0, ts_loader_1.default)(),
|
|
928
|
+
...(0, tsx_loader_1.default)(),
|
|
702
929
|
{
|
|
703
930
|
// remove vuetify locale
|
|
704
931
|
test: (path) => {
|
|
@@ -825,7 +1052,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
825
1052
|
exports.createVueWebpackConfig = createVueWebpackConfig;
|
|
826
1053
|
function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
|
|
827
1054
|
var entensionId = getServiceId();
|
|
828
|
-
return Object.assign({}, (0, shared_1.getBaseWebpackConfigForManifestMetadata)(entry, metadataOutputDir
|
|
1055
|
+
return Object.assign({}, (0, shared_1.getBaseWebpackConfigForManifestMetadata)(entry, metadataOutputDir), {
|
|
829
1056
|
plugins: [
|
|
830
1057
|
...buildReferenceManifestFromConfig(),
|
|
831
1058
|
new $.omniaWebpackPlugins.NamedModulesPlugin(buildModuleName()),
|
|
@@ -1090,7 +1317,8 @@ function buildReferenceManifest(currentEntry, entries) {
|
|
|
1090
1317
|
return dynamicReferenceManifests.concat(buildReferenceManifestFromConfig());
|
|
1091
1318
|
var currentEntryName = Object.keys(currentEntry)[0];
|
|
1092
1319
|
// exclude omnia vendor
|
|
1093
|
-
if (currentEntryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1320
|
+
if (currentEntryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1321
|
+
&& currentEntryName.indexOf(vendorProdId) === -1) {
|
|
1094
1322
|
Object.keys(entries).forEach((entryName) => {
|
|
1095
1323
|
if (entryName !== currentEntryName) {
|
|
1096
1324
|
if ($.fs.existsSync($.tooling.utils.root(outDirManifestMetadata + "/" + entryName + ".manifest.json"))) {
|
|
@@ -1142,7 +1370,8 @@ function buildModuleName() {
|
|
|
1142
1370
|
replace: function (modulePath) {
|
|
1143
1371
|
var buildOptions = getBuildOption();
|
|
1144
1372
|
if (buildOptions && buildOptions.moduleOptions && buildOptions.moduleOptions.enableTransformResourcePath) {
|
|
1145
|
-
if (modulePath.indexOf('./node_modules/') === -1 // ignore from npm package
|
|
1373
|
+
if (modulePath.indexOf('./node_modules/') === -1 // ignore from npm package and in wwwwroot .js file
|
|
1374
|
+
&& (modulePath.indexOf('./wwwroot/') === -1 || path_1.default.extname(modulePath) === ".js")
|
|
1146
1375
|
&& modulePath.indexOf('./omnia/fx/models/ConfigurationComposers') === -1 // ignore comment interface for special case here
|
|
1147
1376
|
&& $.fs.existsSync(modulePath)) {
|
|
1148
1377
|
let stream = $.fs.readFileSync(modulePath, 'utf8');
|
|
@@ -1338,7 +1567,8 @@ function ensureManifestDependencyInRuntime(currentManifestId, manifestBundleFile
|
|
|
1338
1567
|
if (entryName.toLowerCase() !== currentManifestId.toString().toLowerCase()
|
|
1339
1568
|
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.FxWorkers.toString()) === -1
|
|
1340
1569
|
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.FxCore.toString()) === -1 /* ignore omnia.fx.core, omnia.fx.workers and vendor manifest because ith not loaded by our resource loader */
|
|
1341
|
-
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1570
|
+
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1571
|
+
&& entryName.indexOf(vendorProdId) === -1) {
|
|
1342
1572
|
for (let entryPointPath of _manifestsEntry[entryName]) {
|
|
1343
1573
|
if (!hasDependency) {
|
|
1344
1574
|
var transformresourcePath = _transformResourcepaths.find(resource => resource.original === entryPointPath);
|
|
@@ -1392,7 +1622,8 @@ function buildManifestsDependency(entries, manifestId, manifestBundleContent) {
|
|
|
1392
1622
|
if (entryName.toLowerCase() !== manifestId.toLowerCase()
|
|
1393
1623
|
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.FxWorkers.toString()) === -1
|
|
1394
1624
|
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.FxCore.toString()) === -1 /* ignore omnia.fx.core, omnia.fx.workers and vendor manifest because ith not loaded by our resource loader */
|
|
1395
|
-
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1625
|
+
&& entryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
|
|
1626
|
+
&& entryName.indexOf(vendorProdId) === -1) {
|
|
1396
1627
|
for (let entryPointPath of entries[entryName]) {
|
|
1397
1628
|
if (!hasDependency) {
|
|
1398
1629
|
var transformresourcePath = _transformResourcepaths.find(resource => resource.original === entryPointPath);
|
|
@@ -1531,7 +1762,8 @@ function checkDuplicateWebpackEntryPoints(entries) {
|
|
|
1531
1762
|
let foundDuplicated = false;
|
|
1532
1763
|
let entryPathInfos = {};
|
|
1533
1764
|
Object.keys(entries).forEach(key => {
|
|
1534
|
-
|
|
1765
|
+
// skip omnia.vendor.prod
|
|
1766
|
+
if (entries[key] && key.indexOf(vendorProdId) === -1) {
|
|
1535
1767
|
entries[key].forEach(path => {
|
|
1536
1768
|
entryPathInfos[path] = entryPathInfos[path] || [];
|
|
1537
1769
|
entryPathInfos[path].push(key);
|
|
@@ -1546,13 +1778,6 @@ function checkDuplicateWebpackEntryPoints(entries) {
|
|
|
1546
1778
|
});
|
|
1547
1779
|
return foundDuplicated;
|
|
1548
1780
|
}
|
|
1549
|
-
function isEnableMeasureBuild() {
|
|
1550
|
-
let enableMeasure = $.composers.DevelopmentBuildConfiguration.isEnableMeasureBuild;
|
|
1551
|
-
if (enableMeasure !== true && process.argv.length > 0) {
|
|
1552
|
-
enableMeasure = process.argv.find(argv => argv === "--measure") !== undefined;
|
|
1553
|
-
}
|
|
1554
|
-
return enableMeasure;
|
|
1555
|
-
}
|
|
1556
1781
|
function prefixCssSelector() {
|
|
1557
1782
|
//var applyToSelectors = ['input', '::before', '::after'];
|
|
1558
1783
|
//var applyToSelectors = ['select', 'textarea', 'button', 'input', '.btn', '.content', '.input-group', '.title', '.icon', '*'];
|
|
@@ -1615,9 +1840,6 @@ function registerWebComponentDefinitions(definitions) {
|
|
|
1615
1840
|
}
|
|
1616
1841
|
}
|
|
1617
1842
|
exports.registerWebComponentDefinitions = registerWebComponentDefinitions;
|
|
1618
|
-
function getRegisteredWebComponentDefinitions() {
|
|
1619
|
-
return _wcDefinitions;
|
|
1620
|
-
}
|
|
1621
1843
|
function sortString(a, b) {
|
|
1622
1844
|
if (a >= b) {
|
|
1623
1845
|
return 1;
|