@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.
- package/build/genericAstGeneration.js +80 -34
- package/package.json +1 -1
- package/build/__tests__/adgAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/adgAstGeneration.spec.js +0 -447
- package/build/__tests__/compile-generated-module-fixtures.spec.d.ts +0 -2
- package/build/__tests__/compile-generated-module-fixtures.spec.js +0 -49
- package/build/__tests__/compilerConfigs.d.ts +0 -24
- package/build/__tests__/compilerConfigs.js +0 -126
- package/build/__tests__/compositionAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/compositionAstGeneration.spec.js +0 -676
- package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/exclude-comps-unused-import-prop/actual.js +0 -28
- package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.d.ts +0 -29
- package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.js +0 -148
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.d.ts +0 -9
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-one/actual.js +0 -35
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.d.ts +0 -10
- package/build/__tests__/fixtures-combined-files/exclude-total-unused-import-getter-from-two/actual.js +0 -39
- package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-combined-files/exclude-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-combined-files/image-type/actual.d.ts +0 -13
- package/build/__tests__/fixtures-combined-files/image-type/actual.js +0 -41
- package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.d.ts +0 -14
- package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.js +0 -79
- package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.d.ts +0 -18
- package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.js +0 -103
- package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/include-comps-used-import-prop/actual.js +0 -28
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-imports/actual.js +0 -16
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.d.ts +0 -4
- package/build/__tests__/fixtures-combined-files/include-salesforce-resourceUrl-nonAnalyzable-imports/actual.js +0 -18
- package/build/__tests__/fixtures-combined-files/include-template-strings/actual.d.ts +0 -10
- package/build/__tests__/fixtures-combined-files/include-template-strings/actual.js +0 -41
- package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.d.ts +0 -9
- package/build/__tests__/fixtures-combined-files/include-used-import-getter/actual.js +0 -38
- package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-combined-files/include-wire-used-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.d.ts +0 -1
- package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.js +0 -2
- package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
- package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.d.ts +0 -5
- package/build/__tests__/fixtures-combined-files-multiple-templates/invalid-renderFunc-no-valid-imports/c/component/component.js +0 -14
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-complex/lightning/component/component.js +0 -31
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.d.ts +0 -6
- package/build/__tests__/fixtures-combined-files-multiple-templates/valid-render-function-simple/lightning/component/component.js +0 -27
- package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.d.ts +0 -15
- package/build/__tests__/fixtures-gql/multipleGqlQueries/c/component/component.js +0 -104
- package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.d.ts +0 -8
- package/build/__tests__/fixtures-script-files/class-extends-multiple-with-separate-imports/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports/actual.js +0 -13
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/class-extends-separate-imports-alias/actual.js +0 -10
- package/build/__tests__/fixtures-script-files/class-props/actual.d.ts +0 -30
- package/build/__tests__/fixtures-script-files/class-props/actual.js +0 -103
- package/build/__tests__/fixtures-script-files/empty-class/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/empty-class/actual.js +0 -7
- package/build/__tests__/fixtures-script-files/empty-doc/actual.d.ts +0 -1
- package/build/__tests__/fixtures-script-files/empty-doc/actual.js +0 -2
- package/build/__tests__/fixtures-script-files/empty-wire/actual.d.ts +0 -5
- package/build/__tests__/fixtures-script-files/empty-wire/actual.js +0 -16
- package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-script-files/exclude-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-script-files/exports/actual.d.ts +0 -22
- package/build/__tests__/fixtures-script-files/exports/actual.js +0 -63
- package/build/__tests__/fixtures-script-files/imports/actual.d.ts +0 -11
- package/build/__tests__/fixtures-script-files/imports/actual.js +0 -80
- package/build/__tests__/fixtures-script-files/imports-namespaced/actual.d.ts +0 -10
- package/build/__tests__/fixtures-script-files/imports-namespaced/actual.js +0 -63
- package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.d.ts +0 -7
- package/build/__tests__/fixtures-script-files/include-wire-unused-import-prop/actual.js +0 -34
- package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.d.ts +0 -3
- package/build/__tests__/fixtures-script-files/inheritance-imports-default/actual.js +0 -10
- package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.d.ts +0 -9
- package/build/__tests__/fixtures-script-files/inheritance-imports-local/actual.js +0 -24
- package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/inheritance-imports-named/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.d.ts +0 -4
- package/build/__tests__/fixtures-script-files/inheritance-parent-unresolved/actual.js +0 -17
- package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.d.ts +0 -6
- package/build/__tests__/fixtures-script-files/unsupported-wire-from-supported-namespace/actual.js +0 -19
- package/build/__tests__/fixtures-script-files/wire-basic/actual.d.ts +0 -8
- package/build/__tests__/fixtures-script-files/wire-basic/actual.js +0 -30
- package/build/__tests__/fixtures-script-files/wire-functions/actual.d.ts +0 -13
- package/build/__tests__/fixtures-script-files/wire-functions/actual.js +0 -46
- package/build/__tests__/fixtures-script-files/wire-imports/actual.d.ts +0 -11
- package/build/__tests__/fixtures-script-files/wire-imports/actual.js +0 -63
- package/build/__tests__/fixtures-source-code/badImportRef.d.ts +0 -4
- package/build/__tests__/fixtures-source-code/badImportRef.js +0 -31
- package/build/__tests__/fixtures-source-code/generalMockSourceCode.d.ts +0 -8
- package/build/__tests__/fixtures-source-code/generalMockSourceCode.js +0 -127
- package/build/__tests__/fixtures-source-code/gqlMockSource.d.ts +0 -3
- package/build/__tests__/fixtures-source-code/gqlMockSource.js +0 -95
- package/build/__tests__/functionAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/functionAstGeneration.spec.js +0 -727
- package/build/__tests__/general-komaci-docs/assorted-template-strings/source.d.ts +0 -10
- package/build/__tests__/general-komaci-docs/assorted-template-strings/source.js +0 -41
- package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.d.ts +0 -7
- package/build/__tests__/general-komaci-docs/getters-and-compositions-collisions/source.js +0 -31
- package/build/__tests__/general-komaci-docs/import-types/source.d.ts +0 -18
- package/build/__tests__/general-komaci-docs/import-types/source.js +0 -108
- package/build/__tests__/general-komaci-docs/import-types/validationStuff.d.ts +0 -18
- package/build/__tests__/general-komaci-docs/import-types/validationStuff.js +0 -63
- package/build/__tests__/general-komaci-docs/template-component/source.d.ts +0 -8
- package/build/__tests__/general-komaci-docs/template-component/source.js +0 -34
- package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.d.ts +0 -2
- package/build/__tests__/generated-module/compile-graphql-with-scoped-import.spec.js +0 -20
- package/build/__tests__/generated-module/lightning/component/component.d.ts +0 -18
- package/build/__tests__/generated-module/lightning/component/component.js +0 -168
- package/build/__tests__/genericAstGeneration.spec.d.ts +0 -2
- package/build/__tests__/genericAstGeneration.spec.js +0 -1052
- package/build/__tests__/index.spec.d.ts +0 -2
- package/build/__tests__/index.spec.js +0 -393
- package/build/__tests__/komaci-ast-unit.spec.d.ts +0 -2
- package/build/__tests__/komaci-ast-unit.spec.js +0 -422
- package/build/__tests__/komaci-bundle-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-bundle-module.fixtures.spec.js +0 -76
- package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-bundle-multiple-templates-module.fixtures.spec.js +0 -117
- package/build/__tests__/komaci-gql.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-gql.fixtures.spec.js +0 -51
- package/build/__tests__/komaci-script-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-script-module.fixtures.spec.js +0 -70
- package/build/__tests__/komaci-template-module.fixtures.spec.d.ts +0 -2
- package/build/__tests__/komaci-template-module.fixtures.spec.js +0 -57
- package/build/__tests__/readAndParseBundle.d.ts +0 -22
- package/build/__tests__/readAndParseBundle.js +0 -80
|
@@ -123,7 +123,7 @@ function generateResolvableModule(input, scriptKomaciDoc, templateKomaciDocMap,
|
|
|
123
123
|
}
|
|
124
124
|
// for script only docs we assume there there is still a html file around so we build the import to reference that html
|
|
125
125
|
if (!isBundle && hasScriptKomaciDoc && !hasTemplateKomaciDoc) {
|
|
126
|
-
const newImport = (0, common_shared_1.composeImportMetadata)('default', `@salesforce/komaci/${input.moduleInfo.namespace}__${input.moduleInfo.name}__${input.moduleInfo.name}.html`, true, common_shared_1.NO_KOMACI_DOC_REF, moduleMetadata, common_shared_1.IdKeys.DEFAULT_COMP);
|
|
126
|
+
const newImport = (0, common_shared_1.composeImportMetadata)('default', `@salesforce/komaci/${input.moduleInfo.namespace}__${input.moduleInfo.name}__${input.moduleInfo.name}.html`, true, common_shared_1.NO_KOMACI_DOC_REF, moduleMetadata, common_shared_1.IdKeys.DEFAULT_COMP, false);
|
|
127
127
|
newImport.usedInPriming = true;
|
|
128
128
|
newImport.isFromSupportedLibrary = true;
|
|
129
129
|
newImport.generatorAlias = 'comp1';
|
|
@@ -215,6 +215,27 @@ function generateResolvableModule(input, scriptKomaciDoc, templateKomaciDocMap,
|
|
|
215
215
|
return file;
|
|
216
216
|
}
|
|
217
217
|
exports.generateResolvableModule = generateResolvableModule;
|
|
218
|
+
/**
|
|
219
|
+
* Builds a single import declaration. If every specifier is type-only the declaration
|
|
220
|
+
* uses the decl-level `import type` form; if only some are type-only, the inline
|
|
221
|
+
* `type` modifier is applied per ImportSpecifier.
|
|
222
|
+
*/
|
|
223
|
+
function buildImportDeclaration(entries, resourceName) {
|
|
224
|
+
const specifiers = entries.map((e) => e.specifier);
|
|
225
|
+
const importDeclaration = t.importDeclaration(specifiers, t.stringLiteral(resourceName));
|
|
226
|
+
const allTypeOnly = entries.length > 0 && entries.every((e) => e.isTypeOnly);
|
|
227
|
+
if (allTypeOnly) {
|
|
228
|
+
importDeclaration.importKind = 'type';
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
entries.forEach((entry) => {
|
|
232
|
+
if (entry.isTypeOnly && entry.specifier.type === 'ImportSpecifier') {
|
|
233
|
+
entry.specifier.importKind = 'type';
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return importDeclaration;
|
|
238
|
+
}
|
|
218
239
|
/**
|
|
219
240
|
* Adds a babel import decleration to the AST for each Komaci import
|
|
220
241
|
*
|
|
@@ -228,6 +249,7 @@ exports.generateResolvableModule = generateResolvableModule;
|
|
|
228
249
|
function addImportStatements(moduleMetadata, statements, options) {
|
|
229
250
|
if (moduleMetadata.importsByName.size > 0) {
|
|
230
251
|
const seenImports = new Set();
|
|
252
|
+
// Sort by resourceName for deterministic output order in the generated ADG.
|
|
231
253
|
const imports = Array.from(moduleMetadata.importsByName.values())
|
|
232
254
|
.sort((a, b) => {
|
|
233
255
|
if (a.resourceName < b.resourceName) {
|
|
@@ -242,52 +264,76 @@ function addImportStatements(moduleMetadata, statements, options) {
|
|
|
242
264
|
})
|
|
243
265
|
.filter((value) => {
|
|
244
266
|
// sometimes we can have multiple import names mapped to the same import. so we want to dedup those before running them through composition
|
|
267
|
+
// always include type imports
|
|
245
268
|
const isComposable = !seenImports.has(value.generatorAlias) &&
|
|
246
269
|
value.isFromInternalNamespace &&
|
|
247
|
-
value.usedInPriming;
|
|
270
|
+
(value.usedInPriming || value.isTypeOnly);
|
|
248
271
|
if (isComposable) {
|
|
249
272
|
seenImports.add(value.generatorAlias);
|
|
250
273
|
}
|
|
251
274
|
return isComposable;
|
|
252
275
|
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
276
|
+
// We can't use the standard groupBy helper until we update ES version target.
|
|
277
|
+
const importsByResource = new Map();
|
|
278
|
+
for (const imp of imports) {
|
|
279
|
+
const group = importsByResource.get(imp.resourceName) ?? [];
|
|
280
|
+
group.push(imp);
|
|
281
|
+
importsByResource.set(imp.resourceName, group);
|
|
282
|
+
}
|
|
283
|
+
for (const [originalResourceName, group] of importsByResource) {
|
|
284
|
+
if (!(0, static_analyzer_1.isSupportedNamespace)(originalResourceName)) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
// Partition all specifiers for this resource into the three ES grammar
|
|
288
|
+
// buckets so we can emit only the legal combined forms below.
|
|
289
|
+
//
|
|
290
|
+
// The metadata layer (collectImportMetadataFromAst + findOtherAlias) collapses
|
|
291
|
+
// multiple aliases of the same exported binding to a single ImportMetadata,
|
|
292
|
+
// and the dedup pass above strips duplicates by `generatorAlias`, so we are
|
|
293
|
+
// guaranteed at most one default and at most one namespace per resource here.
|
|
294
|
+
let defaultSpecifier;
|
|
295
|
+
let namespaceSpecifier;
|
|
296
|
+
const namedSpecifiers = [];
|
|
297
|
+
for (const imp of group) {
|
|
298
|
+
const localName = t.identifier(imp.generatorAlias);
|
|
299
|
+
const exportName = imp.name;
|
|
262
300
|
if (exportName === 'default') {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
301
|
+
defaultSpecifier = {
|
|
302
|
+
specifier: t.importDefaultSpecifier(localName),
|
|
303
|
+
isTypeOnly: imp.isTypeOnly,
|
|
304
|
+
};
|
|
266
305
|
}
|
|
267
|
-
else if (exportName === '*'
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
306
|
+
else if (exportName === '*') {
|
|
307
|
+
namespaceSpecifier = {
|
|
308
|
+
specifier: t.importNamespaceSpecifier(localName),
|
|
309
|
+
isTypeOnly: imp.isTypeOnly,
|
|
310
|
+
};
|
|
272
311
|
}
|
|
273
312
|
else {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
313
|
+
namedSpecifiers.push({
|
|
314
|
+
specifier: t.importSpecifier(localName, t.identifier(exportName)),
|
|
315
|
+
isTypeOnly: imp.isTypeOnly,
|
|
316
|
+
});
|
|
278
317
|
}
|
|
279
|
-
i++;
|
|
280
318
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
319
|
+
let resourceName = originalResourceName;
|
|
320
|
+
if (options.isComposingFromBundle &&
|
|
321
|
+
resourceName.startsWith('@salesforce/komaci')) {
|
|
322
|
+
// @salesforce/komaci/c__foo__foo.js -> @salesforce/komaci/c__foo
|
|
323
|
+
const lastIndex = resourceName.lastIndexOf('__');
|
|
324
|
+
resourceName = resourceName.slice(0, lastIndex);
|
|
325
|
+
}
|
|
326
|
+
// Emit each bucket as its own declaration in default -> namespace -> named order.
|
|
327
|
+
// We could be clever and merge certain combinations of import lines which would
|
|
328
|
+
// be legal grammar, but logic simplicity is better for maintainability.
|
|
329
|
+
if (defaultSpecifier) {
|
|
330
|
+
statements.push(buildImportDeclaration([defaultSpecifier], resourceName));
|
|
331
|
+
}
|
|
332
|
+
if (namespaceSpecifier) {
|
|
333
|
+
statements.push(buildImportDeclaration([namespaceSpecifier], resourceName));
|
|
334
|
+
}
|
|
335
|
+
if (namedSpecifiers.length > 0) {
|
|
336
|
+
statements.push(buildImportDeclaration(namedSpecifiers, resourceName));
|
|
291
337
|
}
|
|
292
338
|
}
|
|
293
339
|
}
|
package/package.json
CHANGED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const common_shared_1 = require("@komaci/common-shared");
|
|
4
|
-
const metadata_1 = require("@lwc/metadata");
|
|
5
|
-
const functionAstGeneration_1 = require("../functionAstGeneration");
|
|
6
|
-
const index_1 = require("../index");
|
|
7
|
-
describe('getAdgFunctionBody', () => {
|
|
8
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
9
|
-
it('includes a statement for factory functions if needed', () => {
|
|
10
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
11
|
-
adg.requiredAdgFactoryFunctions.add(common_shared_1.IdKeys.ADG_FUNC);
|
|
12
|
-
const res = (0, functionAstGeneration_1.getAdgFunctionBody)(adg, moduleMetadata);
|
|
13
|
-
expect(res.body).toHaveLength(2);
|
|
14
|
-
expect(res.body[0].type).toBe('VariableDeclaration');
|
|
15
|
-
expect(res.body[1].type).toBe('ReturnStatement');
|
|
16
|
-
});
|
|
17
|
-
it('only contains a return statement if no factory functions are needed', () => {
|
|
18
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
19
|
-
adg.requiredAdgFactoryFunctions.delete(common_shared_1.IdKeys.ADG_FUNC);
|
|
20
|
-
const res = (0, functionAstGeneration_1.getAdgFunctionBody)(adg, moduleMetadata);
|
|
21
|
-
expect(res.body).toHaveLength(1);
|
|
22
|
-
expect(res.body[0].type).toBe('ReturnStatement');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe('composeAdgFunction', () => {
|
|
26
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
27
|
-
it('can return a function declaration for a non exported function', () => {
|
|
28
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
29
|
-
const res = (0, functionAstGeneration_1.composeAdgFunction)(adg, moduleMetadata);
|
|
30
|
-
expect(res.type).toBe('FunctionDeclaration');
|
|
31
|
-
expect(res.id.name).toBe('adg0');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('composeAdgStaticMetadata', () => {
|
|
35
|
-
it('creates a static metadata object', () => {
|
|
36
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
37
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
38
|
-
adg.exportName = 'default';
|
|
39
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
40
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
41
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
42
|
-
const varDeclarator = res.declarations[0];
|
|
43
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
44
|
-
const properties = varDeclarator.init.properties;
|
|
45
|
-
expect(properties).toHaveLength(4);
|
|
46
|
-
expect(properties[0].value.value).toBe('c-test-comp');
|
|
47
|
-
});
|
|
48
|
-
it('creates a static metadata object for non default export', () => {
|
|
49
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
50
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg1');
|
|
51
|
-
adg.exportName = 'base';
|
|
52
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
53
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
54
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
55
|
-
const varDeclarator = res.declarations[0];
|
|
56
|
-
expect(varDeclarator.id.name).toBe('adg1Meta');
|
|
57
|
-
const properties = varDeclarator.init.properties;
|
|
58
|
-
expect(properties).toHaveLength(4);
|
|
59
|
-
expect(properties[0].value.value).toBe('c-test-comp__base');
|
|
60
|
-
});
|
|
61
|
-
describe('static metadata for component with image', () => {
|
|
62
|
-
const enablePropMetadata = [false, true];
|
|
63
|
-
for (const propMetadataEnabled of enablePropMetadata) {
|
|
64
|
-
it(`creates a static metadata object with child metadata ${propMetadataEnabled ? 'with props' : 'WITHOUT props'} and true for img`, () => {
|
|
65
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
66
|
-
if (propMetadataEnabled) {
|
|
67
|
-
moduleMetadata.includePropsMetadata = true;
|
|
68
|
-
}
|
|
69
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
70
|
-
adg.exportName = 'default';
|
|
71
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
72
|
-
adg.compositionRootIndex = 0;
|
|
73
|
-
adg.compositions = [
|
|
74
|
-
{
|
|
75
|
-
type: 'Container',
|
|
76
|
-
compositions: [
|
|
77
|
-
{
|
|
78
|
-
type: 'ComposedAdg',
|
|
79
|
-
input: { type: 'ImportReference', value: 'test' },
|
|
80
|
-
properties: {
|
|
81
|
-
attr1: { type: 'Binding', value: 'input1' },
|
|
82
|
-
attr2: { type: 'Binding', value: 'input2' },
|
|
83
|
-
attr3: { type: 'PrimitiveValue', value: 'Literal!' },
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
type: 'Image',
|
|
88
|
-
src: { type: 'Binding', value: 'input1' },
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
moduleMetadata.importIndexReference.set('test', 'import1');
|
|
94
|
-
moduleMetadata.importsByName.set('import1', {
|
|
95
|
-
generatorAlias: 'i0',
|
|
96
|
-
name: '',
|
|
97
|
-
resourceName: '',
|
|
98
|
-
komaciDocImportRef: '',
|
|
99
|
-
isFromInternalNamespace: false,
|
|
100
|
-
isFromSupportedLibrary: false,
|
|
101
|
-
usedInPriming: false,
|
|
102
|
-
staticallyAnalyzable: false,
|
|
103
|
-
});
|
|
104
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
105
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
106
|
-
const varDeclarator = res.declarations[0];
|
|
107
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
108
|
-
const properties = varDeclarator.init.properties;
|
|
109
|
-
expect(properties).toHaveLength(4);
|
|
110
|
-
expect(properties[0].value.value).toBe('c-test-comp');
|
|
111
|
-
expect(properties[1].value
|
|
112
|
-
.properties[0].value.type).toBe('ArrayExpression');
|
|
113
|
-
const childMetaArr = properties[1].value
|
|
114
|
-
.properties[0].value;
|
|
115
|
-
expect(childMetaArr.elements).toHaveLength(2);
|
|
116
|
-
// should have two elements, one for the adg ("a") and another for the props ("p")
|
|
117
|
-
// when propMetadata enabled; otherwise only 1 for the adg ("a")
|
|
118
|
-
const expectedNumElementsForChildMetadata = propMetadataEnabled ? 2 : 1;
|
|
119
|
-
expect(childMetaArr.elements[0].properties).toHaveLength(expectedNumElementsForChildMetadata);
|
|
120
|
-
expect(childMetaArr.elements[1].properties).toHaveLength(1);
|
|
121
|
-
expect(childMetaArr.elements[0].properties).toHaveLength(expectedNumElementsForChildMetadata);
|
|
122
|
-
const prop1 = childMetaArr.elements[0]
|
|
123
|
-
.properties[0];
|
|
124
|
-
expect(prop1.value.name).toEqual('i0');
|
|
125
|
-
const prop2 = childMetaArr.elements[0]
|
|
126
|
-
.properties[1];
|
|
127
|
-
if (propMetadataEnabled) {
|
|
128
|
-
expect(prop2.value.properties).toHaveLength(3);
|
|
129
|
-
const propObj = prop2.value.properties[0].value;
|
|
130
|
-
expect(propObj.properties[1].value
|
|
131
|
-
.value).toEqual('input1');
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// no prop metadata if propMetadata is false
|
|
135
|
-
expect(prop2).toBeUndefined();
|
|
136
|
-
}
|
|
137
|
-
expect(childMetaArr.elements[1].properties).toHaveLength(1);
|
|
138
|
-
expect(properties[3].value.value).toBeTruthy();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
it('static meta data object has true for PF', () => {
|
|
143
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
144
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
145
|
-
adg.exportName = 'default';
|
|
146
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
147
|
-
adg.compositionRootIndex = 0;
|
|
148
|
-
const primingFunction = {
|
|
149
|
-
requiredProperties: [],
|
|
150
|
-
importReference: { functionName: 'test' },
|
|
151
|
-
type: common_shared_1.FunctionTypes.PRIMING_FUNCTION,
|
|
152
|
-
};
|
|
153
|
-
adg.functions.push(primingFunction);
|
|
154
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
155
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
156
|
-
const varDeclarator = res.declarations[0];
|
|
157
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
158
|
-
const properties = varDeclarator.init.properties;
|
|
159
|
-
expect(properties).toHaveLength(4);
|
|
160
|
-
expect(properties[0].value.value).toBe('c-test-comp');
|
|
161
|
-
expect(properties[2].value.value).toBeTruthy();
|
|
162
|
-
});
|
|
163
|
-
it('static meta data object has true for PF for wire function', () => {
|
|
164
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
165
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
166
|
-
adg.exportName = 'default';
|
|
167
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
168
|
-
adg.compositionRootIndex = 0;
|
|
169
|
-
const primingFunction = {
|
|
170
|
-
requiredProperties: [],
|
|
171
|
-
importReference: { functionName: 'test' },
|
|
172
|
-
type: common_shared_1.FunctionTypes.WIRE_FUNCTION,
|
|
173
|
-
};
|
|
174
|
-
adg.functions.push(primingFunction);
|
|
175
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
176
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
177
|
-
const varDeclarator = res.declarations[0];
|
|
178
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
179
|
-
const properties = varDeclarator.init.properties;
|
|
180
|
-
expect(properties).toHaveLength(4);
|
|
181
|
-
expect(properties[0].value.value).toBe('c-test-comp');
|
|
182
|
-
expect(properties[2].value.value).toBeTruthy();
|
|
183
|
-
});
|
|
184
|
-
it('static meta data object has false for PF for getter', () => {
|
|
185
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
186
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
187
|
-
adg.exportName = 'default';
|
|
188
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
189
|
-
adg.compositionRootIndex = 0;
|
|
190
|
-
const primingFunction = {
|
|
191
|
-
requiredProperties: [],
|
|
192
|
-
type: common_shared_1.FunctionTypes.GETTER_FUNCTION,
|
|
193
|
-
};
|
|
194
|
-
adg.functions.push(primingFunction);
|
|
195
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
196
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
197
|
-
const varDeclarator = res.declarations[0];
|
|
198
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
199
|
-
const properties = varDeclarator.init.properties;
|
|
200
|
-
expect(properties).toHaveLength(4);
|
|
201
|
-
expect(properties[0].value.value).toBe('c-test-comp');
|
|
202
|
-
expect(properties[2].value.value).toBeFalsy();
|
|
203
|
-
});
|
|
204
|
-
it('Correct id for non exported class', () => {
|
|
205
|
-
const moduleMetadata = (0, common_shared_1.initModuleMetadataObject)();
|
|
206
|
-
const adg = (0, common_shared_1.initAdgMetadataObject)('adg0');
|
|
207
|
-
moduleMetadata.staticMetadataId = 'c-test-comp';
|
|
208
|
-
adg.compositionRootIndex = 0;
|
|
209
|
-
const primingFunction = {
|
|
210
|
-
requiredProperties: [],
|
|
211
|
-
type: common_shared_1.FunctionTypes.GETTER_FUNCTION,
|
|
212
|
-
};
|
|
213
|
-
adg.functions.push(primingFunction);
|
|
214
|
-
const res = (0, functionAstGeneration_1.composeAdgStaticMetadata)(adg, moduleMetadata);
|
|
215
|
-
expect(res.type).toBe('VariableDeclaration');
|
|
216
|
-
const varDeclarator = res.declarations[0];
|
|
217
|
-
expect(varDeclarator.id.name).toBe('adg0Meta');
|
|
218
|
-
const properties = varDeclarator.init.properties;
|
|
219
|
-
expect(properties).toHaveLength(4);
|
|
220
|
-
expect(properties[0].value.value).toBe('c-test-comp__$nonExportedClass$');
|
|
221
|
-
expect(properties[2].value.value).toBeFalsy();
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
describe('Actual TypeScript File Processing', () => {
|
|
225
|
-
it('includes .ts files when reading bundles', () => {
|
|
226
|
-
const testFiles = [
|
|
227
|
-
'component.js',
|
|
228
|
-
'component.ts',
|
|
229
|
-
'component.html',
|
|
230
|
-
'component.css',
|
|
231
|
-
'other.txt',
|
|
232
|
-
];
|
|
233
|
-
const LWC_EXT = ['.js', '.mjs', '.css', '.html', '.ts'];
|
|
234
|
-
const filtered = testFiles.filter((filename) => {
|
|
235
|
-
return LWC_EXT.some((ext) => filename.endsWith(ext));
|
|
236
|
-
});
|
|
237
|
-
expect(filtered).toContain('component.ts');
|
|
238
|
-
expect(filtered).not.toContain('other.txt');
|
|
239
|
-
});
|
|
240
|
-
// Test with actual TypeScript syntax
|
|
241
|
-
it('processes TypeScript files with type annotations', () => {
|
|
242
|
-
const typescriptSource = `
|
|
243
|
-
import { LightningElement, api } from 'lwc';
|
|
244
|
-
|
|
245
|
-
interface User {
|
|
246
|
-
id: string;
|
|
247
|
-
name: string;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export default class TypeScriptComponent extends LightningElement {
|
|
251
|
-
@api recordId: string;
|
|
252
|
-
private users: User[] = [];
|
|
253
|
-
|
|
254
|
-
get userCount(): number {
|
|
255
|
-
return this.users.length;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
handleUserUpdate(user: User): void {
|
|
259
|
-
this.users = [...this.users, user];
|
|
260
|
-
}
|
|
261
|
-
}`;
|
|
262
|
-
// Create a proper KomaciDocument structure
|
|
263
|
-
const komaciDoc = {
|
|
264
|
-
adgs: [{}],
|
|
265
|
-
exports: {
|
|
266
|
-
default: {
|
|
267
|
-
type: 'AdgReference',
|
|
268
|
-
value: 0,
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
expect(() => {
|
|
273
|
-
const input = {
|
|
274
|
-
moduleInfo: {
|
|
275
|
-
name: 'typeScriptComponent',
|
|
276
|
-
namespace: 'c',
|
|
277
|
-
type: 'file',
|
|
278
|
-
fileName: 'typeScriptComponent.ts',
|
|
279
|
-
komaciDoc,
|
|
280
|
-
},
|
|
281
|
-
srcFileMap: {
|
|
282
|
-
'typeScriptComponent.ts': typescriptSource,
|
|
283
|
-
},
|
|
284
|
-
};
|
|
285
|
-
(0, index_1.generateKomaciModule)(input);
|
|
286
|
-
}).not.toThrow();
|
|
287
|
-
});
|
|
288
|
-
// Test that ensures TypeScript-specific syntax is parsed correctly
|
|
289
|
-
it('handles TypeScript generics and interfaces', () => {
|
|
290
|
-
const typescriptGenericSource = `
|
|
291
|
-
import { LightningElement } from 'lwc';
|
|
292
|
-
|
|
293
|
-
interface ApiResponse<T> {
|
|
294
|
-
data: T;
|
|
295
|
-
success: boolean;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export default class GenericComponent<T = any> extends LightningElement {
|
|
299
|
-
private cache: Map<string, ApiResponse<T>> = new Map();
|
|
300
|
-
|
|
301
|
-
get cacheSize(): number {
|
|
302
|
-
return this.cache.size;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
processResponse<U extends T>(response: ApiResponse<U>): U | null {
|
|
306
|
-
if (response.success) {
|
|
307
|
-
return response.data;
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
}`;
|
|
312
|
-
// Create a proper KomaciDocument structure
|
|
313
|
-
const komaciDoc = {
|
|
314
|
-
adgs: [{}],
|
|
315
|
-
exports: {
|
|
316
|
-
default: {
|
|
317
|
-
type: 'AdgReference',
|
|
318
|
-
value: 0,
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
expect(() => {
|
|
323
|
-
const input = {
|
|
324
|
-
moduleInfo: {
|
|
325
|
-
name: 'genericComponent',
|
|
326
|
-
namespace: 'c',
|
|
327
|
-
type: 'file',
|
|
328
|
-
fileName: 'genericComponent.ts',
|
|
329
|
-
komaciDoc,
|
|
330
|
-
},
|
|
331
|
-
srcFileMap: {
|
|
332
|
-
'genericComponent.ts': typescriptGenericSource,
|
|
333
|
-
},
|
|
334
|
-
};
|
|
335
|
-
(0, index_1.generateKomaciModule)(input);
|
|
336
|
-
}).not.toThrow();
|
|
337
|
-
});
|
|
338
|
-
// Test bundle processing with .ts files
|
|
339
|
-
it('processes bundles containing TypeScript files', () => {
|
|
340
|
-
const bundleFiles = [
|
|
341
|
-
{
|
|
342
|
-
fileName: 'component.ts',
|
|
343
|
-
source: `
|
|
344
|
-
import { LightningElement, api } from 'lwc';
|
|
345
|
-
|
|
346
|
-
export default class Component extends LightningElement {
|
|
347
|
-
@api recordId: string;
|
|
348
|
-
|
|
349
|
-
get displayName(): string {
|
|
350
|
-
return 'TypeScript Component';
|
|
351
|
-
}
|
|
352
|
-
}`,
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
fileName: 'component.html',
|
|
356
|
-
source: '<template><div>{displayName}</div></template>',
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
fileName: 'component.css',
|
|
360
|
-
source: 'div { color: blue; }',
|
|
361
|
-
},
|
|
362
|
-
];
|
|
363
|
-
// Test that bundles with .ts files are processed correctly
|
|
364
|
-
expect(() => {
|
|
365
|
-
const bundleConfig = {
|
|
366
|
-
namespace: 'c',
|
|
367
|
-
name: 'tsComponent',
|
|
368
|
-
type: 'internal',
|
|
369
|
-
namespaceMapping: {},
|
|
370
|
-
npmModuleMapping: {},
|
|
371
|
-
files: bundleFiles,
|
|
372
|
-
enableKomaci: true,
|
|
373
|
-
};
|
|
374
|
-
// This should work with .ts files
|
|
375
|
-
const metadata = (0, metadata_1.collectBundleMetadata)(bundleConfig);
|
|
376
|
-
expect(metadata.files.length).toBeGreaterThan(0);
|
|
377
|
-
const tsFile = metadata.files.find((f) => f.fileName === 'component.ts');
|
|
378
|
-
expect(tsFile).toBeDefined();
|
|
379
|
-
expect(tsFile?.komaciDoc).toBeDefined();
|
|
380
|
-
// Now verify the full ADG generation path works with TypeScript bundle
|
|
381
|
-
const srcFileMap = bundleFiles.reduce((map, { fileName, source }) => ({ ...map, [fileName]: source }), {});
|
|
382
|
-
const inputFiles = Object.fromEntries(metadata.files
|
|
383
|
-
.map(({ fileName, komaciDoc }) => [fileName, komaciDoc])
|
|
384
|
-
.filter(([, komaciDoc]) => !!komaciDoc));
|
|
385
|
-
const generatorInput = {
|
|
386
|
-
moduleInfo: {
|
|
387
|
-
name: bundleConfig.name,
|
|
388
|
-
namespace: bundleConfig.namespace,
|
|
389
|
-
type: 'bundle',
|
|
390
|
-
files: inputFiles,
|
|
391
|
-
},
|
|
392
|
-
srcFileMap,
|
|
393
|
-
};
|
|
394
|
-
// This exercises the full code path including the fix at line ~134
|
|
395
|
-
const result = (0, index_1.generateKomaciModule)(generatorInput);
|
|
396
|
-
// The result should be valid JavaScript and not an error
|
|
397
|
-
expect(result).not.toContain('ErrorFunction');
|
|
398
|
-
expect(result).not.toContain('unsupported file extension');
|
|
399
|
-
}).not.toThrow();
|
|
400
|
-
});
|
|
401
|
-
// Test that verifies the file extension is properly detected
|
|
402
|
-
it('detects TypeScript files by .ts extension', () => {
|
|
403
|
-
// Create a proper KomaciDocument structure
|
|
404
|
-
const komaciDoc = {
|
|
405
|
-
adgs: [{}],
|
|
406
|
-
exports: {
|
|
407
|
-
default: {
|
|
408
|
-
type: 'AdgReference',
|
|
409
|
-
value: 0,
|
|
410
|
-
},
|
|
411
|
-
},
|
|
412
|
-
};
|
|
413
|
-
const input = {
|
|
414
|
-
moduleInfo: {
|
|
415
|
-
name: 'test',
|
|
416
|
-
namespace: 'c',
|
|
417
|
-
type: 'file',
|
|
418
|
-
fileName: 'test.ts',
|
|
419
|
-
komaciDoc,
|
|
420
|
-
},
|
|
421
|
-
srcFileMap: {
|
|
422
|
-
'test.ts': 'export default class Component {}',
|
|
423
|
-
},
|
|
424
|
-
};
|
|
425
|
-
// Verify the filename extension is preserved and recognized
|
|
426
|
-
expect(input.moduleInfo.fileName).toContain('.ts');
|
|
427
|
-
// The module generation should handle .ts files
|
|
428
|
-
expect(() => (0, index_1.generateKomaciModule)(input)).not.toThrow();
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
describe('TypeScript Parser Configuration', () => {
|
|
432
|
-
it('includes TypeScript plugin in Babel parser configuration', () => {
|
|
433
|
-
// This test ensures that when we fix the parser, it includes TS support
|
|
434
|
-
const typescriptCode = `
|
|
435
|
-
interface Props {
|
|
436
|
-
title: string;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export default class Component extends LightningElement {
|
|
440
|
-
@api title: string = '';
|
|
441
|
-
}`;
|
|
442
|
-
expect(() => {
|
|
443
|
-
(0, common_shared_1.generateAstFromSrcCode)(typescriptCode);
|
|
444
|
-
}).not.toThrow();
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
//# sourceMappingURL=adgAstGeneration.spec.js.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const glob_1 = require("glob");
|
|
9
|
-
const sfdc_lwc_compiler_1 = require("@lwc-platform/sfdc-lwc-compiler");
|
|
10
|
-
const compilerConfigs_1 = require("./compilerConfigs");
|
|
11
|
-
const EXPECTED_SRC_FILENAME = 'expected.src';
|
|
12
|
-
describe('fixtures', () => {
|
|
13
|
-
//Adding filter on the resolvable modules we try to compile until the compiler has been updated to handle imported gql queries. Will be removed in W-14269523
|
|
14
|
-
const fixtures = (0, glob_1.globSync)(path_1.default.resolve(__dirname, '**/expected.src')).filter((e) => !e.includes(`/fixtures-gql`));
|
|
15
|
-
for (const caseEntry of fixtures) {
|
|
16
|
-
const caseFolder = path_1.default.dirname(caseEntry);
|
|
17
|
-
const caseName = path_1.default.relative(__dirname, caseFolder);
|
|
18
|
-
const fixtureFilePath = (fileName) => {
|
|
19
|
-
return path_1.default.join(caseFolder, fileName);
|
|
20
|
-
};
|
|
21
|
-
const readFixtureFile = (fileName) => {
|
|
22
|
-
const filePath = fixtureFilePath(fileName);
|
|
23
|
-
return fs_1.default.existsSync(filePath) ? fs_1.default.readFileSync(filePath, 'utf-8') : null;
|
|
24
|
-
};
|
|
25
|
-
it(`${caseName}-komaci-module`, async () => {
|
|
26
|
-
const fileStr = readFixtureFile(EXPECTED_SRC_FILENAME);
|
|
27
|
-
expect(fileStr).not.toBeNull();
|
|
28
|
-
const files = { 'test.js': fileStr !== null ? fileStr : '' };
|
|
29
|
-
// Note: lockerConfig and compat outputConfig flags are mutually exclusive.
|
|
30
|
-
const result = await (0, sfdc_lwc_compiler_1.compile)({
|
|
31
|
-
bundle: {
|
|
32
|
-
name: 'test',
|
|
33
|
-
namespace: 'c',
|
|
34
|
-
type: 'internal',
|
|
35
|
-
files,
|
|
36
|
-
options: {
|
|
37
|
-
komaciOptions: {
|
|
38
|
-
enableKomaci: false,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
compilerConfigs: compilerConfigs_1.compilerConfigs,
|
|
43
|
-
});
|
|
44
|
-
expect(result.success).toBe(true);
|
|
45
|
-
expect(result.results).toHaveLength(compilerConfigs_1.compilerConfigs.length);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=compile-generated-module-fixtures.spec.js.map
|