@komaci/esm-generator 244.1.0 → 244.1.3
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/build/__tests__/adgAstGeneration.spec.js +25 -6
- package/build/__tests__/compositionAstGeneration.spec.js +35 -0
- package/build/__tests__/functionAstGeneration.spec.js +36 -0
- package/build/__tests__/genericAstGeneration.spec.js +5 -0
- package/build/compositionAstGeneration.js +7 -2
- package/build/functionAstGeneration.d.ts +7 -0
- package/build/functionAstGeneration.js +39 -6
- package/build/genericAstGeneration.js +28 -6
- package/package.json +4 -4
|
@@ -34,7 +34,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
34
34
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
35
35
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
36
36
|
adg.exportName = 'default';
|
|
37
|
-
moduleMetadata.
|
|
37
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
38
38
|
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
39
39
|
expect(res.type).toBe('VariableDeclaration');
|
|
40
40
|
const varDeclarator = res.declarations[0];
|
|
@@ -47,7 +47,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
47
47
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
48
48
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg1');
|
|
49
49
|
adg.exportName = 'base';
|
|
50
|
-
moduleMetadata.
|
|
50
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
51
51
|
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
52
52
|
expect(res.type).toBe('VariableDeclaration');
|
|
53
53
|
const varDeclarator = res.declarations[0];
|
|
@@ -60,7 +60,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
60
60
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
61
61
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
62
62
|
adg.exportName = 'default';
|
|
63
|
-
moduleMetadata.
|
|
63
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
64
64
|
adg.compositionRootIndex = 0;
|
|
65
65
|
adg.compositions = [
|
|
66
66
|
{
|
|
@@ -123,7 +123,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
123
123
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
124
124
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
125
125
|
adg.exportName = 'default';
|
|
126
|
-
moduleMetadata.
|
|
126
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
127
127
|
adg.compositionRootIndex = 0;
|
|
128
128
|
const primingFunction = {
|
|
129
129
|
requiredProperties: [],
|
|
@@ -144,7 +144,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
144
144
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
145
145
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
146
146
|
adg.exportName = 'default';
|
|
147
|
-
moduleMetadata.
|
|
147
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
148
148
|
adg.compositionRootIndex = 0;
|
|
149
149
|
const primingFunction = {
|
|
150
150
|
requiredProperties: [],
|
|
@@ -165,7 +165,7 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
165
165
|
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
166
166
|
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
167
167
|
adg.exportName = 'default';
|
|
168
|
-
moduleMetadata.
|
|
168
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
169
169
|
adg.compositionRootIndex = 0;
|
|
170
170
|
const primingFunction = {
|
|
171
171
|
requiredProperties: [],
|
|
@@ -181,5 +181,24 @@ describe('composeAdgStaticMetadata', () => {
|
|
|
181
181
|
expect(properties[0].value.value).toBe('c-test-comp');
|
|
182
182
|
expect(properties[2].value.value).toBeFalsy();
|
|
183
183
|
});
|
|
184
|
+
it('Correct id for non exported class', () => {
|
|
185
|
+
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
186
|
+
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
187
|
+
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
188
|
+
adg.compositionRootIndex = 0;
|
|
189
|
+
const primingFunction = {
|
|
190
|
+
requiredProperties: [],
|
|
191
|
+
type: common_shared_1.FunctionTypes.GETTER_FUNCTION,
|
|
192
|
+
};
|
|
193
|
+
adg.functions.push(primingFunction);
|
|
194
|
+
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
195
|
+
expect(res.type).toBe('VariableDeclaration');
|
|
196
|
+
const varDeclarator = res.declarations[0];
|
|
197
|
+
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
198
|
+
const properties = varDeclarator.init.properties;
|
|
199
|
+
expect(properties).toHaveLength(4);
|
|
200
|
+
expect(properties[0].value.value).toBe('c-test-comp__$nonExportedClass$');
|
|
201
|
+
expect(properties[2].value.value).toBeFalsy();
|
|
202
|
+
});
|
|
184
203
|
});
|
|
185
204
|
//# sourceMappingURL=adgAstGeneration.spec.js.map
|
|
@@ -419,5 +419,40 @@ describe('getCompositionConfig', () => {
|
|
|
419
419
|
const code = (0, generator_1.default)(res).code;
|
|
420
420
|
expect(code).toBe('{}');
|
|
421
421
|
});
|
|
422
|
+
it('can handle a prop name having special characters', () => {
|
|
423
|
+
const res = (0, compositionAstGeneration_1.getCompositionConfig)({
|
|
424
|
+
type: 'ComposedAdg',
|
|
425
|
+
input: {
|
|
426
|
+
type: 'ImportReference',
|
|
427
|
+
value: '0/names/0',
|
|
428
|
+
},
|
|
429
|
+
properties: {
|
|
430
|
+
'foo:baz': {
|
|
431
|
+
type: 'PrimitiveValue',
|
|
432
|
+
value: 'bar',
|
|
433
|
+
},
|
|
434
|
+
'baz:foo': {
|
|
435
|
+
type: 'Binding',
|
|
436
|
+
value: 'bar',
|
|
437
|
+
},
|
|
438
|
+
baz: {
|
|
439
|
+
type: 'Binding',
|
|
440
|
+
value: 'bar',
|
|
441
|
+
},
|
|
442
|
+
foo: {
|
|
443
|
+
type: 'PrimitiveValue',
|
|
444
|
+
value: 'bar',
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
expect(res.properties[0].value
|
|
449
|
+
.properties[0].key.type).toBe('Identifier');
|
|
450
|
+
expect(res.properties[0].value
|
|
451
|
+
.properties[1].key.type).toBe('StringLiteral');
|
|
452
|
+
expect(res.properties[0].value
|
|
453
|
+
.properties[2].key.type).toBe('Identifier');
|
|
454
|
+
expect(res.properties[0].value
|
|
455
|
+
.properties[3].key.type).toBe('StringLiteral');
|
|
456
|
+
});
|
|
422
457
|
});
|
|
423
458
|
//# sourceMappingURL=compositionAstGeneration.spec.js.map
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -11,6 +34,7 @@ const types_1 = require("@babel/types");
|
|
|
11
34
|
const functionAstGeneration_1 = require("../functionAstGeneration");
|
|
12
35
|
const generator_1 = __importDefault(require("@babel/generator"));
|
|
13
36
|
const badImportRef_1 = require("./fixtures-source-code/badImportRef");
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
14
38
|
const generalMockSourceCode_1 = require("./fixtures-source-code/generalMockSourceCode");
|
|
15
39
|
describe('hoistLocalFunction', () => {
|
|
16
40
|
const baseFilesPath = (0, path_1.join)(__dirname, 'general-komaci-docs/assorted-template-strings');
|
|
@@ -535,4 +559,16 @@ export default registerAdgFunction(adg0);`;
|
|
|
535
559
|
expect((0, generator_1.default)((0, types_1.file)(res)).code).toBe(expected);
|
|
536
560
|
});
|
|
537
561
|
});
|
|
562
|
+
describe('composeStaticMetadataAssignmentExpression', () => {
|
|
563
|
+
it('returns proper expression statement', () => {
|
|
564
|
+
const metaVarDeclarator = t.variableDeclarator(t.identifier(`Adg0Meta`), t.objectExpression([]));
|
|
565
|
+
const staticMetadataObject = t.variableDeclaration('const', [metaVarDeclarator]);
|
|
566
|
+
const expr = (0, functionAstGeneration_1.composeStaticMetadataAssignmentExpression)('adg0', staticMetadataObject).expression;
|
|
567
|
+
const left = expr.left;
|
|
568
|
+
expect(left.object.name).toBe('adg0');
|
|
569
|
+
expect(left.property.name).toBe('meta');
|
|
570
|
+
const right = expr.right;
|
|
571
|
+
expect(right.name).toBe('Adg0Meta');
|
|
572
|
+
});
|
|
573
|
+
});
|
|
538
574
|
//# sourceMappingURL=functionAstGeneration.spec.js.map
|
|
@@ -494,6 +494,7 @@ describe('addImportStatements', () => {
|
|
|
494
494
|
(0, common_shared_1.composeImportMetadata)('adg', '@salesforce/komaci/c__foo__foo.js', true, '4/names/0', moduleMetadata);
|
|
495
495
|
moduleMetadata.importsByNamespace.set('lightning/uiTestingApi', {
|
|
496
496
|
names: new Set(['default', 'regularImport']),
|
|
497
|
+
originalNames: new Set(['default', 'regularImport']),
|
|
497
498
|
isDefaultSpecifier: true,
|
|
498
499
|
isSupported: true,
|
|
499
500
|
isNamespaceSpecifier: false,
|
|
@@ -501,6 +502,7 @@ describe('addImportStatements', () => {
|
|
|
501
502
|
});
|
|
502
503
|
moduleMetadata.importsByNamespace.set('badImport', {
|
|
503
504
|
names: new Set(['tes1', 'tes2']),
|
|
505
|
+
originalNames: new Set(['tes1', 'tes2']),
|
|
504
506
|
isDefaultSpecifier: false,
|
|
505
507
|
isSupported: false,
|
|
506
508
|
isNamespaceSpecifier: false,
|
|
@@ -508,6 +510,7 @@ describe('addImportStatements', () => {
|
|
|
508
510
|
});
|
|
509
511
|
moduleMetadata.importsByNamespace.set('@salesforce/labels', {
|
|
510
512
|
names: new Set(['*']),
|
|
513
|
+
originalNames: new Set(['*']),
|
|
511
514
|
isDefaultSpecifier: false,
|
|
512
515
|
isSupported: true,
|
|
513
516
|
isNamespaceSpecifier: true,
|
|
@@ -515,6 +518,7 @@ describe('addImportStatements', () => {
|
|
|
515
518
|
});
|
|
516
519
|
moduleMetadata.importsByNamespace.set('lightning/uiRecordApi', {
|
|
517
520
|
names: new Set(['tes3', 'tes4', 'tes5']),
|
|
521
|
+
originalNames: new Set(['tes3', 'tes4', 'tes5']),
|
|
518
522
|
isDefaultSpecifier: false,
|
|
519
523
|
isSupported: true,
|
|
520
524
|
isNamespaceSpecifier: false,
|
|
@@ -522,6 +526,7 @@ describe('addImportStatements', () => {
|
|
|
522
526
|
});
|
|
523
527
|
moduleMetadata.importsByNamespace.set('@salesforce/komaci/c__foo__foo.js', {
|
|
524
528
|
names: new Set(['adg']),
|
|
529
|
+
originalNames: new Set(['adg']),
|
|
525
530
|
isDefaultSpecifier: false,
|
|
526
531
|
isSupported: true,
|
|
527
532
|
isNamespaceSpecifier: false,
|
|
@@ -28,6 +28,7 @@ const common_shared_1 = require("@komaci/common-shared");
|
|
|
28
28
|
const t = __importStar(require("@babel/types"));
|
|
29
29
|
const genericAstGeneration_1 = require("./genericAstGeneration");
|
|
30
30
|
const types_1 = require("./types");
|
|
31
|
+
const hasSpecialCharacters = /^([0-9]+|(.*[^A-Za-z0-9]+.*))$/;
|
|
31
32
|
/**
|
|
32
33
|
* Convert an array of Komaci Compositions into a babel array of expressions.
|
|
33
34
|
* This is used for both the top-level compositions in the Komaci Doc, as well
|
|
@@ -285,10 +286,14 @@ function getCompositionConfig(composition, componentId, iterationContext) {
|
|
|
285
286
|
for (const propName of sortedCompositions) {
|
|
286
287
|
const prop = composition.properties[propName];
|
|
287
288
|
if (prop.type === 'Binding') {
|
|
288
|
-
props.push(t.objectProperty(
|
|
289
|
+
props.push(t.objectProperty(hasSpecialCharacters.test(propName)
|
|
290
|
+
? t.stringLiteral(propName)
|
|
291
|
+
: t.identifier(propName), (0, genericAstGeneration_1.bindingToExpression)(prop, iterationContext)));
|
|
289
292
|
}
|
|
290
293
|
else if (prop.type === 'PrimitiveValue') {
|
|
291
|
-
props.push(t.objectProperty(
|
|
294
|
+
props.push(t.objectProperty(hasSpecialCharacters.test(propName)
|
|
295
|
+
? t.stringLiteral(propName)
|
|
296
|
+
: t.identifier(propName), (0, genericAstGeneration_1.primitiveToExpression)(prop)));
|
|
292
297
|
}
|
|
293
298
|
}
|
|
294
299
|
config.push(t.objectProperty(types_1.ID.PROPS, t.objectExpression(props)));
|
|
@@ -85,4 +85,11 @@ export declare function getInlineFunctionFromTemplateCompositions(moduleMetadata
|
|
|
85
85
|
* @returns A default export representing the error state for this resolvable module
|
|
86
86
|
*/
|
|
87
87
|
export declare function produceErrorAdgFunction(moduleMetadata: ModuleMetadata, error: Error): t.Program;
|
|
88
|
+
/**
|
|
89
|
+
* Helper function to return the static metadata assignemnt expression statement.
|
|
90
|
+
* @param adgName the name of the adg function to associate the adgMeta object with.
|
|
91
|
+
* @param staticMetadataObject the staticMetadatObject to get the assicated adgMeta object name.
|
|
92
|
+
* @returns an expression statement, eg: adg0.meta = adg0meta
|
|
93
|
+
*/
|
|
94
|
+
export declare function composeStaticMetadataAssignmentExpression(adgName: string, staticMetadataObject: t.VariableDeclaration): t.ExpressionStatement;
|
|
88
95
|
//# sourceMappingURL=functionAstGeneration.d.ts.map
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.produceErrorAdgFunction = exports.getInlineFunctionFromTemplateCompositions = exports.getAdgFunctionBody = exports.addExportStatement = exports.composeAdgStaticMetadata = exports.composeAdgFunction = exports.getFactoryFuncDeclaration = exports.adgToExpression = exports.sanitizeFunction = exports.hoistLocalFunction = void 0;
|
|
26
|
+
exports.composeStaticMetadataAssignmentExpression = exports.produceErrorAdgFunction = exports.getInlineFunctionFromTemplateCompositions = exports.getAdgFunctionBody = exports.addExportStatement = exports.composeAdgStaticMetadata = exports.composeAdgFunction = exports.getFactoryFuncDeclaration = exports.adgToExpression = exports.sanitizeFunction = exports.hoistLocalFunction = void 0;
|
|
27
27
|
const t = __importStar(require("@babel/types"));
|
|
28
28
|
const common_shared_1 = require("@komaci/common-shared");
|
|
29
29
|
const compositionAstGeneration_1 = require("./compositionAstGeneration");
|
|
@@ -242,13 +242,35 @@ exports.composeAdgFunction = composeAdgFunction;
|
|
|
242
242
|
* @returns a babel representation of a static metadata object.
|
|
243
243
|
*/
|
|
244
244
|
function composeAdgStaticMetadata(adg, moduleMetadata) {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
const Id = adg.exportName == 'default' ||
|
|
246
|
+
moduleMetadata.moduleType == common_shared_1.ModuleTypes.TEMPLATE_ONLY
|
|
247
|
+
? moduleMetadata.staticMetadataId
|
|
248
|
+
: adg.exportName
|
|
249
|
+
? `${moduleMetadata.staticMetadataId}__${adg.exportName}`
|
|
250
|
+
: `${moduleMetadata.staticMetadataId}__$nonExportedClass$`;
|
|
248
251
|
const metaDataProps = [];
|
|
249
252
|
//creating id: "comp-id";
|
|
250
|
-
const idProp = t.objectProperty(t.identifier('id'), t.stringLiteral(
|
|
253
|
+
const idProp = t.objectProperty(t.identifier('id'), t.stringLiteral(Id));
|
|
251
254
|
metaDataProps.push(idProp);
|
|
255
|
+
if (adg.parentReference != undefined) {
|
|
256
|
+
if (adg.parentReference.type == 'ImportReference') {
|
|
257
|
+
const importName = moduleMetadata.importIndexReference.get(adg.parentReference.value);
|
|
258
|
+
if (importName) {
|
|
259
|
+
const importId = moduleMetadata.importsByName.get(importName)?.generatorAlias;
|
|
260
|
+
if (importId) {
|
|
261
|
+
const parentProp = t.objectProperty(t.identifier('p'), t.identifier(importId));
|
|
262
|
+
metaDataProps.push(parentProp);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else if (adg.parentReference.type == 'AdgReference') {
|
|
267
|
+
const parentAdgName = moduleMetadata.adgs.get(adg.parentReference.value)?.defaultGeneratedName;
|
|
268
|
+
if (parentAdgName) {
|
|
269
|
+
const parentProp = t.objectProperty(t.identifier('p'), t.identifier(parentAdgName));
|
|
270
|
+
metaDataProps.push(parentProp);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
252
274
|
const tPropBody = [];
|
|
253
275
|
let hasImg = false;
|
|
254
276
|
if (adg.compositions && adg.compositionRootIndex != undefined) {
|
|
@@ -267,7 +289,7 @@ function composeAdgStaticMetadata(adg, moduleMetadata) {
|
|
|
267
289
|
//creating pf: false as the default.
|
|
268
290
|
const pfProp = t.objectProperty(t.identifier('pf'), t.booleanLiteral(hasPrimableFunction));
|
|
269
291
|
//creating img: prop based on if we found an img in the children traversal
|
|
270
|
-
const imgProp = t.objectProperty(t.identifier('
|
|
292
|
+
const imgProp = t.objectProperty(t.identifier('img'), t.booleanLiteral(hasImg));
|
|
271
293
|
metaDataProps.push(pfProp);
|
|
272
294
|
metaDataProps.push(imgProp);
|
|
273
295
|
//eg: adg0Meta: {...metadataProps}
|
|
@@ -480,4 +502,15 @@ function produceErrorAdgFunction(moduleMetadata, error) {
|
|
|
480
502
|
]);
|
|
481
503
|
}
|
|
482
504
|
exports.produceErrorAdgFunction = produceErrorAdgFunction;
|
|
505
|
+
/**
|
|
506
|
+
* Helper function to return the static metadata assignemnt expression statement.
|
|
507
|
+
* @param adgName the name of the adg function to associate the adgMeta object with.
|
|
508
|
+
* @param staticMetadataObject the staticMetadatObject to get the assicated adgMeta object name.
|
|
509
|
+
* @returns an expression statement, eg: adg0.meta = adg0meta
|
|
510
|
+
*/
|
|
511
|
+
function composeStaticMetadataAssignmentExpression(adgName, staticMetadataObject) {
|
|
512
|
+
return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(adgName), t.identifier('meta')), t.identifier(staticMetadataObject.declarations[0]
|
|
513
|
+
.id.name)));
|
|
514
|
+
}
|
|
515
|
+
exports.composeStaticMetadataAssignmentExpression = composeStaticMetadataAssignmentExpression;
|
|
483
516
|
//# sourceMappingURL=functionAstGeneration.js.map
|
|
@@ -61,12 +61,16 @@ function generateResolvableModule(input, scriptKomaciDoc, templateKomaciDocMap,
|
|
|
61
61
|
: undefined;
|
|
62
62
|
const hasScriptKomaciDoc = scriptKomaciDoc && Object.keys(scriptKomaciDoc).length !== 0;
|
|
63
63
|
const hasTemplateKomaciDoc = defaultTemplateKomaciDoc && Object.keys(defaultTemplateKomaciDoc).length !== 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
moduleMetadata.defaultComponentId = (0, common_shared_1.getComponentId)(input.moduleInfo.namespace, input.moduleInfo.name);
|
|
67
|
-
}
|
|
64
|
+
//generates the component name eg. komaciAction.js/html -> c-komaci-action
|
|
65
|
+
moduleMetadata.staticMetadataId = (0, common_shared_1.getComponentId)(input.moduleInfo.namespace, input.moduleInfo.name);
|
|
68
66
|
const combinedModule = scriptKomaciDoc !== undefined && defaultTemplateKomaciDoc !== undefined;
|
|
69
67
|
const isBundle = input.moduleInfo.type === 'bundle';
|
|
68
|
+
moduleMetadata.moduleType =
|
|
69
|
+
hasTemplateKomaciDoc && hasScriptKomaciDoc
|
|
70
|
+
? common_shared_1.ModuleTypes.BUNDLE_MODULE
|
|
71
|
+
: hasScriptKomaciDoc
|
|
72
|
+
? common_shared_1.ModuleTypes.SCRIPT_ONLY
|
|
73
|
+
: common_shared_1.ModuleTypes.TEMPLATE_ONLY;
|
|
70
74
|
let renderFunctionMetadata = undefined;
|
|
71
75
|
// start of metadata collection
|
|
72
76
|
if (scriptKomaciDoc) {
|
|
@@ -179,7 +183,15 @@ function generateResolvableModule(input, scriptKomaciDoc, templateKomaciDocMap,
|
|
|
179
183
|
statements.push(addUndefinedDefaultExport());
|
|
180
184
|
}
|
|
181
185
|
for (const adg of moduleMetadata.adgs.values()) {
|
|
182
|
-
|
|
186
|
+
//eg: const adgoMeta = {...}
|
|
187
|
+
const staticMetadataObject = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
188
|
+
//eg: function adg0(fct, ctx) {...}
|
|
189
|
+
const adgFunctionDefinition = (0, functionAstGeneration_1.composeAdgFunction)(adg, moduleMetadata);
|
|
190
|
+
//eg: adg0.meta = adg0Meta;
|
|
191
|
+
const staticMetadataAssignmentExpression = (0, functionAstGeneration_1.composeStaticMetadataAssignmentExpression)(adg.defaultGeneratedName, staticMetadataObject);
|
|
192
|
+
statements.push(staticMetadataObject);
|
|
193
|
+
statements.push(adgFunctionDefinition);
|
|
194
|
+
statements.push(staticMetadataAssignmentExpression);
|
|
183
195
|
}
|
|
184
196
|
for (const [exportName, adg] of Object.entries(moduleMetadata.exports)) {
|
|
185
197
|
statements.push((0, functionAstGeneration_1.addExportStatement)(adg.defaultGeneratedName, exportName));
|
|
@@ -203,6 +215,7 @@ exports.generateResolvableModule = generateResolvableModule;
|
|
|
203
215
|
*/
|
|
204
216
|
function addImportStatements(moduleMetadata, statements, options) {
|
|
205
217
|
if (moduleMetadata.importsByName.size > 0) {
|
|
218
|
+
const seenImports = new Set();
|
|
206
219
|
const imports = Array.from(moduleMetadata.importsByName.values())
|
|
207
220
|
.sort((a, b) => {
|
|
208
221
|
if (a.resourceName < b.resourceName) {
|
|
@@ -215,7 +228,16 @@ function addImportStatements(moduleMetadata, statements, options) {
|
|
|
215
228
|
return 0;
|
|
216
229
|
}
|
|
217
230
|
})
|
|
218
|
-
.filter((value) =>
|
|
231
|
+
.filter((value) => {
|
|
232
|
+
// sometimes we can have multiple import names mapped to the same import. so we want to dedup those before running them through composition
|
|
233
|
+
const isComposable = !seenImports.has(value.generatorAlias) &&
|
|
234
|
+
value.isFromInternalNamespace &&
|
|
235
|
+
value.usedInPriming;
|
|
236
|
+
if (isComposable) {
|
|
237
|
+
seenImports.add(value.generatorAlias);
|
|
238
|
+
}
|
|
239
|
+
return isComposable;
|
|
240
|
+
});
|
|
219
241
|
let i = 0;
|
|
220
242
|
while (i < imports.length) {
|
|
221
243
|
const specifiers = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@komaci/esm-generator",
|
|
3
|
-
"version": "244.1.
|
|
3
|
+
"version": "244.1.3",
|
|
4
4
|
"description": "Komaci generator for ADG ES modules",
|
|
5
5
|
"homepage": "https://komaci.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@babel/core": "^7.9.0",
|
|
30
30
|
"@babel/generator": "^7.9.0",
|
|
31
31
|
"@babel/types": "^7.9.0",
|
|
32
|
-
"@komaci/common-shared": "244.1.
|
|
33
|
-
"@komaci/static-analyzer": "244.1.
|
|
32
|
+
"@komaci/common-shared": "244.1.3",
|
|
33
|
+
"@komaci/static-analyzer": "244.1.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@komaci/types": "244.1.
|
|
36
|
+
"@komaci/types": "244.1.3",
|
|
37
37
|
"@lwc-platform/sfdc-lwc-compiler": "242.15.1-2.28.0",
|
|
38
38
|
"@lwc/metadata": "^2.28.0-0"
|
|
39
39
|
}
|