@hubspot/cms-dev-server 0.4.0 → 0.4.2

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.
@@ -14,6 +14,7 @@ import { debug } from './lib/debug.js';
14
14
  import { getEnv, getAccountId, loadConfig, validateConfig, } from '@hubspot/cli-lib/lib/config.js';
15
15
  import { fetchWebsiteDomainNames } from './proxyPage/fetchDomains.js';
16
16
  import { logMissingScopeWarning, MissingScopeError } from './lib/errors.js';
17
+ const sharedDepsEnabled = Boolean(process.env.SHARED_DEPS_ENABLED);
17
18
  const BASE_PATH = '/';
18
19
  const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
19
20
  const SHADOW_PORT = 1442;
@@ -71,7 +72,7 @@ Local proxy functionality will not work without setting up authentication.`);
71
72
  const authedHublet = 'na1';
72
73
  const absoluteWebRoot = normalizePath(path.resolve(process.cwd(), webRoot));
73
74
  const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, '').split('/').slice(-2);
74
- const viteServer = await createViteDevServer(absoluteWebRoot, PORT, sslEnabledOption, domainsToProxy);
75
+ const viteServer = await createViteDevServer(absoluteWebRoot, PORT, sslEnabledOption, domainsToProxy, sharedDepsEnabled);
75
76
  // Get https key and cert from the vite config set by vite-plugin-mkcert (if it worked )
76
77
  const viteHTTPSConfig = viteServer.config.server.https;
77
78
  const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
@@ -87,6 +88,7 @@ Local proxy functionality will not work without setting up authentication.`);
87
88
  expressServer.locals.authedHublet = authedHublet;
88
89
  expressServer.locals.storybookEnabled = storybook;
89
90
  expressServer.locals.storybookPort = STORYBOOK_PORT;
91
+ expressServer.locals.sharedDepsEnabled = sharedDepsEnabled;
90
92
  expressServer.locals.projectName = getProjectNameFromHSConfig(path.join(webRoot, '../hsproject.json'));
91
93
  expressServer.locals.projectComponentPath = webRootProjectComponentFolder;
92
94
  expressServer.use(bodyParser.json());
