@bleedingdev/modern-js-create 3.4.0-ultramodern.3 → 3.4.0-ultramodern.5
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 +5 -3
- package/dist/cjs/ultramodern-workspace/effect-api.cjs +162 -31
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +23 -4
- package/dist/cjs/ultramodern-workspace/package-json.cjs +14 -2
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +2 -1
- package/dist/esm/ultramodern-workspace/demo-components.js +5 -3
- package/dist/esm/ultramodern-workspace/effect-api.js +162 -31
- package/dist/esm/ultramodern-workspace/module-federation.js +21 -5
- package/dist/esm/ultramodern-workspace/package-json.js +14 -2
- package/dist/esm/ultramodern-workspace/write-workspace.js +3 -2
- package/dist/esm-node/ultramodern-workspace/demo-components.js +5 -3
- package/dist/esm-node/ultramodern-workspace/effect-api.js +162 -31
- package/dist/esm-node/ultramodern-workspace/module-federation.js +21 -5
- package/dist/esm-node/ultramodern-workspace/package-json.js +14 -2
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +3 -2
- package/dist/types/ultramodern-workspace/module-federation.d.ts +1 -0
- 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
|
@@ -36,27 +36,51 @@ function serviceHasCheckoutCartState(service) {
|
|
|
36
36
|
function createCheckoutCartSharedSchemas(service) {
|
|
37
37
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
38
38
|
return `
|
|
39
|
-
export
|
|
39
|
+
export interface CheckoutCartLine {
|
|
40
|
+
readonly sku: string;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly quantity: number;
|
|
43
|
+
readonly unitPriceCents: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CheckoutCart {
|
|
47
|
+
readonly lines: readonly CheckoutCartLine[];
|
|
48
|
+
readonly subtotalCents: number;
|
|
49
|
+
readonly totalQuantity: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface CheckoutAddCartItemPayload {
|
|
53
|
+
readonly sku: string;
|
|
54
|
+
readonly name?: string;
|
|
55
|
+
readonly quantity: number;
|
|
56
|
+
readonly unitPriceCents?: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface CheckoutRemoveCartItemPayload {
|
|
60
|
+
readonly sku: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const checkoutCartLineSchema: Schema.Codec<CheckoutCartLine> = Schema.Struct({
|
|
40
64
|
sku: Schema.String,
|
|
41
65
|
name: Schema.String,
|
|
42
66
|
quantity: Schema.Finite,
|
|
43
67
|
unitPriceCents: Schema.Finite,
|
|
44
68
|
});
|
|
45
69
|
|
|
46
|
-
export const checkoutCartSchema = Schema.Struct({
|
|
70
|
+
export const checkoutCartSchema: Schema.Codec<CheckoutCart> = Schema.Struct({
|
|
47
71
|
lines: Schema.Array(checkoutCartLineSchema),
|
|
48
72
|
subtotalCents: Schema.Finite,
|
|
49
73
|
totalQuantity: Schema.Finite,
|
|
50
74
|
});
|
|
51
75
|
|
|
52
|
-
export const checkoutAddCartItemPayloadSchema = Schema.Struct({
|
|
76
|
+
export const checkoutAddCartItemPayloadSchema: Schema.Codec<CheckoutAddCartItemPayload> = Schema.Struct({
|
|
53
77
|
sku: Schema.String,
|
|
54
78
|
name: Schema.optional(Schema.String),
|
|
55
79
|
quantity: Schema.Finite,
|
|
56
80
|
unitPriceCents: Schema.optional(Schema.Finite),
|
|
57
81
|
});
|
|
58
82
|
|
|
59
|
-
export const checkoutRemoveCartItemPayloadSchema = Schema.Struct({
|
|
83
|
+
export const checkoutRemoveCartItemPayloadSchema: Schema.Codec<CheckoutRemoveCartItemPayload> = Schema.Struct({
|
|
60
84
|
sku: Schema.String,
|
|
61
85
|
});
|
|
62
86
|
`;
|
|
@@ -209,6 +233,7 @@ function createCheckoutCartClientExports(service) {
|
|
|
209
233
|
const pascalStem = toPascalCase(stem);
|
|
210
234
|
const clientOptionsName = `${pascalStem}ClientOptions`;
|
|
211
235
|
const createClientName = `create${pascalStem}Client`;
|
|
236
|
+
const clientEffectTypeName = `${pascalStem}ClientEffect`;
|
|
212
237
|
return `
|
|
213
238
|
export interface CheckoutCartLine {
|
|
214
239
|
sku: string;
|
|
@@ -232,7 +257,7 @@ export interface CheckoutAddCartItemInput {
|
|
|
232
257
|
|
|
233
258
|
export const getCheckoutCart = (
|
|
234
259
|
options: ${clientOptionsName} = {},
|
|
235
|
-
) =>
|
|
260
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
236
261
|
${createClientName}({
|
|
237
262
|
...options,
|
|
238
263
|
operationContext:
|
|
@@ -244,7 +269,7 @@ export const getCheckoutCart = (
|
|
|
244
269
|
export const addCheckoutCartItem = (
|
|
245
270
|
payload: CheckoutAddCartItemInput,
|
|
246
271
|
options: ${clientOptionsName} = {},
|
|
247
|
-
) =>
|
|
272
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
248
273
|
${createClientName}({
|
|
249
274
|
...options,
|
|
250
275
|
operationContext:
|
|
@@ -258,7 +283,7 @@ export const addCheckoutCartItem = (
|
|
|
258
283
|
export const removeCheckoutCartItem = (
|
|
259
284
|
sku: string,
|
|
260
285
|
options: ${clientOptionsName} = {},
|
|
261
|
-
) =>
|
|
286
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
262
287
|
${createClientName}({
|
|
263
288
|
...options,
|
|
264
289
|
operationContext:
|
|
@@ -271,7 +296,7 @@ export const removeCheckoutCartItem = (
|
|
|
271
296
|
|
|
272
297
|
export const clearCheckoutCart = (
|
|
273
298
|
options: ${clientOptionsName} = {},
|
|
274
|
-
) =>
|
|
299
|
+
): ${clientEffectTypeName}<CheckoutCart> =>
|
|
275
300
|
${createClientName}({
|
|
276
301
|
...options,
|
|
277
302
|
operationContext:
|
|
@@ -302,12 +327,63 @@ function createEffectSharedApiContract(service) {
|
|
|
302
327
|
const apiName = verticalEffectApiName(service);
|
|
303
328
|
const groupName = verticalEffectGroupName(service);
|
|
304
329
|
const stem = effectApiStem(service);
|
|
330
|
+
const pascalStem = toPascalCase(stem);
|
|
331
|
+
const markerType = `${pascalStem}Marker`;
|
|
332
|
+
const itemType = `${pascalStem}Item`;
|
|
333
|
+
const readinessType = `${pascalStem}Readiness`;
|
|
334
|
+
const createPayloadType = `${pascalStem}CreatePayload`;
|
|
335
|
+
const createResponseType = `${pascalStem}CreateResponse`;
|
|
336
|
+
const listResponseType = `${pascalStem}ListResponse`;
|
|
305
337
|
const apiPrefix = effectApiPrefix(service);
|
|
306
338
|
const checkoutCartSharedSchemas = createCheckoutCartSharedSchemas(service);
|
|
307
339
|
const checkoutCartSharedSchemaSection = '' === checkoutCartSharedSchemas ? '' : `${checkoutCartSharedSchemas}\n`;
|
|
308
340
|
const checkoutCartOperationContexts = createCheckoutCartOperationContexts(service).trimStart();
|
|
309
341
|
const checkoutCartOperationContextEntries = '' === checkoutCartOperationContexts ? '' : `${checkoutCartOperationContexts}\n`;
|
|
310
|
-
return `export
|
|
342
|
+
return `export interface ${markerType} {
|
|
343
|
+
readonly appId: string;
|
|
344
|
+
readonly build: string;
|
|
345
|
+
readonly deployProfile: string;
|
|
346
|
+
readonly packageName: string;
|
|
347
|
+
readonly surface: string;
|
|
348
|
+
readonly version: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface ${itemType} {
|
|
352
|
+
readonly id: string;
|
|
353
|
+
readonly marker: ${markerType};
|
|
354
|
+
readonly title: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface ${readinessType} {
|
|
358
|
+
readonly checks: {
|
|
359
|
+
readonly effectBff: 'ready';
|
|
360
|
+
readonly moduleFederation: 'ready';
|
|
361
|
+
readonly ssr: 'ready';
|
|
362
|
+
readonly translations: 'ready';
|
|
363
|
+
};
|
|
364
|
+
readonly marker: ${markerType};
|
|
365
|
+
readonly status: 'ready';
|
|
366
|
+
readonly versionSkew: 'none';
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface ${createPayloadType} {
|
|
370
|
+
readonly title: string;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface ${listResponseType} {
|
|
374
|
+
readonly items: readonly ${itemType}[];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export interface ${createResponseType} {
|
|
378
|
+
readonly item: ${itemType};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface ${notFoundErrorExport} {
|
|
382
|
+
readonly _tag: '${notFoundErrorExport}';
|
|
383
|
+
readonly id: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export const ${markerSchemaExport}: Schema.Codec<${markerType}> = Schema.Struct({
|
|
311
387
|
appId: Schema.String,
|
|
312
388
|
build: Schema.String,
|
|
313
389
|
deployProfile: Schema.String,
|
|
@@ -316,13 +392,13 @@ function createEffectSharedApiContract(service) {
|
|
|
316
392
|
version: Schema.String,
|
|
317
393
|
});
|
|
318
394
|
|
|
319
|
-
export const ${schemaExport} = Schema.Struct({
|
|
395
|
+
export const ${schemaExport}: Schema.Codec<${itemType}> = Schema.Struct({
|
|
320
396
|
id: Schema.String,
|
|
321
397
|
marker: ${markerSchemaExport},
|
|
322
398
|
title: Schema.String,
|
|
323
399
|
});
|
|
324
400
|
|
|
325
|
-
export const ${readinessSchemaExport} = Schema.Struct({
|
|
401
|
+
export const ${readinessSchemaExport}: Schema.Codec<${readinessType}> = Schema.Struct({
|
|
326
402
|
checks: Schema.Struct({
|
|
327
403
|
effectBff: Schema.Literal('ready'),
|
|
328
404
|
moduleFederation: Schema.Literal('ready'),
|
|
@@ -334,18 +410,13 @@ export const ${readinessSchemaExport} = Schema.Struct({
|
|
|
334
410
|
versionSkew: Schema.Literal('none'),
|
|
335
411
|
});
|
|
336
412
|
|
|
337
|
-
export const ${createPayloadSchemaExport} = Schema.Struct({
|
|
413
|
+
export const ${createPayloadSchemaExport}: Schema.Codec<${createPayloadType}> = Schema.Struct({
|
|
338
414
|
title: Schema.String,
|
|
339
415
|
});
|
|
340
416
|
|
|
341
|
-
${checkoutCartSharedSchemaSection}export
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
id: Schema.String,
|
|
345
|
-
},
|
|
346
|
-
) {}
|
|
347
|
-
|
|
348
|
-
export const ${notFoundSchemaExport} = ${notFoundErrorExport}.pipe(
|
|
417
|
+
${checkoutCartSharedSchemaSection}export const ${notFoundSchemaExport}: Schema.Codec<${notFoundErrorExport}> = Schema.TaggedStruct('${notFoundErrorExport}', {
|
|
418
|
+
id: Schema.String,
|
|
419
|
+
}).pipe(
|
|
349
420
|
HttpApiSchema.status(404),
|
|
350
421
|
);
|
|
351
422
|
|
|
@@ -449,13 +520,20 @@ function createEffectServiceEntry(service, contractImportPath) {
|
|
|
449
520
|
HttpApiBuilder,
|
|
450
521
|
Layer,
|
|
451
522
|
} from '@modern-js/plugin-bff/effect-edge';
|
|
452
|
-
import {
|
|
523
|
+
import type {
|
|
524
|
+
EffectBffDefinition,
|
|
525
|
+
EffectBffRuntime,
|
|
526
|
+
EffectRuntimeLayer,
|
|
527
|
+
} from '@modern-js/plugin-bff/effect-edge';
|
|
528
|
+
import { ultramodernApiMarker } from '../../shared/ultramodern-build.ts';
|
|
453
529
|
import {
|
|
454
530
|
${apiExport},
|
|
455
531
|
${groupName}OperationContexts,
|
|
532
|
+
} from '${contractImportPath}';
|
|
533
|
+
import type {
|
|
456
534
|
${notFoundErrorExport},
|
|
535
|
+
OperationContext,
|
|
457
536
|
} from '${contractImportPath}';
|
|
458
|
-
import type { OperationContext } from '${contractImportPath}';
|
|
459
537
|
|
|
460
538
|
const ${groupName}Items = [
|
|
461
539
|
{
|
|
@@ -516,9 +594,13 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
516
594
|
const matchedItem = ${groupName}Items.find(
|
|
517
595
|
candidate => candidate.id === params.id,
|
|
518
596
|
);
|
|
597
|
+
const notFound: ${notFoundErrorExport} = {
|
|
598
|
+
_tag: '${notFoundErrorExport}',
|
|
599
|
+
id: params.id,
|
|
600
|
+
};
|
|
519
601
|
const result =
|
|
520
602
|
matchedItem === undefined
|
|
521
|
-
? Effect.fail(
|
|
603
|
+
? Effect.fail(notFound)
|
|
522
604
|
: Effect.succeed(matchedItem);
|
|
523
605
|
|
|
524
606
|
return result.pipe(
|
|
@@ -549,12 +631,15 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
549
631
|
|
|
550
632
|
const layer = HttpApiBuilder.layer(${apiExport}).pipe(
|
|
551
633
|
Layer.provide(${groupName}Layer),
|
|
552
|
-
);
|
|
634
|
+
) satisfies EffectRuntimeLayer;
|
|
553
635
|
|
|
554
|
-
|
|
636
|
+
const effectBff: EffectBffDefinition<typeof ${apiExport}, EffectRuntimeLayer> &
|
|
637
|
+
EffectBffRuntime<typeof ${apiExport}, EffectRuntimeLayer> = defineEffectBff({
|
|
555
638
|
api: ${apiExport},
|
|
556
639
|
layer,
|
|
557
640
|
});
|
|
641
|
+
|
|
642
|
+
export default effectBff;
|
|
558
643
|
`;
|
|
559
644
|
}
|
|
560
645
|
function createEffectClient(service, contractImportPath) {
|
|
@@ -565,25 +650,71 @@ function createEffectClient(service, contractImportPath) {
|
|
|
565
650
|
const singular = verticalEffectErrorStem(service);
|
|
566
651
|
const clientOptionsName = `${toPascalCase(stem)}ClientOptions`;
|
|
567
652
|
const createClientName = `create${toPascalCase(stem)}Client`;
|
|
653
|
+
const clientTypeName = `${toPascalCase(stem)}Client`;
|
|
654
|
+
const clientEffectTypeName = `${toPascalCase(stem)}ClientEffect`;
|
|
568
655
|
const listName = `list${toPascalCase(stem)}`;
|
|
569
656
|
const readinessName = `get${toPascalCase(stem)}Readiness`;
|
|
570
657
|
const getName = `get${toPascalCase(singular)}`;
|
|
571
658
|
const createName = `create${toPascalCase(singular)}`;
|
|
659
|
+
const notFoundErrorExport = verticalEffectNotFoundErrorExport(service);
|
|
660
|
+
const pascalStem = toPascalCase(stem);
|
|
661
|
+
const itemType = `${pascalStem}Item`;
|
|
662
|
+
const readinessType = `${pascalStem}Readiness`;
|
|
663
|
+
const createResponseType = `${pascalStem}CreateResponse`;
|
|
664
|
+
const listResponseType = `${pascalStem}ListResponse`;
|
|
572
665
|
const checkoutCartClientExports = createCheckoutCartClientExports(service);
|
|
573
666
|
return `import {
|
|
574
667
|
Effect,
|
|
575
668
|
makeEffectHttpApiClient,
|
|
576
669
|
runEffectRequest,
|
|
577
670
|
} from '@modern-js/plugin-bff/effect-client';
|
|
671
|
+
import type {
|
|
672
|
+
HttpClientError,
|
|
673
|
+
HttpApi,
|
|
674
|
+
HttpApiClient,
|
|
675
|
+
HttpApiGroup,
|
|
676
|
+
Schema,
|
|
677
|
+
} from '@modern-js/plugin-bff/effect-client';
|
|
578
678
|
import {
|
|
579
679
|
${contractExport}ApiContract,
|
|
580
680
|
${apiExport},
|
|
581
681
|
${groupName}OperationContexts,
|
|
582
682
|
} from '${contractImportPath}';
|
|
583
|
-
import type {
|
|
683
|
+
import type {
|
|
684
|
+
${createResponseType},
|
|
685
|
+
${itemType},
|
|
686
|
+
${listResponseType},
|
|
687
|
+
${notFoundErrorExport},
|
|
688
|
+
OperationContext,
|
|
689
|
+
${readinessType},
|
|
690
|
+
} from '${contractImportPath}';
|
|
584
691
|
|
|
585
692
|
export { Effect, runEffectRequest };
|
|
586
693
|
|
|
694
|
+
type ${pascalStem}EffectGroups = typeof ${apiExport} extends HttpApi.HttpApi<
|
|
695
|
+
infer _ApiId,
|
|
696
|
+
infer Groups
|
|
697
|
+
>
|
|
698
|
+
? Groups
|
|
699
|
+
: never;
|
|
700
|
+
|
|
701
|
+
export type ${clientTypeName} = HttpApiClient.Client<
|
|
702
|
+
Extract<${pascalStem}EffectGroups, HttpApiGroup.Any>,
|
|
703
|
+
never,
|
|
704
|
+
never
|
|
705
|
+
>;
|
|
706
|
+
|
|
707
|
+
export type ${pascalStem}ClientError =
|
|
708
|
+
| ${notFoundErrorExport}
|
|
709
|
+
| HttpClientError.HttpClientError
|
|
710
|
+
| Schema.SchemaError;
|
|
711
|
+
|
|
712
|
+
export type ${clientEffectTypeName}<Success> = Effect.Effect<
|
|
713
|
+
Success,
|
|
714
|
+
${pascalStem}ClientError,
|
|
715
|
+
never
|
|
716
|
+
>;
|
|
717
|
+
|
|
587
718
|
export interface ${clientOptionsName} {
|
|
588
719
|
baseUrl?: string | URL;
|
|
589
720
|
locale?: string;
|
|
@@ -593,7 +724,7 @@ export interface ${clientOptionsName} {
|
|
|
593
724
|
|
|
594
725
|
export const ${createClientName} = (
|
|
595
726
|
options: ${clientOptionsName} = {},
|
|
596
|
-
) =>
|
|
727
|
+
): ${clientEffectTypeName}<${clientTypeName}> =>
|
|
597
728
|
makeEffectHttpApiClient(${apiExport}, {
|
|
598
729
|
baseUrl: options.baseUrl ?? ${contractExport}ApiContract.apiPrefix,
|
|
599
730
|
requestContext: {
|
|
@@ -609,7 +740,7 @@ export const ${createClientName} = (
|
|
|
609
740
|
|
|
610
741
|
export const ${listName} = (
|
|
611
742
|
options: ${clientOptionsName} & { limit?: number } = {},
|
|
612
|
-
) =>
|
|
743
|
+
): ${clientEffectTypeName}<${listResponseType}> =>
|
|
613
744
|
${createClientName}({
|
|
614
745
|
...options,
|
|
615
746
|
operationContext:
|
|
@@ -622,7 +753,7 @@ export const ${listName} = (
|
|
|
622
753
|
|
|
623
754
|
export const ${readinessName} = (
|
|
624
755
|
options: ${clientOptionsName} = {},
|
|
625
|
-
) =>
|
|
756
|
+
): ${clientEffectTypeName}<${readinessType}> =>
|
|
626
757
|
${createClientName}({
|
|
627
758
|
...options,
|
|
628
759
|
operationContext:
|
|
@@ -634,7 +765,7 @@ export const ${readinessName} = (
|
|
|
634
765
|
export const ${getName} = (
|
|
635
766
|
id: string,
|
|
636
767
|
options: ${clientOptionsName} = {},
|
|
637
|
-
) =>
|
|
768
|
+
): ${clientEffectTypeName}<${itemType}> =>
|
|
638
769
|
${createClientName}({
|
|
639
770
|
...options,
|
|
640
771
|
operationContext:
|
|
@@ -646,7 +777,7 @@ export const ${getName} = (
|
|
|
646
777
|
export const ${createName} = (
|
|
647
778
|
title: string,
|
|
648
779
|
options: ${clientOptionsName} = {},
|
|
649
|
-
) =>
|
|
780
|
+
): ${clientEffectTypeName}<${createResponseType}> =>
|
|
650
781
|
${createClientName}({
|
|
651
782
|
...options,
|
|
652
783
|
operationContext:
|
|
@@ -217,12 +217,12 @@ ${bffPluginEntry} moduleFederationPlugin(),
|
|
|
217
217
|
}
|
|
218
218
|
function createSharedModuleFederationConfig() {
|
|
219
219
|
return ` shared: {
|
|
220
|
-
'@modern-js/plugin-i18n/runtime
|
|
220
|
+
'@modern-js/plugin-i18n/runtime': {
|
|
221
221
|
requiredVersion: pluginI18nVersion,
|
|
222
222
|
singleton: true,
|
|
223
223
|
treeShaking: false,
|
|
224
224
|
},
|
|
225
|
-
'@modern-js/plugin-i18n/runtime': {
|
|
225
|
+
'@modern-js/plugin-i18n/runtime/no-react-i18next': {
|
|
226
226
|
requiredVersion: pluginI18nVersion,
|
|
227
227
|
singleton: true,
|
|
228
228
|
treeShaking: false,
|
|
@@ -342,7 +342,9 @@ const reactVersion = (require('react/package.json') as { version: string }).vers
|
|
|
342
342
|
const reactDomVersion = (require('react-dom/package.json') as { version: string }).version;
|
|
343
343
|
|
|
344
344
|
${createModuleFederationRemoteUrlHelpers(shellHost, remotes)}
|
|
345
|
-
|
|
345
|
+
const moduleFederationConfig: Parameters<
|
|
346
|
+
typeof createModuleFederationConfig
|
|
347
|
+
>[0] = createModuleFederationConfig({
|
|
346
348
|
bridge: {
|
|
347
349
|
enableBridgeRouter: false,
|
|
348
350
|
},
|
|
@@ -360,6 +362,8 @@ export default createModuleFederationConfig({
|
|
|
360
362
|
${createModuleFederationRemotesConfig(scope, shellHost, remotes)}${createSharedModuleFederationConfig()},
|
|
361
363
|
treeShakingSharedExcludePlugins: ['RspackModuleFederationPlugin'],
|
|
362
364
|
});
|
|
365
|
+
|
|
366
|
+
export default moduleFederationConfig;
|
|
363
367
|
`;
|
|
364
368
|
}
|
|
365
369
|
function createBuildMarker(scope, app) {
|
|
@@ -385,6 +389,14 @@ export const ultramodernApiMarker = {
|
|
|
385
389
|
} as const;
|
|
386
390
|
`;
|
|
387
391
|
}
|
|
392
|
+
function createUltramodernBuildReexportModule() {
|
|
393
|
+
return `export {
|
|
394
|
+
ultramodernApiMarker,
|
|
395
|
+
ultramodernUiMarker,
|
|
396
|
+
ultramodernVerticalIdentity,
|
|
397
|
+
} from '../shared/ultramodern-build';
|
|
398
|
+
`;
|
|
399
|
+
}
|
|
388
400
|
function createRemoteModuleFederationConfig(scope, app, remotes = []) {
|
|
389
401
|
const exposes = formatTsObjectLiteral(app.exposes ?? {});
|
|
390
402
|
return `// @effect-diagnostics nodeBuiltinImport:off
|
|
@@ -400,7 +412,9 @@ const reactVersion = (require('react/package.json') as { version: string }).vers
|
|
|
400
412
|
const reactDomVersion = (require('react-dom/package.json') as { version: string }).version;
|
|
401
413
|
|
|
402
414
|
${createModuleFederationRemoteUrlHelpers(app, remotes)}
|
|
403
|
-
|
|
415
|
+
const moduleFederationConfig: Parameters<
|
|
416
|
+
typeof createModuleFederationConfig
|
|
417
|
+
>[0] = createModuleFederationConfig({
|
|
404
418
|
bridge: {
|
|
405
419
|
enableBridgeRouter: false,
|
|
406
420
|
},
|
|
@@ -419,6 +433,8 @@ export default createModuleFederationConfig({
|
|
|
419
433
|
${createModuleFederationRemotesConfig(scope, app, remotes)}${createSharedModuleFederationConfig()},
|
|
420
434
|
treeShakingSharedExcludePlugins: ['RspackModuleFederationPlugin'],
|
|
421
435
|
});
|
|
436
|
+
|
|
437
|
+
export default moduleFederationConfig;
|
|
422
438
|
`;
|
|
423
439
|
}
|
|
424
|
-
export { createAppModernConfig, createBuildMarker, createModuleFederationRemoteUrlHelpers, createModuleFederationRemotesConfig, createRemoteModuleFederationConfig, createSharedModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule, formatTsObjectLiteral };
|
|
440
|
+
export { createAppModernConfig, createBuildMarker, createModuleFederationRemoteUrlHelpers, createModuleFederationRemotesConfig, createRemoteModuleFederationConfig, createSharedModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule, createUltramodernBuildReexportModule, formatTsObjectLiteral };
|
|
@@ -255,6 +255,10 @@ function createTsBuildInfoFile(packageDir) {
|
|
|
255
255
|
const cacheKey = packageDir.replace(/[^a-zA-Z0-9._-]+/gu, '__');
|
|
256
256
|
return `${relativeRootFor(packageDir)}/node_modules/.cache/tsgo/${cacheKey}.tsbuildinfo`;
|
|
257
257
|
}
|
|
258
|
+
function createTsDeclarationOutDir(packageDir) {
|
|
259
|
+
const cacheKey = packageDir.replace(/[^a-zA-Z0-9._-]+/gu, '__');
|
|
260
|
+
return `${relativeRootFor(packageDir)}/node_modules/.cache/tsgo/declarations/${cacheKey}`;
|
|
261
|
+
}
|
|
258
262
|
function createReferences(packageDir, references) {
|
|
259
263
|
return [
|
|
260
264
|
...new Set(references)
|
|
@@ -268,16 +272,24 @@ function createPackageTsConfig(packageDir, options = {}) {
|
|
|
268
272
|
} : options;
|
|
269
273
|
const include = resolvedOptions.include ?? [
|
|
270
274
|
'src',
|
|
275
|
+
'locales/**/*.json',
|
|
271
276
|
'modern.config.ts',
|
|
272
|
-
'module-federation.config.ts'
|
|
277
|
+
'module-federation.config.ts',
|
|
278
|
+
'package.json',
|
|
279
|
+
'shared'
|
|
273
280
|
];
|
|
274
|
-
if (resolvedOptions.includeApi) include.push('api'
|
|
281
|
+
if (resolvedOptions.includeApi) include.push('api');
|
|
275
282
|
const references = createReferences(packageDir, resolvedOptions.references ?? []);
|
|
276
283
|
const tsconfig = {
|
|
277
284
|
extends: `${relativeRootFor(packageDir)}/tsconfig.base.json`,
|
|
278
285
|
compilerOptions: {
|
|
279
286
|
composite: true,
|
|
287
|
+
declaration: true,
|
|
288
|
+
declarationMap: false,
|
|
289
|
+
emitDeclarationOnly: true,
|
|
280
290
|
incremental: true,
|
|
291
|
+
noEmit: false,
|
|
292
|
+
outDir: createTsDeclarationOutDir(packageDir),
|
|
281
293
|
tsBuildInfoFile: createTsBuildInfoFile(packageDir)
|
|
282
294
|
},
|
|
283
295
|
include
|
|
@@ -7,7 +7,7 @@ import { createEffectClient, createEffectServiceEntry, createEffectSharedApi, cr
|
|
|
7
7
|
import { copyRootTemplate, writeFile, writeJson } from "./fs-io.js";
|
|
8
8
|
import { createFileSnapshot, createGenerationResult, diffFileSnapshots } from "./generation-result.js";
|
|
9
9
|
import { createAppPublicLocaleMessages } from "./locales.js";
|
|
10
|
-
import { createAppModernConfig, createRemoteModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule } from "./module-federation.js";
|
|
10
|
+
import { createAppModernConfig, createRemoteModuleFederationConfig, createShellModuleFederationConfig, createUltramodernBuildModule, createUltramodernBuildReexportModule } from "./module-federation.js";
|
|
11
11
|
import { assertUniqueTailwindPrefixes, toPackageScope } from "./naming.js";
|
|
12
12
|
import { runCodeSmithOverlays } from "./overlays.js";
|
|
13
13
|
import { createAppPackage, createAppTsConfig, createRootPackageJson, createRootTsConfig, createSharedContractsIndex, createSharedPackage, createSharedPackageTsConfig, createTsConfigBase } from "./package-json.js";
|
|
@@ -24,7 +24,8 @@ function writeApp(targetDir, scope, app, packageSource, enableTailwind, remotes
|
|
|
24
24
|
writeJson(targetDir, `${resolvedApp.directory}/package.json`, createAppPackage(scope, resolvedApp, packageSource, enableTailwind, remotes));
|
|
25
25
|
writeJson(targetDir, `${resolvedApp.directory}/tsconfig.json`, createAppTsConfig(resolvedApp, remotes));
|
|
26
26
|
writeFile(targetDir, `${resolvedApp.directory}/src/modern-app-env.d.ts`, createAppEnvDts(resolvedApp, remotes));
|
|
27
|
-
writeFile(targetDir, `${resolvedApp.directory}/src/ultramodern-build.ts`,
|
|
27
|
+
writeFile(targetDir, `${resolvedApp.directory}/src/ultramodern-build.ts`, createUltramodernBuildReexportModule());
|
|
28
|
+
writeFile(targetDir, `${resolvedApp.directory}/shared/ultramodern-build.ts`, createUltramodernBuildModule(scope, resolvedApp));
|
|
28
29
|
writeFile(targetDir, publicWeb.jsonLdHelperFile.path, publicWeb.jsonLdHelperFile.content);
|
|
29
30
|
writeFile(targetDir, publicWeb.routeMetadataFile.path, publicWeb.routeMetadataFile.content);
|
|
30
31
|
writeFile(targetDir, publicWeb.routeHeadFile.path, publicWeb.routeHeadFile.content);
|
|
@@ -86,10 +86,12 @@ const createRemoteFallback = (specifier: string) =>
|
|
|
86
86
|
({ error }: { error: Error }) => {
|
|
87
87
|
const { t } = useModernI18n();
|
|
88
88
|
const classification = classifyModuleFederationFallback(error);
|
|
89
|
+
const telemetryEntry =
|
|
90
|
+
typeof window === 'undefined' ? undefined : window.location.href;
|
|
89
91
|
const telemetry = createModuleFederationFallbackTelemetry({
|
|
90
92
|
appName: '${shellApp.id}',
|
|
91
93
|
classification,
|
|
92
|
-
|
|
94
|
+
...(telemetryEntry === undefined ? {} : { entry: telemetryEntry }),
|
|
93
95
|
error,
|
|
94
96
|
eventName: 'mf.client.remote.fallback',
|
|
95
97
|
exportName: 'default',
|
|
@@ -102,7 +104,7 @@ const createRemoteFallback = (specifier: string) =>
|
|
|
102
104
|
void emitModuleFederationFallbackTelemetry({
|
|
103
105
|
appName: telemetry.appName,
|
|
104
106
|
classification,
|
|
105
|
-
entry: telemetry.entry,
|
|
107
|
+
...(telemetry.entry === undefined ? {} : { entry: telemetry.entry }),
|
|
106
108
|
error,
|
|
107
109
|
eventName: telemetry.eventName,
|
|
108
110
|
exportName: 'default',
|
|
@@ -111,7 +113,7 @@ const createRemoteFallback = (specifier: string) =>
|
|
|
111
113
|
remote: specifier,
|
|
112
114
|
status: 'degraded',
|
|
113
115
|
});
|
|
114
|
-
}, [classification, error,
|
|
116
|
+
}, [classification, error, telemetry]);
|
|
115
117
|
|
|
116
118
|
return <div className="${tw('rounded-xl border border-red-900/20 bg-red-50 px-4 py-3 text-sm font-semibold text-red-900')}" data-remote-error={error.name} {...toModuleFederationFallbackAttributes(telemetry)}>{t('shell.remoteUnavailable')}</div>;
|
|
117
119
|
};
|