@komaci/esm-generator 264.4.0 → 266.3.0

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.
Files changed (130) hide show
  1. package/build/genericAstGeneration.js +80 -34
  2. package/package.json +1 -1
  3. package/build/__tests__/adgAstGeneration.spec.d.ts +0 -2
  4. package/build/__tests__/adgAstGeneration.spec.js +0 -447
  5. package/build/__tests__/compile-generated-module-fixtures.spec.d.ts +0 -2
  6. package/build/__tests__/compile-generated-module-fixtures.spec.js +0 -49
  7. package/build/__tests__/compilerConfigs.d.ts +0 -24
  8. package/build/__tests__/compilerConfigs.js +0 -126
  9. package/build/__tests__/compositionAstGeneration.spec.d.ts +0 -2
  10. package/build/__tests__/compositionAstGeneration.spec.js +0 -676
  11. package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.d.ts +0 -6
  12. package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.js +0 -28
  13. package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.d.ts +0 -29
  14. package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.js +0 -148
  15. package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.d.ts +0 -9
  16. package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.js +0 -35
  17. package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.d.ts +0 -10
  18. package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.js +0 -39
  19. package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
  20. package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.js +0 -34
  21. package/build/__tests__/fixtures-combined-files/image-type/actual.d.ts +0 -13
  22. package/build/__tests__/fixtures-combined-files/image-type/actual.js +0 -41
  23. package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.d.ts +0 -14
  24. package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.js +0 -79
  25. package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.d.ts +0 -18
  26. package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.js +0 -103
  27. package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.d.ts +0 -6
  28. package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.js +0 -28
  29. package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.d.ts +0 -6
  30. package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.js +0 -16
  31. package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.d.ts +0 -4
  32. package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.js +0 -18
  33. package/build/__tests__/fixtures-combined-files/include-template-strings/actual.d.ts +0 -10
  34. package/build/__tests__/fixtures-combined-files/include-template-strings/actual.js +0 -41
  35. package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.d.ts +0 -9
  36. package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.js +0 -38
  37. package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.d.ts +0 -7
  38. package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.js +0 -34
  39. package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.d.ts +0 -1
  40. package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.js +0 -2
  41. package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
  42. package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
  43. package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.d.ts +0 -5
  44. package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.js +0 -14
  45. package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.d.ts +0 -6
  46. package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.js +0 -31
  47. package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.d.ts +0 -6
  48. package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.js +0 -27
  49. package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.d.ts +0 -15
  50. package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.js +0 -104
  51. package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.d.ts +0 -8
  52. package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.js +0 -17
  53. package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.d.ts +0 -4
  54. package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.js +0 -13
  55. package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.d.ts +0 -4
  56. package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.js +0 -10
  57. package/build/__tests__/fixtures-script-files/class-props/actual.d.ts +0 -30
  58. package/build/__tests__/fixtures-script-files/class-props/actual.js +0 -103
  59. package/build/__tests__/fixtures-script-files/empty-class/actual.d.ts +0 -4
  60. package/build/__tests__/fixtures-script-files/empty-class/actual.js +0 -7
  61. package/build/__tests__/fixtures-script-files/empty-doc/actual.d.ts +0 -1
  62. package/build/__tests__/fixtures-script-files/empty-doc/actual.js +0 -2
  63. package/build/__tests__/fixtures-script-files/empty-wire/actual.d.ts +0 -5
  64. package/build/__tests__/fixtures-script-files/empty-wire/actual.js +0 -16
  65. package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
  66. package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.js +0 -34
  67. package/build/__tests__/fixtures-script-files/exports/actual.d.ts +0 -22
  68. package/build/__tests__/fixtures-script-files/exports/actual.js +0 -63
  69. package/build/__tests__/fixtures-script-files/imports/actual.d.ts +0 -11
  70. package/build/__tests__/fixtures-script-files/imports/actual.js +0 -80
  71. package/build/__tests__/fixtures-script-files/imports-namespaced/actual.d.ts +0 -10
  72. package/build/__tests__/fixtures-script-files/imports-namespaced/actual.js +0 -63
  73. package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.d.ts +0 -7
  74. package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.js +0 -34
  75. package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.d.ts +0 -3
  76. package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.js +0 -10
  77. package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.d.ts +0 -9
  78. package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.js +0 -24
  79. package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.d.ts +0 -4
  80. package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.js +0 -17
  81. package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.d.ts +0 -4
  82. package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.js +0 -17
  83. package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
  84. package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
  85. package/build/__tests__/fixtures-script-files/wire-basic/actual.d.ts +0 -8
  86. package/build/__tests__/fixtures-script-files/wire-basic/actual.js +0 -30
  87. package/build/__tests__/fixtures-script-files/wire-functions/actual.d.ts +0 -13
  88. package/build/__tests__/fixtures-script-files/wire-functions/actual.js +0 -46
  89. package/build/__tests__/fixtures-script-files/wire-imports/actual.d.ts +0 -11
  90. package/build/__tests__/fixtures-script-files/wire-imports/actual.js +0 -63
  91. package/build/__tests__/fixtures-source-code/badImportRef.d.ts +0 -4
  92. package/build/__tests__/fixtures-source-code/badImportRef.js +0 -31
  93. package/build/__tests__/fixtures-source-code/generalMockSourceCode.d.ts +0 -8
  94. package/build/__tests__/fixtures-source-code/generalMockSourceCode.js +0 -127
  95. package/build/__tests__/fixtures-source-code/gqlMockSource.d.ts +0 -3
  96. package/build/__tests__/fixtures-source-code/gqlMockSource.js +0 -95
  97. package/build/__tests__/functionAstGeneration.spec.d.ts +0 -2
  98. package/build/__tests__/functionAstGeneration.spec.js +0 -727
  99. package/build/__tests__/general-komaci-docs/assorted-template-strings/source.d.ts +0 -10
  100. package/build/__tests__/general-komaci-docs/assorted-template-strings/source.js +0 -41
  101. package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.d.ts +0 -7
  102. package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.js +0 -31
  103. package/build/__tests__/general-komaci-docs/import-types/source.d.ts +0 -18
  104. package/build/__tests__/general-komaci-docs/import-types/source.js +0 -108
  105. package/build/__tests__/general-komaci-docs/import-types/validationStuff.d.ts +0 -18
  106. package/build/__tests__/general-komaci-docs/import-types/validationStuff.js +0 -63
  107. package/build/__tests__/general-komaci-docs/template-component/source.d.ts +0 -8
  108. package/build/__tests__/general-komaci-docs/template-component/source.js +0 -34
  109. package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.d.ts +0 -2
  110. package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.js +0 -20
  111. package/build/__tests__/generated-module/lightning/component/component.d.ts +0 -18
  112. package/build/__tests__/generated-module/lightning/component/component.js +0 -168
  113. package/build/__tests__/genericAstGeneration.spec.d.ts +0 -2
  114. package/build/__tests__/genericAstGeneration.spec.js +0 -1052
  115. package/build/__tests__/index.spec.d.ts +0 -2
  116. package/build/__tests__/index.spec.js +0 -393
  117. package/build/__tests__/komaci-ast-unit.spec.d.ts +0 -2
  118. package/build/__tests__/komaci-ast-unit.spec.js +0 -422
  119. package/build/__tests__/komaci-bundle-module.fixtures.spec.d.ts +0 -2
  120. package/build/__tests__/komaci-bundle-module.fixtures.spec.js +0 -76
  121. package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.d.ts +0 -2
  122. package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.js +0 -117
  123. package/build/__tests__/komaci-gql.fixtures.spec.d.ts +0 -2
  124. package/build/__tests__/komaci-gql.fixtures.spec.js +0 -51
  125. package/build/__tests__/komaci-script-module.fixtures.spec.d.ts +0 -2
  126. package/build/__tests__/komaci-script-module.fixtures.spec.js +0 -70
  127. package/build/__tests__/komaci-template-module.fixtures.spec.d.ts +0 -2
  128. package/build/__tests__/komaci-template-module.fixtures.spec.js +0 -57
  129. package/build/__tests__/readAndParseBundle.d.ts +0 -22
  130. package/build/__tests__/readAndParseBundle.js +0 -80
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1,393 +0,0 @@
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
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const __1 = require("..");
27
- const modgen = __importStar(require("../genericAstGeneration"));
28
- const metadata_1 = require("@lwc/metadata");
29
- describe('Handling errors that throw inside a call to generateKomaciModule', () => {
30
- it('should return error adg when an error is produced', () => {
31
- const input = {
32
- moduleInfo: {
33
- name: 'test',
34
- namespace: 'lightning',
35
- type: 'bad',
36
- files: {},
37
- },
38
- srcFileMap: {
39
- 'test.js': '',
40
- 'test.css': 'p { text-align: center; }',
41
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
42
- },
43
- };
44
- const res = (0, __1.generateKomaciModule)(input);
45
- const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
46
- 'function adg0(fct, ctx) {\n' +
47
- ' const {\n' +
48
- ' adg\n' +
49
- ' } = fct;\n' +
50
- ' return adg(undefined, {}, [{\n' +
51
- ' t: "ErrorFunction",\n' +
52
- ' c: {\n' +
53
- ' "error": "[komaci esm-generator] unrecognized input type"\n';
54
- const expectedModuleSecondHalf = ' return [];\n' +
55
- ' }, []);\n' +
56
- '}\n' +
57
- '\nexport default registerAdgFunction(adg0);';
58
- const lines = res.split('\n');
59
- const skipStack = lines.slice(0, 10).join('\n') + '\n';
60
- const skipStackEnd = lines.slice(lines.length - 5).join('\n');
61
- expect(skipStack).toBe(expectedModuleFirstHalf);
62
- expect(skipStackEnd).toBe(expectedModuleSecondHalf);
63
- });
64
- it('should return error adg when something not an error is thrown', () => {
65
- const input = {
66
- moduleInfo: {
67
- name: 'test',
68
- namespace: 'lightning',
69
- type: 'bundle',
70
- files: {},
71
- },
72
- srcFileMap: {
73
- 'test.js': '',
74
- 'test.css': 'p { text-align: center; }',
75
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
76
- },
77
- };
78
- const mock = jest.spyOn(modgen, 'generateResolvableModule');
79
- mock.mockImplementationOnce(() => {
80
- throw 'not an error';
81
- });
82
- const res = (0, __1.generateKomaciModule)(input);
83
- const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
84
- 'function adg0(fct, ctx) {\n' +
85
- ' const {\n' +
86
- ' adg\n' +
87
- ' } = fct;\n' +
88
- ' return adg(undefined, {}, [{\n' +
89
- ' t: "ErrorFunction",\n' +
90
- ' c: {\n' +
91
- ' "error": "[komaci] Something that is not an error was thrown"\n';
92
- const expectedModuleSecondHalf = ' return [];\n' +
93
- ' }, []);\n' +
94
- '}\n' +
95
- '\nexport default registerAdgFunction(adg0);';
96
- const lines = res.split('\n');
97
- const skipStack = lines.slice(0, 10).join('\n') + '\n';
98
- const skipStackEnd = lines.slice(lines.length - 5).join('\n');
99
- expect(skipStack).toBe(expectedModuleFirstHalf);
100
- expect(skipStackEnd).toBe(expectedModuleSecondHalf);
101
- });
102
- it('should return error adg when undefined is thrown', () => {
103
- const input = {
104
- moduleInfo: {
105
- name: 'test',
106
- namespace: 'lightning',
107
- type: 'bundle',
108
- files: {},
109
- },
110
- srcFileMap: {
111
- 'test.js': '',
112
- 'test.css': 'p { text-align: center; }',
113
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
114
- },
115
- };
116
- const mock = jest.spyOn(modgen, 'generateResolvableModule');
117
- mock.mockImplementationOnce(() => {
118
- throw undefined;
119
- });
120
- const res = (0, __1.generateKomaciModule)(input);
121
- const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
122
- 'function adg0(fct, ctx) {\n' +
123
- ' const {\n' +
124
- ' adg\n' +
125
- ' } = fct;\n' +
126
- ' return adg(undefined, {}, [{\n' +
127
- ' t: "ErrorFunction",\n' +
128
- ' c: {\n' +
129
- ' "error": "[komaci] Something that is not an error was thrown"\n';
130
- const expectedModuleSecondHalf = ' return [];\n' +
131
- ' }, []);\n' +
132
- '}\n' +
133
- '\nexport default registerAdgFunction(adg0);';
134
- const lines = res.split('\n');
135
- const skipStack = lines.slice(0, 10).join('\n') + '\n';
136
- const skipStackEnd = lines.slice(lines.length - 5).join('\n');
137
- expect(skipStack).toBe(expectedModuleFirstHalf);
138
- expect(skipStackEnd).toBe(expectedModuleSecondHalf);
139
- });
140
- });
141
- describe('normalizeSrcFileKeys', () => {
142
- it('should properly normalize keys that are full filePaths', () => {
143
- const bundleSrcFileMap = {
144
- 'c/test/test.js': {},
145
- 'c/test/test.css': {},
146
- 'c/test/test.html': {},
147
- };
148
- const input = {
149
- moduleInfo: {
150
- name: 'test',
151
- namespace: 'c',
152
- type: 'bundle',
153
- files: bundleSrcFileMap,
154
- },
155
- srcFileMap: {
156
- 'c/test/test.js': '',
157
- 'c/test/test.css': 'p { text-align: center; }',
158
- 'c/test/test.html': '<html><body><h1>Hey</h1></body></html>',
159
- },
160
- };
161
- (0, __1.normalizeSrcFileKeys)(input);
162
- expect(input.moduleInfo.files['test.js']).not.toBeUndefined();
163
- expect(input.moduleInfo.files['test.css']).not.toBeUndefined();
164
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
165
- expect(input.srcFileMap['test.js']).not.toBeUndefined();
166
- expect(input.srcFileMap['test.css']).not.toBeUndefined();
167
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
168
- });
169
- it('should properly normalize keys that are full filePaths with sub dirs', () => {
170
- const bundleSrcFileMap = {
171
- 'c/test/test.js': {},
172
- 'c/test/test.css': {},
173
- 'c/test/test.html': {},
174
- 'c/test/templates/test2.html': {},
175
- };
176
- const input = {
177
- moduleInfo: {
178
- name: 'test',
179
- namespace: 'c',
180
- type: 'bundle',
181
- files: bundleSrcFileMap,
182
- },
183
- srcFileMap: {
184
- 'c/test/test.js': '',
185
- 'c/test/test.css': 'p { text-align: center; }',
186
- 'c/test/test.html': '<html><body><h1>Hey</h1></body></html>',
187
- 'c/test/templates/test2.html': '<html><body><h1>Hey</h1></body></html>',
188
- },
189
- };
190
- (0, __1.normalizeSrcFileKeys)(input);
191
- expect(input.moduleInfo.files['test.js']).not.toBeUndefined();
192
- expect(input.moduleInfo.files['test.css']).not.toBeUndefined();
193
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
194
- expect(input.srcFileMap['test.js']).not.toBeUndefined();
195
- expect(input.srcFileMap['test.css']).not.toBeUndefined();
196
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
197
- });
198
- it('keys stay same when passed in by fileName', () => {
199
- const bundleSrcFileMap = {
200
- 'test.js': {},
201
- 'test.css': {},
202
- 'test.html': {},
203
- };
204
- const input = {
205
- moduleInfo: {
206
- name: 'test',
207
- namespace: 'c',
208
- type: 'bundle',
209
- files: bundleSrcFileMap,
210
- },
211
- srcFileMap: {
212
- 'test.js': '',
213
- 'test.css': 'p { text-align: center; }',
214
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
215
- },
216
- };
217
- (0, __1.normalizeSrcFileKeys)(input);
218
- expect(input.moduleInfo.files['test.js']).not.toBeUndefined();
219
- expect(input.moduleInfo.files['test.css']).not.toBeUndefined();
220
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
221
- expect(input.srcFileMap['test.js']).not.toBeUndefined();
222
- expect(input.srcFileMap['test.css']).not.toBeUndefined();
223
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
224
- });
225
- it('keys stay same for single html file', () => {
226
- const bundleSrcFileMap = {
227
- 'test.html': {},
228
- };
229
- const input = {
230
- moduleInfo: {
231
- name: 'test',
232
- namespace: 'c',
233
- type: 'bundle',
234
- files: bundleSrcFileMap,
235
- },
236
- srcFileMap: {
237
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
238
- },
239
- };
240
- (0, __1.normalizeSrcFileKeys)(input);
241
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
242
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
243
- });
244
- it('key is normalized when full path is provided', () => {
245
- const bundleSrcFileMap = {
246
- 'c/test/test.html': {},
247
- };
248
- const input = {
249
- moduleInfo: {
250
- name: 'test',
251
- namespace: 'c',
252
- type: 'bundle',
253
- files: bundleSrcFileMap,
254
- },
255
- srcFileMap: {
256
- 'c/test/test.html': '<html><body><h1>Hey</h1></body></html>',
257
- },
258
- };
259
- (0, __1.normalizeSrcFileKeys)(input);
260
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
261
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
262
- });
263
- it('No keys change, with subDir included', () => {
264
- const bundleSrcFileMap = {
265
- 'test.js': {},
266
- 'test.css': {},
267
- 'test.html': {},
268
- 'templates/test2.html': {},
269
- };
270
- const input = {
271
- moduleInfo: {
272
- name: 'test',
273
- namespace: 'c',
274
- type: 'bundle',
275
- files: bundleSrcFileMap,
276
- },
277
- srcFileMap: {
278
- 'test.js': '',
279
- 'test.css': 'p { text-align: center; }',
280
- 'test.html': '<html><body><h1>Hey</h1></body></html>',
281
- 'templates/test2.html': '<html><body><h1>Hey</h1></body></html>',
282
- },
283
- };
284
- (0, __1.normalizeSrcFileKeys)(input);
285
- expect(input.moduleInfo.files['test.js']).not.toBeUndefined();
286
- expect(input.moduleInfo.files['test.css']).not.toBeUndefined();
287
- expect(input.moduleInfo.files['test.html']).not.toBeUndefined();
288
- expect(input.srcFileMap['test.js']).not.toBeUndefined();
289
- expect(input.srcFileMap['test.css']).not.toBeUndefined();
290
- expect(input.srcFileMap['test.html']).not.toBeUndefined();
291
- expect(input.srcFileMap['templates/test2.html']).not.toBeUndefined();
292
- });
293
- });
294
- describe('Bundle processing', () => {
295
- it('when both .js and .ts files exist with for the component name', () => {
296
- const bundleSrcFileMap = {
297
- 'test.js': {},
298
- 'test.ts': {},
299
- 'test.html': {},
300
- };
301
- const input = {
302
- moduleInfo: {
303
- name: 'test',
304
- namespace: 'lightning',
305
- type: 'bundle',
306
- files: bundleSrcFileMap,
307
- },
308
- srcFileMap: {
309
- 'test.js': 'export default class Test {}',
310
- 'test.ts': 'export default class Test {}',
311
- 'test.html': '<template><div>Test</div></template>',
312
- 'test.css': 'p { text-align: center; }',
313
- },
314
- };
315
- const res = (0, __1.generateKomaciModule)(input);
316
- expect(res).toContain('ErrorFunction');
317
- expect(res).toContain('[komaci esm-generator] multiple component script files with the same name found in bundle: test');
318
- });
319
- it('can handle multiple script files with the same name in different directories', () => {
320
- const bundleSrcFileMap = {
321
- 'test.js': {},
322
- 'subdir/test.ts': {},
323
- 'test.html': {},
324
- };
325
- const input = {
326
- moduleInfo: {
327
- name: 'test',
328
- namespace: 'c',
329
- type: 'bundle',
330
- files: bundleSrcFileMap,
331
- },
332
- srcFileMap: {
333
- 'test.js': 'export default class Test {}',
334
- 'subdir/test.ts': 'export default class Test {}',
335
- 'test.html': '<template><div>Test</div></template>',
336
- 'test.css': 'p { text-align: center; }',
337
- },
338
- };
339
- const res = (0, __1.generateKomaciModule)(input);
340
- expect(res).not.toContain('ErrorFunction');
341
- expect(res).toContain('registerAdgFunction');
342
- });
343
- it('can handle multiple script files with different names in same directory', () => {
344
- const testJsSource = `export default class Test extends LightningElement {
345
- get testProp() {
346
- return 'test';
347
- }
348
- }`;
349
- const fooTsSource = `export default class Foo {
350
- get fooProp() {
351
- return 'foo';
352
- }
353
- }`;
354
- const bundleConfig = {
355
- namespace: 'c',
356
- name: 'test',
357
- type: 'internal',
358
- files: [
359
- { fileName: 'test.js', source: testJsSource },
360
- { fileName: 'foo.ts', source: fooTsSource },
361
- { fileName: 'test.html', source: '<template><div>Test</div></template>' },
362
- { fileName: 'test.css', source: 'p { text-align: center; }' },
363
- ],
364
- enableKomaci: true,
365
- namespaceMapping: {},
366
- npmModuleMapping: {},
367
- };
368
- const metadata = (0, metadata_1.collectBundleMetadata)(bundleConfig);
369
- const inputFiles = Object.fromEntries(metadata.files
370
- .map(({ fileName, komaciDoc }) => [fileName, komaciDoc])
371
- .filter(([, komaciDoc]) => !!komaciDoc));
372
- const input = {
373
- moduleInfo: {
374
- name: 'test',
375
- namespace: 'c',
376
- type: 'bundle',
377
- files: inputFiles,
378
- },
379
- srcFileMap: {
380
- 'test.js': testJsSource,
381
- 'foo.ts': fooTsSource,
382
- 'test.html': '<template><div>Test</div></template>',
383
- 'test.css': 'p { text-align: center; }',
384
- },
385
- };
386
- const res = (0, __1.generateKomaciModule)(input);
387
- expect(res).not.toContain('ErrorFunction');
388
- expect(res).toContain('registerAdgFunction');
389
- expect(res).toContain('testProp');
390
- expect(res).not.toContain('fooProp');
391
- });
392
- });
393
- //# sourceMappingURL=index.spec.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=komaci-ast-unit.spec.d.ts.map