@hubspot/cms-dev-server 0.16.18 → 0.18.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/dist/generateJsonFromJsx.js +297 -172
- package/dist/index.js +4766 -176
- package/dist/internalSsr.js +260 -151
- package/dist/run.js +1989 -503
- package/dist/storybook-main/main.js +261 -152
- package/package.json +14 -10
- package/types/api/designmanager.d.ts +31 -0
- package/types/api/session.d.ts +2 -0
- package/types/components/HubLModulesList.d.ts +4 -0
- package/types/components/HubLTemplatesList.d.ts +4 -0
- package/types/components/ModulesList.d.ts +5 -0
- package/types/components/PartialsList.d.ts +4 -0
- package/types/createAppServer.d.ts +2 -0
- package/types/createDevServer.d.ts +5 -0
- package/types/createViteDevServer.d.ts +3 -0
- package/types/fileManager.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/lib/configHelpers.d.ts +2 -0
- package/types/lib/criticalDevErrorsToServerMessages.d.ts +4 -0
- package/types/lib/debug.d.ts +1 -0
- package/types/lib/errors.d.ts +6 -0
- package/types/lib/fetchModuleGraphQLData.d.ts +24 -0
- package/types/lib/fullOriginalUrlFromRequest.d.ts +2 -0
- package/types/lib/gates.d.ts +2 -0
- package/types/lib/getJSRenderingGates.d.ts +8 -0
- package/types/lib/httpsRedirectingServer.d.ts +11 -0
- package/types/lib/logColors.d.ts +6 -0
- package/types/lib/moduleGraph.d.ts +1 -0
- package/types/lib/packagePath.d.ts +1 -0
- package/types/lib/pathHelpers.d.ts +3 -0
- package/types/lib/previewUtils.d.ts +22 -0
- package/types/lib/proxyHelpers.d.ts +29 -0
- package/types/lib/renderComponentWithCSS.d.ts +14 -0
- package/types/lib/renderHelpers.d.ts +1 -0
- package/types/lib/renderModule.d.ts +11 -0
- package/types/lib/renderModulePreview.d.ts +5 -0
- package/types/lib/renderPartial.d.ts +5 -0
- package/types/lib/templates.d.ts +4 -0
- package/types/lib/trackUsage.d.ts +3 -0
- package/types/lib/validateHSPlatform.d.ts +3 -0
- package/types/lib/watchFieldsUpdates.d.ts +22 -0
- package/types/proxyPage/constants.d.ts +1 -0
- package/types/proxyPage/fetchContentMetadata.d.ts +7 -0
- package/types/proxyPage/fetchDomains.d.ts +9 -0
- package/types/proxyPage/fetchPreviewInfo.d.ts +6 -0
- package/types/proxyPage/proxyPage.d.ts +11 -0
- package/types/proxyPage/renderLocalError.d.ts +2 -0
- package/types/proxyPage/utils.d.ts +4 -0
- package/types/routes/createDevServerRoutes.d.ts +3 -0
- package/types/routes/homeRouteHandler.d.ts +3 -0
- package/types/routes/hublModuleRouteHandler.d.ts +2 -0
- package/types/routes/hublTemplateRouteHandler.d.ts +2 -0
- package/types/routes/linksToAllModulesRouteHandler.d.ts +2 -0
- package/types/routes/linksToAllPartialsRouteHandler.d.ts +2 -0
- package/types/routes/meta.d.ts +2 -0
- package/types/routes/module.d.ts +3 -0
- package/types/routes/modulePreviewRouteHandler.d.ts +3 -0
- package/types/routes/partial.d.ts +2 -0
- package/types/routes/proxyPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPageRouteHandler.d.ts +2 -0
- package/types/routes/proxyPathPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPathPageRouteHandler.d.ts +2 -0
- package/types/routes/proxyServerlessHandler.d.ts +2 -0
- package/types/routes/remoteFsDirtyHandler.d.ts +2 -0
- package/types/shadowDevServer/createShadowDevServerRoutes.d.ts +2 -0
- package/types/shadowDevServer/startShadowDevServer.d.ts +2 -0
- package/dist/generateJsonFromJsx.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/internalSsr.js.map +0 -7
- package/dist/island-runtime.js.map +0 -7
- package/dist/run.js.map +0 -7
- package/dist/storybook/index.js.map +0 -7
- package/dist/storybook-main/main.js.map +0 -7
- package/dist/storybook-main/preview.js.map +0 -7
- package/types/island-runtime.d.ts +0 -2
package/dist/internalSsr.js
CHANGED
|
@@ -319,12 +319,16 @@ var GATES = [
|
|
|
319
319
|
"CMS:JSRenderer:ModuleHubl",
|
|
320
320
|
"CMS:JSRenderer:RemoveCjsPlugin",
|
|
321
321
|
"CMS:JSRenderer:RemoveMockClientEntryPlugin",
|
|
322
|
-
"CMS:JSRenderer:AnalyzeCmsModules"
|
|
322
|
+
"CMS:JSRenderer:AnalyzeCmsModules",
|
|
323
|
+
"CMS:JSRenderer:ClientOnlySupplementalFieldSerialization",
|
|
324
|
+
"CMS:React:UnifiedThemePreview"
|
|
323
325
|
];
|
|
324
326
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
325
327
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
326
328
|
"cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
|
|
327
|
-
"cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
|
|
329
|
+
"cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
|
|
330
|
+
"cms:jsr:clientOnlySupplementalFieldSerialization": "CMS:JSRenderer:ClientOnlySupplementalFieldSerialization",
|
|
331
|
+
"cms:react:unifiedThemePreview": "CMS:React:UnifiedThemePreview"
|
|
328
332
|
};
|
|
329
333
|
function isUngatedFor(gates, gate) {
|
|
330
334
|
return gates.includes(gate);
|
|
@@ -457,7 +461,7 @@ import * as cmsComponents from "@hubspot/cms-components";
|
|
|
457
461
|
import { ServerRenderContext } from "@hubspot/cms-components";
|
|
458
462
|
import { isValidElement, cloneElement } from "react";
|
|
459
463
|
var { setProperty, getProperty, hasProperty } = dotProp;
|
|
460
|
-
var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
|
|
464
|
+
var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
|
|
461
465
|
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
462
466
|
({
|
|
463
467
|
id,
|
|
@@ -499,6 +503,9 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
|
|
|
499
503
|
if (filteredSupplementalFieldValues) {
|
|
500
504
|
output.supplementalFieldValues = filteredSupplementalFieldValues;
|
|
501
505
|
}
|
|
506
|
+
if (isUngatedForClientOnlySupplementalFieldSerialization && output.clientOnly) {
|
|
507
|
+
output.supplementalFieldValues = supplementalFieldValues;
|
|
508
|
+
}
|
|
502
509
|
return output;
|
|
503
510
|
}
|
|
504
511
|
);
|
|
@@ -594,7 +601,7 @@ function getPerServerRequestUrls(perServerRequestData, viteDevServer) {
|
|
|
594
601
|
});
|
|
595
602
|
return perServerRequestDataWithUrls;
|
|
596
603
|
}
|
|
597
|
-
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
|
|
604
|
+
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
|
|
598
605
|
const islands = getIslandUrls(roots, viteDevServer);
|
|
599
606
|
const perServerRequestDataWithUrls = getPerServerRequestUrls(
|
|
600
607
|
perServerRequestData,
|
|
@@ -606,7 +613,8 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
606
613
|
islands,
|
|
607
614
|
perServerRequestData,
|
|
608
615
|
indent,
|
|
609
|
-
prettyPrint
|
|
616
|
+
prettyPrint,
|
|
617
|
+
isUngatedForClientOnlySupplementalFieldSerialization
|
|
610
618
|
)}${writeSharedStateToJsGlobal(
|
|
611
619
|
islands,
|
|
612
620
|
perServerRequestDataWithUrls,
|
|
@@ -638,6 +646,7 @@ function noncePlaceholderPlugin() {
|
|
|
638
646
|
}
|
|
639
647
|
var traverse = _traverse.default;
|
|
640
648
|
var CMS_MODULE_COMPONENT_NAME = "Module";
|
|
649
|
+
var PLUGIN_NAME = "findCmsModules";
|
|
641
650
|
function findCmsModules(cmsModules = {}) {
|
|
642
651
|
let config;
|
|
643
652
|
return {
|
|
@@ -648,80 +657,14 @@ function findCmsModules(cmsModules = {}) {
|
|
|
648
657
|
},
|
|
649
658
|
transform(code, id) {
|
|
650
659
|
const moduleInfo = this.getModuleInfo(id);
|
|
651
|
-
|
|
652
|
-
if (isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME)) {
|
|
660
|
+
if (shouldSkipModule(config, moduleInfo, code))
|
|
653
661
|
return null;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let moduleLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
661
|
-
let moduleUsed = false;
|
|
662
|
-
const pluginError = this.error.bind(this);
|
|
663
|
-
traverse(sourceAst, {
|
|
664
|
-
ImportDeclaration(path2) {
|
|
665
|
-
if (!t.isStringLiteral(path2.node.source, {
|
|
666
|
-
value: "@hubspot/cms-components"
|
|
667
|
-
})) {
|
|
668
|
-
return null;
|
|
669
|
-
}
|
|
670
|
-
for (const specifier of path2.node.specifiers) {
|
|
671
|
-
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
672
|
-
name: CMS_MODULE_COMPONENT_NAME
|
|
673
|
-
})) {
|
|
674
|
-
moduleLocalImportName = specifier.local.name;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
JSXOpeningElement(path2) {
|
|
679
|
-
if (!t.isJSXIdentifier(path2.node.name, {
|
|
680
|
-
name: moduleLocalImportName
|
|
681
|
-
})) {
|
|
682
|
-
return null;
|
|
683
|
-
}
|
|
684
|
-
moduleUsed = true;
|
|
685
|
-
let cmsModuleName;
|
|
686
|
-
let cmsModulePath;
|
|
687
|
-
let cmsModuleLabel;
|
|
688
|
-
for (const prop of path2.node.attributes) {
|
|
689
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
690
|
-
cmsModuleName = prop.value.value;
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "path" }) && t.isStringLiteral(prop.value)) {
|
|
694
|
-
cmsModulePath = prop.value.value;
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "label" }) && t.isStringLiteral(prop.value)) {
|
|
698
|
-
cmsModuleLabel = prop.value.value;
|
|
699
|
-
continue;
|
|
700
|
-
}
|
|
701
|
-
pluginError(
|
|
702
|
-
new Error(
|
|
703
|
-
`Error: ${id.replace(config.root, "")}:${prop.loc.start.line} "name" and "path" must be primitive strings`
|
|
704
|
-
)
|
|
705
|
-
);
|
|
706
|
-
return null;
|
|
707
|
-
}
|
|
708
|
-
const cmsModuleProps = {
|
|
709
|
-
name: cmsModuleName,
|
|
710
|
-
path: cmsModulePath
|
|
711
|
-
};
|
|
712
|
-
if (cmsModuleLabel) {
|
|
713
|
-
cmsModuleProps.label = cmsModuleLabel;
|
|
714
|
-
}
|
|
715
|
-
if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {
|
|
716
|
-
pluginError(
|
|
717
|
-
new Error(
|
|
718
|
-
`Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`
|
|
719
|
-
)
|
|
720
|
-
);
|
|
721
|
-
}
|
|
722
|
-
localCmsModules[cmsModuleProps.name] = cmsModuleProps;
|
|
723
|
-
}
|
|
724
|
-
});
|
|
662
|
+
const { localCmsModules, moduleUsed } = analyzeSourceCodeUsages(
|
|
663
|
+
this,
|
|
664
|
+
moduleInfo,
|
|
665
|
+
config,
|
|
666
|
+
code
|
|
667
|
+
);
|
|
725
668
|
if (!moduleUsed) {
|
|
726
669
|
return null;
|
|
727
670
|
}
|
|
@@ -734,95 +677,261 @@ function findCmsModules(cmsModules = {}) {
|
|
|
734
677
|
buildEnd(error) {
|
|
735
678
|
if (error)
|
|
736
679
|
throw error;
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
680
|
+
const entryPoints = getEntryPoints(this, config);
|
|
681
|
+
const entryPointCmsModuleMap = buildEntryPointsCmsModuleMap(
|
|
682
|
+
this,
|
|
683
|
+
entryPoints
|
|
741
684
|
);
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
685
|
+
const relativeEntryPointCmsModuleMap = convertEntryPointPathsToRelative(
|
|
686
|
+
config,
|
|
687
|
+
entryPointCmsModuleMap
|
|
688
|
+
);
|
|
689
|
+
const entryPointIslandCmsModuleMap = buildEntryPointIslandsCmsModuleMap(
|
|
690
|
+
this,
|
|
691
|
+
entryPoints
|
|
692
|
+
);
|
|
693
|
+
const relativeEntryPointIslandCmsModuleMap = convertEntryPointIslandPathsToRelative(
|
|
694
|
+
config,
|
|
695
|
+
entryPointIslandCmsModuleMap
|
|
696
|
+
);
|
|
697
|
+
if (Object.keys(relativeEntryPointIslandCmsModuleMap).length > 0) {
|
|
698
|
+
this.error(`
|
|
699
|
+
Error: <Module /> cannot be used within <Island />
|
|
700
|
+
Found invalid usages:
|
|
701
|
+
${JSON.stringify(relativeEntryPointIslandCmsModuleMap, null, 2)}
|
|
758
702
|
`);
|
|
759
|
-
}
|
|
760
703
|
}
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
${formatIslandImporter(
|
|
771
|
-
moduleWithCmsModuleUsage.id,
|
|
772
|
-
root
|
|
773
|
-
)} uses <${CMS_MODULE_COMPONENT_NAME} /> and is used by islands:
|
|
774
|
-
${islandsContainingCmsModuleUsage.map(
|
|
775
|
-
(islandModuleInfo) => formatIslandImporter(islandModuleInfo.id, root)
|
|
776
|
-
).join(", ")}
|
|
777
|
-
`);
|
|
778
|
-
}
|
|
704
|
+
const modulesWithinModules = filterEntryPointsToModules(
|
|
705
|
+
relativeEntryPointCmsModuleMap
|
|
706
|
+
);
|
|
707
|
+
if (Object.keys(modulesWithinModules).length > 0) {
|
|
708
|
+
this.error(`
|
|
709
|
+
Error: <Module /> can only be used in React Partials
|
|
710
|
+
Found invalid usages:
|
|
711
|
+
${JSON.stringify(modulesWithinModules, null, 2)}
|
|
712
|
+
`);
|
|
779
713
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
714
|
+
Object.assign(cmsModules, relativeEntryPointCmsModuleMap);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function convertEntryPointPathsToRelative(config, entryPointsCmsModuleMap) {
|
|
719
|
+
const relativeEntries = Object.entries(entryPointsCmsModuleMap).map(
|
|
720
|
+
([entryPointPath, cmsModules]) => {
|
|
721
|
+
return [toRelativePath(config, entryPointPath), cmsModules];
|
|
722
|
+
}
|
|
723
|
+
);
|
|
724
|
+
return Object.fromEntries(relativeEntries);
|
|
725
|
+
}
|
|
726
|
+
function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap) {
|
|
727
|
+
const relativeEntries = Object.entries(entryPointsCmsModuleMap).map(
|
|
728
|
+
([entryPointPath, islandCmsModules]) => {
|
|
729
|
+
const islandCmsModuleUsage = Object.fromEntries(
|
|
730
|
+
Object.entries(islandCmsModules).map(([islandPath, cmsModule]) => {
|
|
731
|
+
return [
|
|
732
|
+
toRelativePath(config, islandPath).replace("?client-entry", ""),
|
|
733
|
+
cmsModule
|
|
734
|
+
];
|
|
735
|
+
})
|
|
736
|
+
);
|
|
737
|
+
return [toRelativePath(config, entryPointPath), islandCmsModuleUsage];
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
return Object.fromEntries(relativeEntries);
|
|
741
|
+
}
|
|
742
|
+
function toRelativePath(config, path2) {
|
|
743
|
+
return path2.replace(config.root, "");
|
|
744
|
+
}
|
|
745
|
+
function shouldSkipModule(config, moduleInfo, code) {
|
|
746
|
+
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
747
|
+
return isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME);
|
|
748
|
+
}
|
|
749
|
+
function getEntryPoints(ctx, config) {
|
|
750
|
+
return Array.from(ctx.getModuleIds()).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => ctx.getModuleInfo(moduleId)).filter((moduleInfo) => moduleInfo.isEntry);
|
|
751
|
+
}
|
|
752
|
+
function buildEntryPointsCmsModuleMap(ctx, entryPoints) {
|
|
753
|
+
const entryPointCmsModuleUsage = {};
|
|
754
|
+
for (const entryPoint of entryPoints) {
|
|
755
|
+
const result = findCmsModuleUsages(ctx, entryPoint.id);
|
|
756
|
+
if (result) {
|
|
757
|
+
entryPointCmsModuleUsage[entryPoint.id] = result;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return entryPointCmsModuleUsage;
|
|
761
|
+
}
|
|
762
|
+
function buildEntryPointIslandsCmsModuleMap(ctx, entryPoints) {
|
|
763
|
+
const entryPointIslandsCmsModuleMap = {};
|
|
764
|
+
for (const entryPoint of entryPoints) {
|
|
765
|
+
const result = findIslandCmsModuleUsage(ctx, entryPoint.id);
|
|
766
|
+
if (result) {
|
|
767
|
+
entryPointIslandsCmsModuleMap[entryPoint.id] = result;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return entryPointIslandsCmsModuleMap;
|
|
771
|
+
}
|
|
772
|
+
function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
773
|
+
const sourceAst = parser.parse(code, {
|
|
774
|
+
sourceType: "module",
|
|
775
|
+
plugins: ["jsx", "typescript"]
|
|
776
|
+
});
|
|
777
|
+
const localCmsModules = {};
|
|
778
|
+
let moduleUsed = false;
|
|
779
|
+
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
780
|
+
traverse(sourceAst, {
|
|
781
|
+
ImportDeclaration(path2) {
|
|
782
|
+
if (t.isStringLiteral(path2.node.source, {
|
|
783
|
+
value: "@hubspot/cms-components"
|
|
784
|
+
})) {
|
|
785
|
+
for (const specifier of path2.node.specifiers) {
|
|
786
|
+
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
787
|
+
name: CMS_MODULE_COMPONENT_NAME
|
|
788
|
+
})) {
|
|
789
|
+
moduleComponentLocalImportName = specifier.local.name;
|
|
794
790
|
}
|
|
795
791
|
}
|
|
796
792
|
}
|
|
793
|
+
},
|
|
794
|
+
JSXOpeningElement(path2) {
|
|
795
|
+
if (!t.isJSXIdentifier(path2.node.name, {
|
|
796
|
+
name: moduleComponentLocalImportName
|
|
797
|
+
})) {
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
moduleUsed = true;
|
|
801
|
+
let cmsModuleName;
|
|
802
|
+
let cmsModulePath;
|
|
803
|
+
let cmsModuleLabel;
|
|
804
|
+
for (const prop of path2.node.attributes) {
|
|
805
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
806
|
+
cmsModuleName = prop.value.value;
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "path" }) && t.isStringLiteral(prop.value)) {
|
|
810
|
+
cmsModulePath = prop.value.value;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "label" }) && t.isStringLiteral(prop.value)) {
|
|
814
|
+
cmsModuleLabel = prop.value.value;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
ctx.error(
|
|
818
|
+
new Error(
|
|
819
|
+
`Error: ${moduleInfo.id.replace(config.root, "")}:${prop.loc.start.line} "name" and "path" must be primitive strings`
|
|
820
|
+
)
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
const cmsModuleProps = {
|
|
824
|
+
name: cmsModuleName,
|
|
825
|
+
path: cmsModulePath
|
|
826
|
+
};
|
|
827
|
+
if (cmsModuleLabel) {
|
|
828
|
+
cmsModuleProps.label = cmsModuleLabel;
|
|
829
|
+
}
|
|
830
|
+
if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {
|
|
831
|
+
ctx.error(
|
|
832
|
+
new Error(
|
|
833
|
+
`Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`
|
|
834
|
+
)
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
localCmsModules[cmsModuleProps.name] = cmsModuleProps;
|
|
797
838
|
}
|
|
839
|
+
});
|
|
840
|
+
return {
|
|
841
|
+
moduleUsed,
|
|
842
|
+
localCmsModules
|
|
798
843
|
};
|
|
799
844
|
}
|
|
800
|
-
function
|
|
801
|
-
if (
|
|
802
|
-
return [
|
|
845
|
+
function findCmsModuleUsages(ctx, moduleId, processed = /* @__PURE__ */ new Set(), result = {}) {
|
|
846
|
+
if (Object.hasOwn(result, moduleId)) {
|
|
847
|
+
return result[moduleId];
|
|
803
848
|
}
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
849
|
+
const moduleInfo = ctx.getModuleInfo(moduleId);
|
|
850
|
+
let entryPointModules = null;
|
|
851
|
+
if (Object.hasOwn(moduleInfo.meta, PLUGIN_NAME)) {
|
|
852
|
+
entryPointModules = {
|
|
853
|
+
...entryPointModules,
|
|
854
|
+
...moduleInfo.meta[PLUGIN_NAME]
|
|
855
|
+
};
|
|
809
856
|
}
|
|
810
|
-
|
|
857
|
+
for (const importedId of [
|
|
858
|
+
...moduleInfo.importedIds,
|
|
859
|
+
...moduleInfo.dynamicallyImportedIds
|
|
860
|
+
]) {
|
|
861
|
+
if (processed.has(importedId)) {
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
const importedResult = findCmsModuleUsages(
|
|
865
|
+
ctx,
|
|
866
|
+
importedId,
|
|
867
|
+
processed,
|
|
868
|
+
result
|
|
869
|
+
);
|
|
870
|
+
if (importedResult) {
|
|
871
|
+
entryPointModules = {
|
|
872
|
+
...entryPointModules,
|
|
873
|
+
...importedResult
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (entryPointModules) {
|
|
878
|
+
result[moduleId] = entryPointModules;
|
|
879
|
+
}
|
|
880
|
+
processed.add(moduleId);
|
|
881
|
+
return entryPointModules;
|
|
811
882
|
}
|
|
812
|
-
function
|
|
813
|
-
|
|
814
|
-
|
|
883
|
+
function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__ */ new Set(), islandModuleResults = {}, processed = /* @__PURE__ */ new Set(), results = {}) {
|
|
884
|
+
processedIslands.add(moduleId);
|
|
885
|
+
if (Object.hasOwn(islandModuleResults, moduleId)) {
|
|
886
|
+
return islandModuleResults[moduleId];
|
|
815
887
|
}
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
888
|
+
const moduleInfo = ctx.getModuleInfo(moduleId);
|
|
889
|
+
let resultForModuleId = {};
|
|
890
|
+
if (moduleInfo.id.endsWith("?client-entry")) {
|
|
891
|
+
const mergedDataDependencies = findCmsModuleUsages(
|
|
892
|
+
ctx,
|
|
893
|
+
moduleInfo.id,
|
|
894
|
+
processed,
|
|
895
|
+
results
|
|
896
|
+
);
|
|
897
|
+
if (mergedDataDependencies) {
|
|
898
|
+
resultForModuleId[moduleInfo.id] = mergedDataDependencies;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
for (const importedId of [
|
|
902
|
+
...moduleInfo.importedIds,
|
|
903
|
+
...moduleInfo.dynamicallyImportedIds
|
|
904
|
+
]) {
|
|
905
|
+
if (processedIslands.has(importedId)) {
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
const importerCmsModuleUsageResult = findIslandCmsModuleUsage(
|
|
909
|
+
ctx,
|
|
910
|
+
importedId,
|
|
911
|
+
processedIslands,
|
|
912
|
+
islandModuleResults,
|
|
913
|
+
processed,
|
|
914
|
+
results
|
|
915
|
+
);
|
|
916
|
+
if (importerCmsModuleUsageResult) {
|
|
917
|
+
resultForModuleId = {
|
|
918
|
+
...resultForModuleId,
|
|
919
|
+
...importerCmsModuleUsageResult
|
|
920
|
+
};
|
|
921
|
+
}
|
|
821
922
|
}
|
|
822
|
-
|
|
923
|
+
if (Object.keys(resultForModuleId).length > 0) {
|
|
924
|
+
islandModuleResults[moduleId] = resultForModuleId;
|
|
925
|
+
return resultForModuleId;
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
823
928
|
}
|
|
824
|
-
function
|
|
825
|
-
return
|
|
929
|
+
function filterEntryPointsToModules(entryPointCmsModuleMap) {
|
|
930
|
+
return Object.fromEntries(
|
|
931
|
+
Object.entries(entryPointCmsModuleMap).filter(
|
|
932
|
+
([entryPoint]) => entryPoint.startsWith("/components/modules/")
|
|
933
|
+
)
|
|
934
|
+
);
|
|
826
935
|
}
|
|
827
936
|
var promiseForNewWritableStream = () => {
|
|
828
937
|
const chunks = [];
|