@bleedingdev/modern-js-create 3.4.0-ultramodern.3 → 3.4.0-ultramodern.4
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/dist/cjs/ultramodern-workspace/demo-components.cjs +1 -1
- package/dist/cjs/ultramodern-workspace/effect-api.cjs +161 -30
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +12 -4
- package/dist/cjs/ultramodern-workspace/package-json.cjs +12 -1
- package/dist/esm/ultramodern-workspace/demo-components.js +1 -1
- package/dist/esm/ultramodern-workspace/effect-api.js +161 -30
- package/dist/esm/ultramodern-workspace/module-federation.js +12 -4
- package/dist/esm/ultramodern-workspace/package-json.js +12 -1
- package/dist/esm-node/ultramodern-workspace/demo-components.js +1 -1
- package/dist/esm-node/ultramodern-workspace/effect-api.js +161 -30
- package/dist/esm-node/ultramodern-workspace/module-federation.js +12 -4
- package/dist/esm-node/ultramodern-workspace/package-json.js +12 -1
- package/package.json +3 -3
- package/templates/app/ultramodern-route-head.tsx.handlebars +2 -2
- package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +29 -0
|
@@ -37,27 +37,51 @@ function serviceHasCheckoutCartState(service) {
|
|
|
37
37
|
function createCheckoutCartSharedSchemas(service) {
|
|
38
38
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
39
39
|
return `
|
|
40
|
-
export
|
|
40
|
+
export interface CheckoutCartLine {
|
|
41
|
+
readonly sku: string;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly quantity: number;
|
|
44
|
+
readonly unitPriceCents: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface CheckoutCart {
|
|
48
|
+
readonly lines: ReadonlyArray<CheckoutCartLine>;
|
|
49
|
+
readonly subtotalCents: number;
|
|
50
|
+
readonly totalQuantity: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface CheckoutAddCartItemPayload {
|
|
54
|
+
readonly sku: string;
|
|
55
|
+
readonly name?: string;
|
|
56
|
+
readonly quantity: number;
|
|
57
|
+
readonly unitPriceCents?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CheckoutRemoveCartItemPayload {
|
|
61
|
+
readonly sku: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const checkoutCartLineSchema: Schema.Schema<CheckoutCartLine> = Schema.Struct({
|
|
41
65
|
sku: Schema.String,
|
|
42
66
|
name: Schema.String,
|
|
43
67
|
quantity: Schema.Finite,
|
|
44
68
|
unitPriceCents: Schema.Finite,
|
|
45
69
|
});
|
|
46
70
|
|
|
47
|
-
export const checkoutCartSchema = Schema.Struct({
|
|
71
|
+
export const checkoutCartSchema: Schema.Schema<CheckoutCart> = Schema.Struct({
|
|
48
72
|
lines: Schema.Array(checkoutCartLineSchema),
|
|
49
73
|
subtotalCents: Schema.Finite,
|
|
50
74
|
totalQuantity: Schema.Finite,
|
|
51
75
|
});
|
|
52
76
|
|
|
53
|
-
export const checkoutAddCartItemPayloadSchema = Schema.Struct({
|
|
77
|
+
export const checkoutAddCartItemPayloadSchema: Schema.Schema<CheckoutAddCartItemPayload> = Schema.Struct({
|
|
54
78
|
sku: Schema.String,
|
|
55
79
|
name: Schema.optional(Schema.String),
|
|
56
80
|
quantity: Schema.Finite,
|
|
57
81
|
unitPriceCents: Schema.optional(Schema.Finite),
|
|
58
82
|
});
|
|
59
83
|
|
|
60
|
-
export const checkoutRemoveCartItemPayloadSchema = Schema.Struct({
|
|
84
|
+
export const checkoutRemoveCartItemPayloadSchema: Schema.Schema<CheckoutRemoveCartItemPayload> = Schema.Struct({
|
|
61
85
|
sku: Schema.String,
|
|
62
86
|
});
|
|
63
87
|
`;
|
|
@@ -210,6 +234,7 @@ function createCheckoutCartClientExports(service) {
|
|
|
210
234
|
const pascalStem = toPascalCase(stem);
|
|
211
235
|
const clientOptionsName = `${pascalStem}ClientOptions`;
|
|
212
236
|
const createClientName = `create${pascalStem}Client`;
|
|
237
|
+
const clientEffectTypeName = `${pascalStem}ClientEffect`;
|
|
213
238
|
return `
|
|
214
239
|
export interface CheckoutCartLine {
|
|
215
240
|
sku: string;
|
|
@@ -233,7 +258,7 @@ export interface CheckoutAddCartItemInput {
|
|
|
233
258
|
|
|
234
259
|
export const getCheckoutCart = (
|
|
235
260
|
options: ${clientOptionsName} = {},
|
|
236
|
-
) =>
|
|
261
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
237
262
|
${createClientName}({
|
|
238
263
|
...options,
|
|
239
264
|
operationContext:
|
|
@@ -245,7 +270,7 @@ export const getCheckoutCart = (
|
|
|
245
270
|
export const addCheckoutCartItem = (
|
|
246
271
|
payload: CheckoutAddCartItemInput,
|
|
247
272
|
options: ${clientOptionsName} = {},
|
|
248
|
-
) =>
|
|
273
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
249
274
|
${createClientName}({
|
|
250
275
|
...options,
|
|
251
276
|
operationContext:
|
|
@@ -259,7 +284,7 @@ export const addCheckoutCartItem = (
|
|
|
259
284
|
export const removeCheckoutCartItem = (
|
|
260
285
|
sku: string,
|
|
261
286
|
options: ${clientOptionsName} = {},
|
|
262
|
-
) =>
|
|
287
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
263
288
|
${createClientName}({
|
|
264
289
|
...options,
|
|
265
290
|
operationContext:
|
|
@@ -272,7 +297,7 @@ export const removeCheckoutCartItem = (
|
|
|
272
297
|
|
|
273
298
|
export const clearCheckoutCart = (
|
|
274
299
|
options: ${clientOptionsName} = {},
|
|
275
|
-
) =>
|
|
300
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
276
301
|
${createClientName}({
|
|
277
302
|
...options,
|
|
278
303
|
operationContext:
|
|
@@ -303,12 +328,63 @@ function createEffectSharedApiContract(service) {
|
|
|
303
328
|
const apiName = verticalEffectApiName(service);
|
|
304
329
|
const groupName = verticalEffectGroupName(service);
|
|
305
330
|
const stem = effectApiStem(service);
|
|
331
|
+
const pascalStem = toPascalCase(stem);
|
|
332
|
+
const markerType = `${pascalStem}Marker`;
|
|
333
|
+
const itemType = `${pascalStem}Item`;
|
|
334
|
+
const readinessType = `${pascalStem}Readiness`;
|
|
335
|
+
const createPayloadType = `${pascalStem}CreatePayload`;
|
|
336
|
+
const createResponseType = `${pascalStem}CreateResponse`;
|
|
337
|
+
const listResponseType = `${pascalStem}ListResponse`;
|
|
306
338
|
const apiPrefix = effectApiPrefix(service);
|
|
307
339
|
const checkoutCartSharedSchemas = createCheckoutCartSharedSchemas(service);
|
|
308
340
|
const checkoutCartSharedSchemaSection = '' === checkoutCartSharedSchemas ? '' : `${checkoutCartSharedSchemas}\n`;
|
|
309
341
|
const checkoutCartOperationContexts = createCheckoutCartOperationContexts(service).trimStart();
|
|
310
342
|
const checkoutCartOperationContextEntries = '' === checkoutCartOperationContexts ? '' : `${checkoutCartOperationContexts}\n`;
|
|
311
|
-
return `export
|
|
343
|
+
return `export interface ${markerType} {
|
|
344
|
+
readonly appId: string;
|
|
345
|
+
readonly build: string;
|
|
346
|
+
readonly deployProfile: string;
|
|
347
|
+
readonly packageName: string;
|
|
348
|
+
readonly surface: string;
|
|
349
|
+
readonly version: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface ${itemType} {
|
|
353
|
+
readonly id: string;
|
|
354
|
+
readonly marker: ${markerType};
|
|
355
|
+
readonly title: string;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface ${readinessType} {
|
|
359
|
+
readonly checks: {
|
|
360
|
+
readonly effectBff: 'ready';
|
|
361
|
+
readonly moduleFederation: 'ready';
|
|
362
|
+
readonly ssr: 'ready';
|
|
363
|
+
readonly translations: 'ready';
|
|
364
|
+
};
|
|
365
|
+
readonly marker: ${markerType};
|
|
366
|
+
readonly status: 'ready';
|
|
367
|
+
readonly versionSkew: 'none';
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface ${createPayloadType} {
|
|
371
|
+
readonly title: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface ${listResponseType} {
|
|
375
|
+
readonly items: ReadonlyArray<${itemType}>;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export interface ${createResponseType} {
|
|
379
|
+
readonly item: ${itemType};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface ${notFoundErrorExport} {
|
|
383
|
+
readonly _tag: '${notFoundErrorExport}';
|
|
384
|
+
readonly id: string;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export const ${markerSchemaExport}: Schema.Schema<${markerType}> = Schema.Struct({
|
|
312
388
|
appId: Schema.String,
|
|
313
389
|
build: Schema.String,
|
|
314
390
|
deployProfile: Schema.String,
|
|
@@ -317,13 +393,13 @@ function createEffectSharedApiContract(service) {
|
|
|
317
393
|
version: Schema.String,
|
|
318
394
|
});
|
|
319
395
|
|
|
320
|
-
export const ${schemaExport} = Schema.Struct({
|
|
396
|
+
export const ${schemaExport}: Schema.Schema<${itemType}> = Schema.Struct({
|
|
321
397
|
id: Schema.String,
|
|
322
398
|
marker: ${markerSchemaExport},
|
|
323
399
|
title: Schema.String,
|
|
324
400
|
});
|
|
325
401
|
|
|
326
|
-
export const ${readinessSchemaExport} = Schema.Struct({
|
|
402
|
+
export const ${readinessSchemaExport}: Schema.Schema<${readinessType}> = Schema.Struct({
|
|
327
403
|
checks: Schema.Struct({
|
|
328
404
|
effectBff: Schema.Literal('ready'),
|
|
329
405
|
moduleFederation: Schema.Literal('ready'),
|
|
@@ -335,18 +411,13 @@ export const ${readinessSchemaExport} = Schema.Struct({
|
|
|
335
411
|
versionSkew: Schema.Literal('none'),
|
|
336
412
|
});
|
|
337
413
|
|
|
338
|
-
export const ${createPayloadSchemaExport} = Schema.Struct({
|
|
414
|
+
export const ${createPayloadSchemaExport}: Schema.Schema<${createPayloadType}> = Schema.Struct({
|
|
339
415
|
title: Schema.String,
|
|
340
416
|
});
|
|
341
417
|
|
|
342
|
-
${checkoutCartSharedSchemaSection}export
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
id: Schema.String,
|
|
346
|
-
},
|
|
347
|
-
) {}
|
|
348
|
-
|
|
349
|
-
export const ${notFoundSchemaExport} = ${notFoundErrorExport}.pipe(
|
|
418
|
+
${checkoutCartSharedSchemaSection}export const ${notFoundSchemaExport}: Schema.Schema<${notFoundErrorExport}> = Schema.TaggedStruct('${notFoundErrorExport}', {
|
|
419
|
+
id: Schema.String,
|
|
420
|
+
}).pipe(
|
|
350
421
|
HttpApiSchema.status(404),
|
|
351
422
|
);
|
|
352
423
|
|
|
@@ -450,13 +521,20 @@ function createEffectServiceEntry(service, contractImportPath) {
|
|
|
450
521
|
HttpApiBuilder,
|
|
451
522
|
Layer,
|
|
452
523
|
} from '@modern-js/plugin-bff/effect-edge';
|
|
524
|
+
import type {
|
|
525
|
+
EffectBffDefinition,
|
|
526
|
+
EffectBffRuntime,
|
|
527
|
+
EffectRuntimeLayer,
|
|
528
|
+
} from '@modern-js/plugin-bff/effect-edge';
|
|
453
529
|
import { ultramodernApiMarker } from '../../src/ultramodern-build.ts';
|
|
454
530
|
import {
|
|
455
531
|
${apiExport},
|
|
456
532
|
${groupName}OperationContexts,
|
|
533
|
+
} from '${contractImportPath}';
|
|
534
|
+
import type {
|
|
457
535
|
${notFoundErrorExport},
|
|
536
|
+
OperationContext,
|
|
458
537
|
} from '${contractImportPath}';
|
|
459
|
-
import type { OperationContext } from '${contractImportPath}';
|
|
460
538
|
|
|
461
539
|
const ${groupName}Items = [
|
|
462
540
|
{
|
|
@@ -517,9 +595,13 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
517
595
|
const matchedItem = ${groupName}Items.find(
|
|
518
596
|
candidate => candidate.id === params.id,
|
|
519
597
|
);
|
|
598
|
+
const notFound: ${notFoundErrorExport} = {
|
|
599
|
+
_tag: '${notFoundErrorExport}',
|
|
600
|
+
id: params.id,
|
|
601
|
+
};
|
|
520
602
|
const result =
|
|
521
603
|
matchedItem === undefined
|
|
522
|
-
? Effect.fail(
|
|
604
|
+
? Effect.fail(notFound)
|
|
523
605
|
: Effect.succeed(matchedItem);
|
|
524
606
|
|
|
525
607
|
return result.pipe(
|
|
@@ -550,12 +632,15 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
550
632
|
|
|
551
633
|
const layer = HttpApiBuilder.layer(${apiExport}).pipe(
|
|
552
634
|
Layer.provide(${groupName}Layer),
|
|
553
|
-
);
|
|
635
|
+
) satisfies EffectRuntimeLayer;
|
|
554
636
|
|
|
555
|
-
|
|
637
|
+
const effectBff: EffectBffDefinition<typeof ${apiExport}, EffectRuntimeLayer> &
|
|
638
|
+
EffectBffRuntime<typeof ${apiExport}, EffectRuntimeLayer> = defineEffectBff({
|
|
556
639
|
api: ${apiExport},
|
|
557
640
|
layer,
|
|
558
641
|
});
|
|
642
|
+
|
|
643
|
+
export default effectBff;
|
|
559
644
|
`;
|
|
560
645
|
}
|
|
561
646
|
function createEffectClient(service, contractImportPath) {
|
|
@@ -566,25 +651,71 @@ function createEffectClient(service, contractImportPath) {
|
|
|
566
651
|
const singular = verticalEffectErrorStem(service);
|
|
567
652
|
const clientOptionsName = `${toPascalCase(stem)}ClientOptions`;
|
|
568
653
|
const createClientName = `create${toPascalCase(stem)}Client`;
|
|
654
|
+
const clientTypeName = `${toPascalCase(stem)}Client`;
|
|
655
|
+
const clientEffectTypeName = `${toPascalCase(stem)}ClientEffect`;
|
|
569
656
|
const listName = `list${toPascalCase(stem)}`;
|
|
570
657
|
const readinessName = `get${toPascalCase(stem)}Readiness`;
|
|
571
658
|
const getName = `get${toPascalCase(singular)}`;
|
|
572
659
|
const createName = `create${toPascalCase(singular)}`;
|
|
660
|
+
const notFoundErrorExport = verticalEffectNotFoundErrorExport(service);
|
|
661
|
+
const pascalStem = toPascalCase(stem);
|
|
662
|
+
const itemType = `${pascalStem}Item`;
|
|
663
|
+
const readinessType = `${pascalStem}Readiness`;
|
|
664
|
+
const createResponseType = `${pascalStem}CreateResponse`;
|
|
665
|
+
const listResponseType = `${pascalStem}ListResponse`;
|
|
573
666
|
const checkoutCartClientExports = createCheckoutCartClientExports(service);
|
|
574
667
|
return `import {
|
|
575
668
|
Effect,
|
|
576
669
|
makeEffectHttpApiClient,
|
|
577
670
|
runEffectRequest,
|
|
578
671
|
} from '@modern-js/plugin-bff/effect-client';
|
|
672
|
+
import type {
|
|
673
|
+
HttpClientError,
|
|
674
|
+
HttpApi,
|
|
675
|
+
HttpApiClient,
|
|
676
|
+
HttpApiGroup,
|
|
677
|
+
Schema,
|
|
678
|
+
} from '@modern-js/plugin-bff/effect-client';
|
|
579
679
|
import {
|
|
580
680
|
${contractExport}ApiContract,
|
|
581
681
|
${apiExport},
|
|
582
682
|
${groupName}OperationContexts,
|
|
583
683
|
} from '${contractImportPath}';
|
|
584
|
-
import type {
|
|
684
|
+
import type {
|
|
685
|
+
${createResponseType},
|
|
686
|
+
${itemType},
|
|
687
|
+
${listResponseType},
|
|
688
|
+
${notFoundErrorExport},
|
|
689
|
+
OperationContext,
|
|
690
|
+
${readinessType},
|
|
691
|
+
} from '${contractImportPath}';
|
|
585
692
|
|
|
586
693
|
export { Effect, runEffectRequest };
|
|
587
694
|
|
|
695
|
+
type ${pascalStem}EffectGroups = typeof ${apiExport} extends HttpApi.HttpApi<
|
|
696
|
+
infer _ApiId,
|
|
697
|
+
infer Groups
|
|
698
|
+
>
|
|
699
|
+
? Groups
|
|
700
|
+
: never;
|
|
701
|
+
|
|
702
|
+
export type ${clientTypeName} = HttpApiClient.Client<
|
|
703
|
+
Extract<${pascalStem}EffectGroups, HttpApiGroup.Any>,
|
|
704
|
+
never,
|
|
705
|
+
never
|
|
706
|
+
>;
|
|
707
|
+
|
|
708
|
+
export type ${pascalStem}ClientError =
|
|
709
|
+
| ${notFoundErrorExport}
|
|
710
|
+
| HttpClientError.HttpClientError
|
|
711
|
+
| Schema.SchemaError;
|
|
712
|
+
|
|
713
|
+
export type ${clientEffectTypeName}<Success> = Effect.Effect<
|
|
714
|
+
Success,
|
|
715
|
+
${pascalStem}ClientError,
|
|
716
|
+
never
|
|
717
|
+
>;
|
|
718
|
+
|
|
588
719
|
export interface ${clientOptionsName} {
|
|
589
720
|
baseUrl?: string | URL;
|
|
590
721
|
locale?: string;
|
|
@@ -594,7 +725,7 @@ export interface ${clientOptionsName} {
|
|
|
594
725
|
|
|
595
726
|
export const ${createClientName} = (
|
|
596
727
|
options: ${clientOptionsName} = {},
|
|
597
|
-
) =>
|
|
728
|
+
): ${clientEffectTypeName}<${clientTypeName}> =>
|
|
598
729
|
makeEffectHttpApiClient(${apiExport}, {
|
|
599
730
|
baseUrl: options.baseUrl ?? ${contractExport}ApiContract.apiPrefix,
|
|
600
731
|
requestContext: {
|
|
@@ -610,7 +741,7 @@ export const ${createClientName} = (
|
|
|
610
741
|
|
|
611
742
|
export const ${listName} = (
|
|
612
743
|
options: ${clientOptionsName} & { limit?: number } = {},
|
|
613
|
-
) =>
|
|
744
|
+
): ${clientEffectTypeName}<${listResponseType}> =>
|
|
614
745
|
${createClientName}({
|
|
615
746
|
...options,
|
|
616
747
|
operationContext:
|
|
@@ -623,7 +754,7 @@ export const ${listName} = (
|
|
|
623
754
|
|
|
624
755
|
export const ${readinessName} = (
|
|
625
756
|
options: ${clientOptionsName} = {},
|
|
626
|
-
) =>
|
|
757
|
+
): ${clientEffectTypeName}<${readinessType}> =>
|
|
627
758
|
${createClientName}({
|
|
628
759
|
...options,
|
|
629
760
|
operationContext:
|
|
@@ -635,7 +766,7 @@ export const ${readinessName} = (
|
|
|
635
766
|
export const ${getName} = (
|
|
636
767
|
id: string,
|
|
637
768
|
options: ${clientOptionsName} = {},
|
|
638
|
-
) =>
|
|
769
|
+
): ${clientEffectTypeName}<${itemType}> =>
|
|
639
770
|
${createClientName}({
|
|
640
771
|
...options,
|
|
641
772
|
operationContext:
|
|
@@ -647,7 +778,7 @@ export const ${getName} = (
|
|
|
647
778
|
export const ${createName} = (
|
|
648
779
|
title: string,
|
|
649
780
|
options: ${clientOptionsName} = {},
|
|
650
|
-
) =>
|
|
781
|
+
): ${clientEffectTypeName}<${createResponseType}> =>
|
|
651
782
|
${createClientName}({
|
|
652
783
|
...options,
|
|
653
784
|
operationContext:
|
|
@@ -218,12 +218,12 @@ ${bffPluginEntry} moduleFederationPlugin(),
|
|
|
218
218
|
}
|
|
219
219
|
function createSharedModuleFederationConfig() {
|
|
220
220
|
return ` shared: {
|
|
221
|
-
'@modern-js/plugin-i18n/runtime
|
|
221
|
+
'@modern-js/plugin-i18n/runtime': {
|
|
222
222
|
requiredVersion: pluginI18nVersion,
|
|
223
223
|
singleton: true,
|
|
224
224
|
treeShaking: false,
|
|
225
225
|
},
|
|
226
|
-
'@modern-js/plugin-i18n/runtime': {
|
|
226
|
+
'@modern-js/plugin-i18n/runtime/no-react-i18next': {
|
|
227
227
|
requiredVersion: pluginI18nVersion,
|
|
228
228
|
singleton: true,
|
|
229
229
|
treeShaking: false,
|
|
@@ -343,7 +343,9 @@ const reactVersion = (require('react/package.json') as { version: string }).vers
|
|
|
343
343
|
const reactDomVersion = (require('react-dom/package.json') as { version: string }).version;
|
|
344
344
|
|
|
345
345
|
${createModuleFederationRemoteUrlHelpers(shellHost, remotes)}
|
|
346
|
-
|
|
346
|
+
const moduleFederationConfig: Parameters<
|
|
347
|
+
typeof createModuleFederationConfig
|
|
348
|
+
>[0] = createModuleFederationConfig({
|
|
347
349
|
bridge: {
|
|
348
350
|
enableBridgeRouter: false,
|
|
349
351
|
},
|
|
@@ -361,6 +363,8 @@ export default createModuleFederationConfig({
|
|
|
361
363
|
${createModuleFederationRemotesConfig(scope, shellHost, remotes)}${createSharedModuleFederationConfig()},
|
|
362
364
|
treeShakingSharedExcludePlugins: ['RspackModuleFederationPlugin'],
|
|
363
365
|
});
|
|
366
|
+
|
|
367
|
+
export default moduleFederationConfig;
|
|
364
368
|
`;
|
|
365
369
|
}
|
|
366
370
|
function createBuildMarker(scope, app) {
|
|
@@ -401,7 +405,9 @@ const reactVersion = (require('react/package.json') as { version: string }).vers
|
|
|
401
405
|
const reactDomVersion = (require('react-dom/package.json') as { version: string }).version;
|
|
402
406
|
|
|
403
407
|
${createModuleFederationRemoteUrlHelpers(app, remotes)}
|
|
404
|
-
|
|
408
|
+
const moduleFederationConfig: Parameters<
|
|
409
|
+
typeof createModuleFederationConfig
|
|
410
|
+
>[0] = createModuleFederationConfig({
|
|
405
411
|
bridge: {
|
|
406
412
|
enableBridgeRouter: false,
|
|
407
413
|
},
|
|
@@ -420,6 +426,8 @@ export default createModuleFederationConfig({
|
|
|
420
426
|
${createModuleFederationRemotesConfig(scope, app, remotes)}${createSharedModuleFederationConfig()},
|
|
421
427
|
treeShakingSharedExcludePlugins: ['RspackModuleFederationPlugin'],
|
|
422
428
|
});
|
|
429
|
+
|
|
430
|
+
export default moduleFederationConfig;
|
|
423
431
|
`;
|
|
424
432
|
}
|
|
425
433
|
export { createAppModernConfig, createBuildMarker, createModuleFederationRemoteUrlHelpers, createModuleFederationRemotesConfig, createRemoteModuleFederationConfig, createSharedModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule, formatTsObjectLiteral };
|
|
@@ -256,6 +256,10 @@ function createTsBuildInfoFile(packageDir) {
|
|
|
256
256
|
const cacheKey = packageDir.replace(/[^a-zA-Z0-9._-]+/gu, '__');
|
|
257
257
|
return `${relativeRootFor(packageDir)}/node_modules/.cache/tsgo/${cacheKey}.tsbuildinfo`;
|
|
258
258
|
}
|
|
259
|
+
function createTsDeclarationOutDir(packageDir) {
|
|
260
|
+
const cacheKey = packageDir.replace(/[^a-zA-Z0-9._-]+/gu, '__');
|
|
261
|
+
return `${relativeRootFor(packageDir)}/node_modules/.cache/tsgo/declarations/${cacheKey}`;
|
|
262
|
+
}
|
|
259
263
|
function createReferences(packageDir, references) {
|
|
260
264
|
return [
|
|
261
265
|
...new Set(references)
|
|
@@ -269,8 +273,10 @@ function createPackageTsConfig(packageDir, options = {}) {
|
|
|
269
273
|
} : options;
|
|
270
274
|
const include = resolvedOptions.include ?? [
|
|
271
275
|
'src',
|
|
276
|
+
'locales/**/*.json',
|
|
272
277
|
'modern.config.ts',
|
|
273
|
-
'module-federation.config.ts'
|
|
278
|
+
'module-federation.config.ts',
|
|
279
|
+
'package.json'
|
|
274
280
|
];
|
|
275
281
|
if (resolvedOptions.includeApi) include.push('api', 'shared');
|
|
276
282
|
const references = createReferences(packageDir, resolvedOptions.references ?? []);
|
|
@@ -278,7 +284,12 @@ function createPackageTsConfig(packageDir, options = {}) {
|
|
|
278
284
|
extends: `${relativeRootFor(packageDir)}/tsconfig.base.json`,
|
|
279
285
|
compilerOptions: {
|
|
280
286
|
composite: true,
|
|
287
|
+
declaration: true,
|
|
288
|
+
declarationMap: false,
|
|
289
|
+
emitDeclarationOnly: true,
|
|
281
290
|
incremental: true,
|
|
291
|
+
noEmit: false,
|
|
292
|
+
outDir: createTsDeclarationOutDir(packageDir),
|
|
282
293
|
tsBuildInfoFile: createTsBuildInfoFile(packageDir)
|
|
283
294
|
},
|
|
284
295
|
include
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
|
-
"version": "3.4.0-ultramodern.
|
|
24
|
+
"version": "3.4.0-ultramodern.4",
|
|
25
25
|
"types": "./dist/types/index.d.ts",
|
|
26
26
|
"main": "./dist/esm-node/index.js",
|
|
27
27
|
"bin": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@modern-js/codesmith": "2.6.9",
|
|
78
|
-
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.4.0-ultramodern.
|
|
78
|
+
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.4.0-ultramodern.4"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@rslib/core": "0.23.0",
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
"test": "rm -rf dist && rslib build -c rslibconfig.mts && rstest --passWithNoTests"
|
|
98
98
|
},
|
|
99
99
|
"ultramodern": {
|
|
100
|
-
"frameworkVersion": "3.4.0-ultramodern.
|
|
100
|
+
"frameworkVersion": "3.4.0-ultramodern.4"
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -143,9 +143,9 @@ export const UltramodernRouteHead = () => {
|
|
|
143
143
|
<meta content="summary_large_image" name="twitter:card" />
|
|
144
144
|
<meta content={title} name="twitter:title" />
|
|
145
145
|
<meta content={description} name="twitter:description" />
|
|
146
|
-
{jsonLd
|
|
146
|
+
{jsonLd === undefined ? null : (
|
|
147
147
|
<script type="application/ld+json">{sanitiseJsonLd(jsonLd)}</script>
|
|
148
|
-
)
|
|
148
|
+
)}
|
|
149
149
|
</>
|
|
150
150
|
)}
|
|
151
151
|
</Helmet>
|
|
@@ -398,6 +398,24 @@ const sharedPackagePaths = [
|
|
|
398
398
|
'packages/shared-contracts',
|
|
399
399
|
'packages/shared-design-tokens',
|
|
400
400
|
];
|
|
401
|
+
const tsgoCacheKey = packagePath => packagePath.replace(/[^a-zA-Z0-9._-]+/gu, '__');
|
|
402
|
+
const assertProjectReferenceEmitConfig = (tsConfig, packagePath) => {
|
|
403
|
+
const compilerOptions = tsConfig.compilerOptions ?? {};
|
|
404
|
+
const relativeRoot = toPosixPath(path.relative(packagePath, '.')) || '.';
|
|
405
|
+
assert(compilerOptions.composite === true, `${packagePath} must stay a composite TS-Go project`);
|
|
406
|
+
assert(compilerOptions.declaration === true, `${packagePath} must emit declarations for TS-Go build mode`);
|
|
407
|
+
assert(compilerOptions.declarationMap === false, `${packagePath} must not emit declaration maps during checks`);
|
|
408
|
+
assert(compilerOptions.emitDeclarationOnly === true, `${packagePath} must only emit declarations during checks`);
|
|
409
|
+
assert(compilerOptions.noEmit === false, `${packagePath} must override root noEmit for TS-Go build mode`);
|
|
410
|
+
assert(
|
|
411
|
+
compilerOptions.outDir === `${relativeRoot}/node_modules/.cache/tsgo/declarations/${tsgoCacheKey(packagePath)}`,
|
|
412
|
+
`${packagePath} must emit TS-Go declarations into the generated cache`,
|
|
413
|
+
);
|
|
414
|
+
assert(
|
|
415
|
+
compilerOptions.tsBuildInfoFile === `${relativeRoot}/node_modules/.cache/tsgo/${tsgoCacheKey(packagePath)}.tsbuildinfo`,
|
|
416
|
+
`${packagePath} must keep TS-Go build info in the generated cache`,
|
|
417
|
+
);
|
|
418
|
+
};
|
|
401
419
|
const assertTsConfigReferenceGraph = () => {
|
|
402
420
|
const rootTsConfig = readJson('tsconfig.json');
|
|
403
421
|
const shellTsConfig = readJson('apps/shell-super-app/tsconfig.json');
|
|
@@ -431,6 +449,16 @@ const assertTsConfigReferenceGraph = () => {
|
|
|
431
449
|
'apps/shell-super-app/tsconfig.json references',
|
|
432
450
|
'restore the generated shell project-reference graph',
|
|
433
451
|
);
|
|
452
|
+
assertProjectReferenceEmitConfig(
|
|
453
|
+
shellTsConfig,
|
|
454
|
+
'apps/shell-super-app',
|
|
455
|
+
);
|
|
456
|
+
for (const sharedPackagePath of sharedPackagePaths) {
|
|
457
|
+
assertProjectReferenceEmitConfig(
|
|
458
|
+
readJson(`${sharedPackagePath}/tsconfig.json`),
|
|
459
|
+
sharedPackagePath,
|
|
460
|
+
);
|
|
461
|
+
}
|
|
434
462
|
|
|
435
463
|
for (const vertical of fullStackVerticals) {
|
|
436
464
|
const verticalTsConfig = readJson(`${vertical.path}/tsconfig.json`);
|
|
@@ -449,6 +477,7 @@ const assertTsConfigReferenceGraph = () => {
|
|
|
449
477
|
`${vertical.path}/tsconfig.json references`,
|
|
450
478
|
'restore the generated MicroVertical project-reference graph',
|
|
451
479
|
);
|
|
480
|
+
assertProjectReferenceEmitConfig(verticalTsConfig, vertical.path);
|
|
452
481
|
}
|
|
453
482
|
};
|
|
454
483
|
const packageJsonFiles = startDir => {
|