@@ -125,7 +127,7 @@ HubSpot CMS dev server hosting: ${expressServer.locals.projectName}/${expressSer
125
127
  if (storybook) {
126
128
  const packageRoot = path.dirname(url.fileURLToPath(import.meta.url));
127
129
  const configPath = path.resolve(packageRoot, './storybook');
128
- const storybookProcess = spawn('yarn', [
130
+ const storybookProcess = spawn('npx', [
129
131
  'sb',
130
132
  'dev',
131
133
  '-p',
@@ -0,0 +1,155 @@
1
+ import path from 'path';
2
+ import url from 'url';
3
+ import express from 'express';
4
+ import http from 'http';
5
+ import { spawn } from 'child_process';
6
+ import { normalizePath } from 'vite';
7
+ import createDevServerRoutes from './routes/createDevServerRoutes.js';
8
+ import startShadowDevServer from './shadowDevServer/startShadowDevServer.js';
9
+ import { getProjectNameFromHSConfig } from './lib/proxyHelpers.js';
10
+ import createViteDevServer from './createViteDevServer.js';
11
+ import { createHttpsRedirectingServer } from './lib/httpsRedirectingServer.js';
12
+ import { debug } from './lib/debug.js';
13
+ import { getEnv, getAccountId, loadConfig, validateConfig, } from '@hubspot/cli-lib/lib/config.js';
14
+ import { fetchWebsiteDomainNames } from './proxyPage/fetchDomains.js';
15
+ import { logMissingScopeWarning, MissingScopeError } from './lib/errors.js';
16
+ async function createDevServer(devServerConfiguration) {
17
+ const { basePath, shadowPort, storybookPort, webRoot, storybookEnabled, hubspotCliConfigPathOption, hubspotCliAccountNameOption, sslEnabled, port, } = devServerConfiguration;
18
+ console.log('Warning: this is a prerelease and requires specific HubSpot account configuration to work');
19
+ let authedPortalId = null;
20
+ let authedEnv = null;
21
+ if (hubspotCliConfigPathOption && hubspotCliAccountNameOption) {
22
+ console.log(`Loading HS auth (account = ${hubspotCliAccountNameOption}) configuration at: ${hubspotCliConfigPathOption}`);
23
+ }
24
+ else if (hubspotCliConfigPathOption) {
25
+ console.log(`Loading HS auth configuration at: ${hubspotCliConfigPathOption}`);
26
+ }
27
+ else if (hubspotCliAccountNameOption) {
28
+ console.log(`Loading HS auth (account = ${hubspotCliAccountNameOption}) configuration.`);
29
+ }
30
+ // If a custom hubspot.config.yaml config path was set, make sure to force load that before
31
+ // any hs config values are read
32
+ loadConfig(hubspotCliConfigPathOption || null, { useEnv: false });
33
+ if (validateConfig()) {
34
+ authedPortalId = getAccountId(hubspotCliAccountNameOption);
35
+ authedEnv = getEnv(hubspotCliAccountNameOption);
36
+ if (!authedPortalId && hubspotCliAccountNameOption) {
37
+ console.error(`Couldn't find ${hubspotCliAccountNameOption} in your hubspot.config.yaml`);
38
+ process.exit(1);
39
+ }
40
+ }
41
+ else {
42
+ console.warn(`Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
43
+ If needed you can refer to another config file with --config.
44
+
45
+ Local proxy functionality will not work without setting up authentication.`);
46
+ }
47
+ let domainsToProxy = [];
48
+ if (sslEnabled && authedPortalId) {
49
+ try {
50
+ const portalDomains = await fetchWebsiteDomainNames(authedPortalId);
51
+ domainsToProxy = (process.env.DOMAINS_TO_PROXY || '')
52
+ .split(',')
53
+ .filter(d => !!d);
54
+ domainsToProxy = [...domainsToProxy, ...portalDomains];
55
+ }
56
+ catch (e) {
57
+ if (e instanceof MissingScopeError) {
58
+ logMissingScopeWarning(e);
59
+ }
60
+ else {
61
+ console.warn(`Failed to fetch domains for ${authedPortalId}, HTTPS proxying won't work with them.`);
62
+ }
63
+ }
64
+ }
65
+ const authedHublet = 'na1';
66
+ const absoluteWebRoot = normalizePath(path.resolve(process.cwd(), webRoot));
67
+ const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, '').split('/').slice(-2);
68
+ const viteServer = await createViteDevServer(absoluteWebRoot, port, sslEnabled, domainsToProxy);
69
+ // Get https key and cert from the vite config set by vite-plugin-mkcert (if it worked )
70
+ const viteHTTPSConfig = viteServer.config.server.https;
71
+ const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
72
+ const httpsCert = viteHTTPSConfig ? viteHTTPSConfig.cert : null;
73
+ const httpServers = [];
74
+ const expressServer = express();
75
+ expressServer.locals.devServerHost = 'hslocal.net';
76
+ expressServer.locals.devServerPort = port;
77
+ expressServer.locals.webRoot = webRoot;
78
+ expressServer.locals.viteServer = viteServer;
79
+ expressServer.locals.authedPortalId = authedPortalId;
80
+ expressServer.locals.authedEnv = authedEnv;
81
+ expressServer.locals.authedHublet = authedHublet;
82
+ expressServer.locals.storybookEnabled = storybookEnabled;
83
+ expressServer.locals.storybookPort = storybookPort;
84
+ expressServer.locals.projectName = getProjectNameFromHSConfig(path.join(webRoot, '../hsproject.json'));
85
+ expressServer.locals.projectComponentPath = webRootProjectComponentFolder;
86
+ expressServer.use(basePath, await createDevServerRoutes(viteServer, storybookEnabled ? storybookPort : null));
87
+ if (sslEnabled) {
88
+ if (httpsKey && httpsCert) {
89
+ const { server, innerHTTPServer, innerHTTPSServer } = createHttpsRedirectingServer({ key: httpsKey, cert: httpsCert }, expressServer);
90
+ server.listen(port);
91
+ httpServers.push(server);
92
+ // Not sure if we need to worry about closing all of these, but🤷
93
+ httpServers.push(innerHTTPServer);
94
+ httpServers.push(innerHTTPSServer);
95
+ }
96
+ else {
97
+ console.error('Failed to start a HTTPS server, try --no-ssl');
98
+ process.exit(1);
99
+ }
100
+ }
101
+ else {
102
+ const httpServer = http.createServer(expressServer);
103
+ httpServer.listen(port);
104
+ httpServers.push(httpServer);
105
+ }
106
+ startShadowDevServer(port, shadowPort);
107
+ let extraServerInfo = '';
108
+ const protocol = sslEnabled ? 'https' : 'http';
109
+ if (authedPortalId) {
110
+ extraServerInfo += `, hubid=${authedPortalId}`;
111
+ }
112
+ if (authedEnv && authedEnv !== 'prod') {
113
+ extraServerInfo += `, env=${authedEnv}`;
114
+ }
115
+ console.log(`
116
+ HubSpot CMS dev server hosting: ${expressServer.locals.projectName}/${expressServer.locals.projectComponentPath} (at ${protocol}://hslocal.net:${port}${extraServerInfo})
117
+ `);
118
+ if (storybookEnabled) {
119
+ const packageRoot = path.dirname(url.fileURLToPath(import.meta.url));
120
+ const configPath = path.resolve(packageRoot, './storybook');
121
+ const storybookProcess = spawn('yarn', [
122
+ 'sb',
123
+ 'dev',
124
+ '-p',
125
+ storybookPort.toString(),
126
+ '-c',
127
+ configPath,
128
+ '--quiet',
129
+ '--no-open',
130
+ ], {
131
+ cwd: process.cwd(),
132
+ env: {
133
+ ...process.env,
134
+ WEB_ROOT: path.join(webRoot, 'components'),
135
+ },
136
+ });
137
+ console.log(`Starting storybook server on port ${storybookPort}`);
138
+ if (debug.enabled) {
139
+ storybookProcess.stdout.pipe(process.stdout);
140
+ }
141
+ storybookProcess.stderr.pipe(process.stderr);
142
+ }
143
+ // Return hook to shut down server gracefully
144
+ return {
145
+ close: () => {
146
+ const serverClosePromises = httpServers.map(server => new Promise(resolve => {
147
+ server.close(() => {
148
+ resolve(null);
149
+ });
150
+ }));
151
+ return Promise.allSettled([...serverClosePromises, viteServer.close()]);
152
+ },
153
+ };
154
+ }
155
+ export default createDevServer;
@@ -2,9 +2,9 @@
2
2
  /* eslint-disable require-await */
3
3
  import { createServer as createViteServer } from 'vite';
4
4
  import { default as react } from '@vitejs/plugin-react';
5
- import { resolveIslandPlugin } from '@hubspot/cms-js-internal';
5
+ import { clientIslandEntryPlugin, resolveIslandPlugin, } from '@hubspot/cms-js-internal';
6
6
  import mkcert from 'vite-plugin-mkcert';
7
- async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = []) {
7
+ async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], sharedDepsEnabled) {
8
8
  const additionalMkcertHosts = domainsToProxy
9
9
  .map(proxyDomain => [
10
10
  `${proxyDomain}.localhost`,
@@ -40,7 +40,8 @@ async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [
40
40
  plugins: [
41
41
  sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
42
42
  react(),
43
- resolveIslandPlugin(),
43
+ sharedDepsEnabled && clientIslandEntryPlugin(),
44
+ resolveIslandPlugin({ sharedDepsEnabled }),
44
45
  ],
45
46
  css: {
46
47
  postcss: webRoot,
package/dist/index.js CHANGED
@@ -52,13 +52,24 @@ function resolveIslandPlugin() {
52
52
  }
53
53
 
54
54
  // src/createViteDevServer.ts
55
- var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
56
- async function createViteDevServer(webRoot) {
55
+ import mkcert from "vite-plugin-mkcert";
56
+ async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = []) {
57
+ const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
58
+ `${proxyDomain}.localhost`,
59
+ `${proxyDomain}.hslocal.net`
60
+ ]).flat();
61
+ additionalMkcertHosts.push("*.hslocal.net", "hslocal.net");
62
+ const origin = sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`;
57
63
  const viteConfig = {
58
64
  appType: "custom",
59
65
  server: {
60
66
  middlewareMode: true,
61
- origin: `http://localhost:${PORT}`
67
+ host: "hslocal.net",
68
+ origin,
69
+ https: sslEnabled,
70
+ hmr: {
71
+ protocol: sslEnabled ? "wss" : void 0
72
+ }
62
73
  },
63
74
  ssr: {
64
75
  // TODO: might need more entries here to get things to resolve through
@@ -71,10 +82,14 @@ async function createViteDevServer(webRoot) {
71
82
  optimizeDeps: {
72
83
  include: ["react", "react-dom", "react-dom/client"]
73
84
  },
85
+ plugins: [
86
+ sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
87
+ react(),
88
+ resolveIslandPlugin()
89
+ ],
74
90
  css: {
75
91
  postcss: webRoot
76
- },
77
- plugins: [react(), resolveIslandPlugin()]
92
+ }
78
93
  };
79
94
  return createViteServer(viteConfig);
80
95
  }
@@ -0,0 +1,63 @@
1
+ import { resolve } from 'path';
2
+ const BASE_PATH = '/';
3
+ const AUTHED_HUBLET = 'na1';
4
+ /**
5
+ * Command line options
6
+ * --ssl
7
+ * --c (--config)
8
+ * --a (--account)
9
+ */
10
+ export function getDevServerConfiguration(args) {
11
+ const commandLineOptions = getCommandLineOptions(args);
12
+ const environmentVariables = getEnvironmentVariables();
13
+ return {
14
+ ...commandLineOptions,
15
+ ...environmentVariables,
16
+ authedHublet: AUTHED_HUBLET,
17
+ };
18
+ }
19
+ function getCommandLineOptions(args) {
20
+ const webRoot = args[2];
21
+ let hubspotCliConfigPathOption;
22
+ let hubspotCliAccountNameOption;
23
+ // Very basic CLI option parsing
24
+ const configOptionIndex = args.findIndex(arg => arg === '-c' || arg === '--config');
25
+ if (configOptionIndex > 0 && args.length > configOptionIndex) {
26
+ hubspotCliConfigPathOption = resolve(args[configOptionIndex + 1]);
27
+ args.splice(configOptionIndex, 2);
28
+ }
29
+ const accountOptionIndex = args.findIndex(arg => arg === '-a' || arg === '--account');
30
+ if (accountOptionIndex > 0 && args.length > accountOptionIndex) {
31
+ hubspotCliAccountNameOption = args[accountOptionIndex + 1];
32
+ args.splice(accountOptionIndex, 2);
33
+ }
34
+ const sslEnabled = args.includes('--ssl') && !args.includes('--no-ssl');
35
+ const storybookEnabled = args.findIndex(arg => arg === '--storybook') > 0;
36
+ return {
37
+ hubspotCliConfigPathOption,
38
+ hubspotCliAccountNameOption,
39
+ sslEnabled,
40
+ storybookEnabled,
41
+ webRoot,
42
+ };
43
+ }
44
+ function getEnvironmentVariables() {
45
+ // Ports
46
+ const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
47
+ const storybookPort = process.env.STORYBOOK_PORT
48
+ ? parseInt(process.env.STORYBOOK_PORT, 10)
49
+ : 3123;
50
+ const shadowPort = process.env.SHADOW_PORT
51
+ ? parseInt(process.env.SHADOW_PORT, 10)
52
+ : 1442;
53
+ const domainsToProxy = (process.env.DOMAINS_TO_PROXY || '')
54
+ .split(',')
55
+ .filter(d => !!d);
56
+ return {
57
+ basePath: BASE_PATH,
58
+ port,
59
+ storybookPort,
60
+ shadowPort,
61
+ domainsToProxy,
62
+ };
63
+ }
@@ -3,7 +3,18 @@
3
3
  import { promises as fsPromises } from 'fs';
4
4
  import { createIslandsGlobalJsForClientInDev, getServerGlobalsToInject, } from '@hubspot/cms-js-internal';
5
5
  const { readFile } = fsPromises;
6
- const generateIslandSetupScriptBlock = () => {
6
+ const generateIslandSetupScriptBlock = sharedDepsEnabled => {
7
+ if (sharedDepsEnabled) {
8
+ return `<script type="module">
9
+ import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
10
+ initConfigSingletonFromJSON(window.__hsEnvConfig);
11
+ </script>
12
+ <script type="module">
13
+ import { setupIslandHydration } from '@hubspot/cms-components/island-runtime-shared';
14
+ setupIslandHydration();
15
+ </script>
16
+ `;
17
+ }
7
18
  return `<script type="module">
8
19
  import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
9
20
  initConfigSingletonFromJSON(window.__hsEnvConfig);
@@ -20,20 +31,20 @@ const createdPlainHtmlTemplate = async (baseTemplatePath, title, globalScriptBlo
20
31
  ${globalScriptBlock}
21
32
  <!--bodyend-->`);
22
33
  };
23
- const createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock) => {
34
+ const createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock, sharedDepsEnabled) => {
24
35
  let htmlTemplate = await createdPlainHtmlTemplate(baseTemplatePath, title, globalScriptBlock);
25
36
  htmlTemplate = htmlTemplate.replace('<!--bodyend-->', `
26
- ${generateIslandSetupScriptBlock()}
37
+ ${generateIslandSetupScriptBlock(sharedDepsEnabled)}
27
38
  <!-- ISLAND_RUNTIME_AND_SETUP_SCRIPT_BLOCK -->
28
39
  <!--islandsglobal-->
29
40
  `);
30
41
  return htmlTemplate;
31
42
  };
32
- export const createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url, title, renderContext, viteServer) => {
43
+ export const createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url, title, renderContext, viteServer, sharedDepsEnabled) => {
33
44
  let htmlTemplate;
34
45
  if (renderContext.islands.length) {
35
46
  const globalScriptBlock = getServerGlobalsToInject(renderContext.environmentConfig, renderContext.pageUrl);
36
- htmlTemplate = await createIslandHtmlTemplate(baseTemplatePath, title, globalScriptBlock);
47
+ htmlTemplate = await createIslandHtmlTemplate(baseTemplatePath, title, globalScriptBlock, sharedDepsEnabled);
37
48
  htmlTemplate = htmlTemplate.replace('<!--islandsglobal-->', `<script>
38
49
  ${createIslandsGlobalJsForClientInDev(renderContext.islands, viteServer, 4)}
39
50
  </script>
@@ -45,10 +56,10 @@ export const createHtmlShellDependingOnRenderContext = async (baseTemplatePath,
45
56
  }
46
57
  return viteServer.transformIndexHtml(url, htmlTemplate);
47
58
  };
48
- export const getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, viteServer) => {
59
+ export const getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, viteServer, sharedDepsEnabled) => {
49
60
  // Loading through vite so all of nested `@hubspot/cms-*` imports work
50
61
  const { createIslandsGlobalJsForClientInDev } = await viteServer.ssrLoadModule('@hubspot/cms-js-internal');
51
- const islandRuntimeScript = await viteServer.transformIndexHtml('/', generateIslandSetupScriptBlock());
62
+ const islandRuntimeScript = await viteServer.transformIndexHtml('/', generateIslandSetupScriptBlock(sharedDepsEnabled));
52
63
  return `${islandRuntimeScript}
53
64
  <script>${createIslandsGlobalJsForClientInDev(sortedIslandRoots, viteServer, 4)}</script>
54
65
  `;
@@ -77,7 +77,7 @@ const renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholde
77
77
  throw new Error(`Unimplemented render of ${placeholderPath}.`);
78
78
  }
79
79
  };
80
- export default async function proxySpecificPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, urlToProxy, fullOriginalUrl) {
80
+ export default async function proxySpecificPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, sharedDepsEnabled, urlToProxy, fullOriginalUrl) {
81
81
  let accountId;
82
82
  let proxyEnv;
83
83
  try {
@@ -151,7 +151,7 @@ export default async function proxySpecificPage(response, portalId, hublet, cont
151
151
  response.write(getServerGlobalsToInject(environmentConfig, fullOriginalUrl));
152
152
  if (islands.length > 0) {
153
153
  const sortedIslandRoots = sortIslandRootsByPriority(islands);
154
- const islandRuntimeAndGlobalScriptHtml = await getIslandRuntimeAndGlobalToInject(sortedIslandRoots, viteServer);
154
+ const islandRuntimeAndGlobalScriptHtml = await getIslandRuntimeAndGlobalToInject(sortedIslandRoots, viteServer, sharedDepsEnabled);
155
155
  response.write(islandRuntimeAndGlobalScriptHtml);
156
156
  }
157
157
  // Write last string chunk located after last placeholder
@@ -6,7 +6,7 @@ import fullOriginalUrlFromRequest from '../lib/fullOriginalUrlFromRequest.js';
6
6
  import renderModule from '../lib/renderModule.js';
7
7
  import { createHtmlShellDependingOnRenderContext } from '../lib/templates.js';
8
8
  const moduleRouteHandler = async (request, response) => {
9
- const { authedPortalId, authedEnv, authedHublet, webRoot, viteServer } = request.app.locals;
9
+ const { authedPortalId, authedEnv, authedHublet, webRoot, viteServer, sharedDepsEnabled, } = request.app.locals;
10
10
  const moduleName = request.params.moduleName;
11
11
  const baseTemplatePath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), '../html/baseTemplate.html');
12
12
  const modulePath = normalizePath(path.resolve(webRoot, 'components/modules/', moduleName));
@@ -24,7 +24,7 @@ const moduleRouteHandler = async (request, response) => {
24
24
  const environmentConfig = buildStaticEnvConfig(authedPortalId, authedHublet, authedEnv, false);
25
25
  try {
26
26
  const { html: renderedHtml, cssNeeded, renderContext, } = await renderModule(viteServer, modulePath, fieldOverrides, fullOriginalUrlFromRequest(request), environmentConfig);
27
- const htmlShell = await createHtmlShellDependingOnRenderContext(baseTemplatePath, request.originalUrl, `Module: ${modulePath}`, renderContext, viteServer);
27
+ const htmlShell = await createHtmlShellDependingOnRenderContext(baseTemplatePath, request.originalUrl, `Module: ${modulePath}`, renderContext, viteServer, sharedDepsEnabled);
28
28
  const html = htmlShell
29
29
  .replace('<!--headend-->', cssNeeded)
30
30
  .replace(`<!--ssr-outlet-->`, renderedHtml);
@@ -6,14 +6,14 @@ import renderPartial from '../lib/renderPartial.js';
6
6
  import { createHtmlShellDependingOnRenderContext } from '../lib/templates.js';
7
7
  import { buildStaticEnvConfig } from '@hubspot/cms-components/config';
8
8
  const partialRouteHandler = async (request, response) => {
9
- const { authedPortalId, authedEnv, authedHublet, webRoot, viteServer } = request.app.locals;
9
+ const { authedPortalId, authedEnv, authedHublet, webRoot, viteServer, sharedDepsEnabled, } = request.app.locals;
10
10
  const partialName = request.params.partial;
11
11
  const baseTemplatePath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), '../html/baseTemplate.html');
12
12
  const partialPath = normalizePath(path.resolve(webRoot, 'components/partials/', partialName));
13
13
  const environmentConfig = buildStaticEnvConfig(authedPortalId, authedHublet, authedEnv, false);
14
14
  try {
15
15
  const { html: renderedHtml, cssNeeded, renderContext, } = await renderPartial(viteServer, partialPath, {}, fullOriginalUrlFromRequest(request), environmentConfig);
16
- const htmlShell = await createHtmlShellDependingOnRenderContext(baseTemplatePath, request.originalUrl, `Partial: ${partialPath}`, renderContext, viteServer);
16
+ const htmlShell = await createHtmlShellDependingOnRenderContext(baseTemplatePath, request.originalUrl, `Partial: ${partialPath}`, renderContext, viteServer, sharedDepsEnabled);
17
17
  const html = htmlShell
18
18
  .replace('<!--headend-->', cssNeeded)
19
19
  .replace(`<!--ssr-outlet-->`, renderedHtml);
@@ -6,7 +6,7 @@ import { getSubDomainFromValidLocalDomain, consoleWarn, } from '../proxyPage/uti
6
6
  import { VALID_PROXY_DOMAIN_SUFFIXES } from '../proxyPage/constants.js';
7
7
  import fullOriginalUrlFromRequest from '../lib/fullOriginalUrlFromRequest.js';
8
8
  export default async function proxyPageRouteHandler(request, response, next) {
9
- const { viteServer, webRoot, projectName, projectComponentPath } = request.app.locals;
9
+ const { viteServer, webRoot, projectName, projectComponentPath, sharedDepsEnabled, } = request.app.locals;
10
10
  if (!request.accepts().includes('text/html')) {
11
11
  return response.sendStatus(404);
12
12
  }
@@ -32,7 +32,7 @@ export default async function proxyPageRouteHandler(request, response, next) {
32
32
  }
33
33
  try {
34
34
  const { portalId, contentId, hublet } = await fetchContentMetadata(urlToProxy);
35
- await proxyPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, urlToProxy, fullOriginalUrl);
35
+ await proxyPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, sharedDepsEnabled, urlToProxy, fullOriginalUrl);
36
36
  }
37
37
  catch (e) {
38
38
  next(e);
@@ -6,7 +6,7 @@ import fetchContentMetadata from '../proxyPage/fetchContentMetadata.js';
6
6
  import proxyPage from '../proxyPage/proxyPage.js';
7
7
  import { consoleWarn } from '../proxyPage/utils.js';
8
8
  export default async function proxyPathPageRouteHandler(request, response, next) {
9
- const { viteServer, webRoot, devServerHost, devServerPort, projectName, projectComponentPath, } = request.app.locals;
9
+ const { viteServer, webRoot, devServerHost, devServerPort, projectName, projectComponentPath, sharedDepsEnabled, } = request.app.locals;
10
10
  if (!request.accepts().includes('text/html')) {
11
11
  return response.sendStatus(404);
12
12
  }
@@ -35,7 +35,7 @@ export default async function proxyPathPageRouteHandler(request, response, next)
35
35
  }
36
36
  try {
37
37
  const { portalId, contentId, hublet } = await fetchContentMetadata(proxyPageUrl.href);
38
- await proxyPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, proxyPageUrl.href, proxyPageUrl.href);
38
+ await proxyPage(response, portalId, hublet, contentId, webRoot, viteServer, projectName, projectComponentPath, sharedDepsEnabled, proxyPageUrl.href, proxyPageUrl.href);
39
39
  }
40
40
  catch (e) {
41
41
  next(e);