@komaci/esm-generator 242.3.3 → 242.3.6

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.
@@ -392,5 +392,40 @@ describe('getCompositionConfig', () => {
392
392
  const code = (0, generator_1.default)(res).code;
393
393
  expect(code).toBe('{}');
394
394
  });
395
+ it('can handle a prop name having special characters', () => {
396
+ const res = (0, compositionAstGeneration_1.getCompositionConfig)({
397
+ type: 'ComposedAdg',
398
+ input: {
399
+ type: 'ImportReference',
400
+ value: '0/names/0',
401
+ },
402
+ properties: {
403
+ 'foo:baz': {
404
+ type: 'PrimitiveValue',
405
+ value: 'bar',
406
+ },
407
+ 'baz:foo': {
408
+ type: 'Binding',
409
+ value: 'bar',
410
+ },
411
+ baz: {
412
+ type: 'Binding',
413
+ value: 'bar',
414
+ },
415
+ foo: {
416
+ type: 'PrimitiveValue',
417
+ value: 'bar',
418
+ },
419
+ },
420
+ });
421
+ expect(res.properties[0].value
422
+ .properties[0].key.type).toBe('StringLiteral');
423
+ expect(res.properties[0].value
424
+ .properties[1].key.type).toBe('StringLiteral');
425
+ expect(res.properties[0].value
426
+ .properties[2].key.type).toBe('Identifier');
427
+ expect(res.properties[0].value
428
+ .properties[3].key.type).toBe('Identifier');
429
+ });
395
430
  });
396
431
  //# sourceMappingURL=compositionAstGeneration.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
@@ -284,10 +285,14 @@ function getCompositionConfig(composition, componentId, iterationContext) {
284
285
  for (const propName of Object.keys(composition.properties)) {
285
286
  const prop = composition.properties[propName];
286
287
  if (prop.type === 'Binding') {
287
- props.push(t.objectProperty(t.identifier(propName), (0, genericAstGeneration_1.bindingToExpression)(prop, iterationContext)));
288
+ props.push(t.objectProperty(hasSpecialCharacters.test(propName)
289
+ ? t.stringLiteral(propName)
290
+ : t.identifier(propName), (0, genericAstGeneration_1.bindingToExpression)(prop, iterationContext)));
288
291
  }
289
292
  else if (prop.type === 'PrimitiveValue') {
290
- props.push(t.objectProperty(t.identifier(propName), (0, genericAstGeneration_1.primitiveToExpression)(prop)));
293
+ props.push(t.objectProperty(hasSpecialCharacters.test(propName)
294
+ ? t.stringLiteral(propName)
295
+ : t.identifier(propName), (0, genericAstGeneration_1.primitiveToExpression)(prop)));
291
296
  }
292
297
  }
293
298
  config.push(t.objectProperty(types_1.ID.PROPS, t.objectExpression(props)));
@@ -199,6 +199,7 @@ exports.generateResolvableModule = generateResolvableModule;
199
199
  */
200
200
  function addImportStatements(moduleMetadata, statements, options) {
201
201
  if (moduleMetadata.importsByName.size > 0) {
202
+ const seenImports = new Set();
202
203
  const imports = Array.from(moduleMetadata.importsByName.values())
203
204
  .sort((a, b) => {
204
205
  if (a.resourceName < b.resourceName) {
@@ -211,7 +212,16 @@ function addImportStatements(moduleMetadata, statements, options) {
211
212
  return 0;
212
213
  }
213
214
  })
214
- .filter((value) => value.isFromInternalNamespace && value.usedInPriming);
215
+ .filter((value) => {
216
+ // sometimes we can have multiple import names mapped to the same import. so we want to dedup those before running them through composition
217
+ const isComposable = !seenImports.has(value.generatorAlias) &&
218
+ value.isFromInternalNamespace &&
219
+ value.usedInPriming;
220
+ if (isComposable) {
221
+ seenImports.add(value.generatorAlias);
222
+ }
223
+ return isComposable;
224
+ });
215
225
  let i = 0;
216
226
  while (i < imports.length) {
217
227
  const specifiers = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@komaci/esm-generator",
3
- "version": "242.3.3",
3
+ "version": "242.3.6",
4
4
  "description": "Komaci generator for ADG ES modules",
5
5
  "homepage": "https://komaci.dev/",
6
6
  "repository": {
@@ -29,12 +29,12 @@
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": "242.3.3",
33
- "@komaci/static-analyzer": "242.3.3",
32
+ "@komaci/common-shared": "242.3.6",
33
+ "@komaci/static-analyzer": "242.3.6",
34
34
  "o11y": "^240.7.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@komaci/types": "242.3.3",
37
+ "@komaci/types": "242.3.6",
38
38
  "@lwc-platform/sfdc-lwc-compiler": "^2.18.0-240.2"
39
39
  }
40
40
  }