@shopify/hydrogen 0.6.2 → 0.7.1

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.
Files changed (114) hide show
  1. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +1 -1
  2. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +3 -3
  3. package/dist/esnext/components/CartLineProvider/context.d.ts +3 -3
  4. package/dist/esnext/components/CartProvider/CartProvider.client.js +0 -1
  5. package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +1 -1
  6. package/dist/esnext/components/Image/Image.d.ts +1 -1
  7. package/dist/esnext/components/MediaFile/MediaFile.d.ts +1 -1
  8. package/dist/esnext/components/Metafield/Metafield.client.d.ts +1 -1
  9. package/dist/esnext/components/Metafield/Metafield.client.js +8 -0
  10. package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +16 -1
  11. package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +1 -1
  12. package/dist/esnext/components/Metafield/index.d.ts +2 -2
  13. package/dist/esnext/components/Model3D/Model3D.client.d.ts +3 -1
  14. package/dist/esnext/components/Model3D/Model3D.client.js +1 -1
  15. package/dist/esnext/components/Money/Money.client.d.ts +1 -1
  16. package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +1 -1
  17. package/dist/esnext/components/ProductProvider/context.d.ts +2 -2
  18. package/dist/esnext/components/ProductProvider/types.d.ts +2 -2
  19. package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.d.ts +1 -1
  20. package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.js +1 -1
  21. package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +1 -1
  22. package/dist/esnext/components/Video/Video.d.ts +1 -1
  23. package/dist/esnext/components/index.d.ts +2 -2
  24. package/dist/esnext/entry-server.js +43 -19
  25. package/dist/esnext/foundation/Router/ServerStateRouter.client.js +5 -3
  26. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.client.d.ts +19 -11
  27. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.client.js +21 -20
  28. package/dist/esnext/foundation/ServerStateProvider/index.d.ts +2 -1
  29. package/dist/esnext/foundation/ShopifyProvider/ShopifyServerProvider.server.js +1 -1
  30. package/dist/esnext/{hooks → foundation}/useQuery/QueryProvider.d.ts +0 -0
  31. package/dist/esnext/{hooks → foundation}/useQuery/QueryProvider.js +0 -0
  32. package/dist/esnext/{hooks → foundation}/useQuery/hooks.d.ts +0 -0
  33. package/dist/esnext/{hooks → foundation}/useQuery/hooks.js +13 -3
  34. package/dist/esnext/{hooks → foundation}/useQuery/index.d.ts +0 -0
  35. package/dist/esnext/{hooks → foundation}/useQuery/index.js +0 -0
  36. package/dist/esnext/foundation/useServerState/use-server-state.d.ts +2 -2
  37. package/dist/esnext/foundation/useServerState/use-server-state.js +1 -1
  38. package/dist/esnext/framework/ClientMarker/ClientMarker.js +0 -1
  39. package/dist/esnext/framework/Hydration/Cache.client.js +3 -1
  40. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
  41. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +13 -0
  42. package/dist/esnext/framework/Hydration/client-imports.d.ts +1 -1
  43. package/dist/esnext/framework/Hydration/client-imports.js +1 -1
  44. package/dist/esnext/framework/Hydration/wire.server.js +1 -1
  45. package/dist/esnext/framework/Hydration/writer.server.js +1 -0
  46. package/dist/esnext/framework/middleware.d.ts +5 -1
  47. package/dist/esnext/framework/middleware.js +12 -8
  48. package/dist/esnext/framework/plugins/resolver.d.ts +1 -0
  49. package/dist/esnext/framework/plugins/resolver.js +3 -0
  50. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +4 -1
  51. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +8 -2
  52. package/dist/esnext/framework/plugins/vite-plugin-react-server-components-shim.js +11 -9
  53. package/dist/esnext/framework/server-components.js +25 -47
  54. package/dist/esnext/graphql/graphql-constants.d.ts +74 -37
  55. package/dist/esnext/graphql/graphql-constants.js +89 -15
  56. package/dist/esnext/handle-event.js +8 -4
  57. package/dist/esnext/hooks/index.d.ts +1 -1
  58. package/dist/esnext/hooks/index.js +1 -1
  59. package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +3 -3
  60. package/dist/esnext/hooks/useMoney/hooks.js +2 -16
  61. package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -3
  62. package/dist/esnext/hooks/useProductOptions/types.d.ts +2 -3
  63. package/dist/esnext/hooks/useShopQuery/hooks.d.ts +4 -2
  64. package/dist/esnext/hooks/useShopQuery/hooks.js +6 -3
  65. package/dist/esnext/types.d.ts +19 -3
  66. package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +0 -7
  67. package/dist/esnext/utilities/flattenConnection/flattenConnection.js +0 -7
  68. package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
  69. package/dist/esnext/utilities/isClient/isClient.js +0 -4
  70. package/dist/esnext/utilities/isServer/isServer.d.ts +0 -4
  71. package/dist/esnext/utilities/isServer/isServer.js +0 -4
  72. package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +2 -33
  73. package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -31
  74. package/dist/esnext/version.d.ts +1 -1
  75. package/dist/esnext/version.js +1 -1
  76. package/dist/node/framework/ClientMarker/ClientMarker.js +2 -3
  77. package/dist/node/framework/Hydration/Cache.client.js +7 -5
  78. package/dist/node/framework/Hydration/HydrationContext.server.js +1 -1
  79. package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
  80. package/dist/node/framework/Hydration/ServerComponentResponse.server.js +15 -2
  81. package/dist/node/framework/Hydration/client-imports.d.ts +1 -1
  82. package/dist/node/framework/Hydration/client-imports.js +2 -2
  83. package/dist/node/framework/Hydration/react-utils.js +3 -3
  84. package/dist/node/framework/Hydration/wire.server.js +2 -2
  85. package/dist/node/framework/Hydration/writer.server.js +1 -0
  86. package/dist/node/framework/cache.js +3 -3
  87. package/dist/node/framework/middleware.d.ts +5 -1
  88. package/dist/node/framework/middleware.js +17 -11
  89. package/dist/node/framework/plugin.js +5 -5
  90. package/dist/node/framework/plugins/resolver.d.ts +1 -0
  91. package/dist/node/framework/plugins/resolver.js +7 -0
  92. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +4 -1
  93. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +8 -2
  94. package/dist/node/framework/plugins/vite-plugin-react-server-components-shim.js +12 -10
  95. package/dist/node/framework/server-components.js +27 -49
  96. package/dist/node/handle-event.js +12 -8
  97. package/dist/node/types.d.ts +19 -3
  98. package/dist/node/utilities/fetch.js +1 -1
  99. package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +0 -7
  100. package/dist/node/utilities/flattenConnection/flattenConnection.js +0 -7
  101. package/dist/node/utilities/isClient/isClient.d.ts +0 -4
  102. package/dist/node/utilities/isClient/isClient.js +0 -4
  103. package/dist/node/utilities/isServer/isServer.d.ts +0 -4
  104. package/dist/node/utilities/isServer/isServer.js +1 -5
  105. package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +2 -33
  106. package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -31
  107. package/dist/node/utilities/video_parameters.js +1 -1
  108. package/dist/node/version.d.ts +1 -1
  109. package/dist/node/version.js +1 -1
  110. package/dist/worker/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
  111. package/dist/worker/framework/Hydration/ServerComponentResponse.server.js +13 -0
  112. package/dist/worker/handle-event.js +8 -4
  113. package/dist/worker/types.d.ts +19 -3
  114. package/package.json +9 -7
@@ -111,7 +111,9 @@ export async function convertHydrationResponseToReactComponents(response) {
111
111
  function createManifestFromWirePayload(payload) {
112
112
  return payload.split('\n').reduce((memo, row) => {
113
113
  const [key, ...values] = row.split(':');
114
- memo[key] = JSON.parse(values.join(':'));
114
+ if (key) {
115
+ memo[key] = JSON.parse(values.join(':'));
116
+ }
115
117
  return memo;
116
118
  }, {});
117
119
  }
@@ -2,6 +2,10 @@ import { CacheOptions } from '../../types';
2
2
  export declare class ServerComponentResponse extends Response {
3
3
  private wait;
4
4
  private cacheOptions?;
5
+ customStatus?: {
6
+ code?: number;
7
+ text?: string;
8
+ };
5
9
  /**
6
10
  * Allow custom body to be a string or a Promise.
7
11
  */
@@ -14,6 +18,12 @@ export declare class ServerComponentResponse extends Response {
14
18
  canStream(): boolean;
15
19
  cache(options: CacheOptions): void;
16
20
  get cacheControlHeader(): string;
21
+ writeHead({ status, statusText, headers, }?: {
22
+ status?: number;
23
+ statusText?: string;
24
+ headers?: Record<string, any>;
25
+ }): void;
26
+ redirect(location: string, status?: number): void;
17
27
  /**
18
28
  * Send the response from a Server Component. Renders React components to string,
19
29
  * and returns `null` to make React happy.
@@ -30,6 +30,19 @@ export class ServerComponentResponse extends Response {
30
30
  };
31
31
  return generateCacheControlHeader(options);
32
32
  }
33
+ writeHead({ status, statusText, headers, } = {}) {
34
+ if (status || statusText) {
35
+ this.customStatus = { code: status, text: statusText };
36
+ }
37
+ if (headers) {
38
+ for (const [key, value] of Object.entries(headers)) {
39
+ this.headers.set(key, value);
40
+ }
41
+ }
42
+ }
43
+ redirect(location, status = 307) {
44
+ this.writeHead({ status, headers: { location } });
45
+ }
33
46
  /**
34
47
  * Send the response from a Server Component. Renders React components to string,
35
48
  * and returns `null` to make React happy.
@@ -1 +1 @@
1
- export default function importDevClientComponent(moduleId: string): any;
1
+ export default function importClientComponent(moduleId: string): any;
@@ -16,7 +16,7 @@ const allClientComponents = {
16
16
  // @ts-ignore
17
17
  import.meta.glob('__USER_COMPONENTS_GLOB__'), `__USER_COMPONENTS_PREFIX__`),
18
18
  };
19
- export default function importDevClientComponent(moduleId) {
19
+ export default function importClientComponent(moduleId) {
20
20
  const modImport = allClientComponents[moduleId];
21
21
  if (!modImport) {
22
22
  throw new Error(`Could not find client component ${moduleId}`);
@@ -68,7 +68,7 @@ export function generateWireSyntaxFromRenderedHtml(html) {
68
68
  .map((component, idx) => {
69
69
  return `M${idx + 1}:${JSON.stringify(component)}`;
70
70
  })
71
- .join('\n') + `\nJ0:${JSON.stringify(wireModel)}`);
71
+ .join('\n') + `\nJ0:${JSON.stringify(wireModel)}`).trim();
72
72
  }
73
73
  function isDomNode(item) {
74
74
  return item !== null && typeof item === 'object' && '_owner' in item;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-function */
1
2
  /**
2
3
  * HydrationWriter is an implementation of `WritableStream` which
3
4
  * keeps track of chunks emitted from React's `pipeToNodeWritable`.
@@ -10,9 +10,13 @@ declare type HydrogenMiddlewareArgs = {
10
10
  devServer?: ViteDevServer;
11
11
  cache?: Cache;
12
12
  };
13
+ export declare function graphiqlMiddleware({ shopifyConfig, dev, }: {
14
+ shopifyConfig: ShopifyConfig;
15
+ dev: boolean;
16
+ }): (request: IncomingMessage, response: http.ServerResponse, next: NextFunction) => Promise<void>;
13
17
  /**
14
18
  * Provides middleware to Node.js Express-like servers. Used by the Hydrogen
15
19
  * Vite dev server plugin as well as production Node.js implementation.
16
20
  */
17
- export default function hydrogenMiddleware({ dev, shopifyConfig, cache, indexTemplate, getServerEntrypoint, devServer, }: HydrogenMiddlewareArgs): (request: IncomingMessage, response: http.ServerResponse, next: NextFunction) => Promise<void>;
21
+ export declare function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypoint, devServer, }: HydrogenMiddlewareArgs): (request: IncomingMessage, response: http.ServerResponse, next: NextFunction) => Promise<void>;
18
22
  export {};
@@ -1,15 +1,20 @@
1
1
  import { graphiqlHtml } from './graphiql';
2
2
  import handleEvent from '../handle-event';
3
- /**
4
- * Provides middleware to Node.js Express-like servers. Used by the Hydrogen
5
- * Vite dev server plugin as well as production Node.js implementation.
6
- */
7
- export default function hydrogenMiddleware({ dev, shopifyConfig, cache, indexTemplate, getServerEntrypoint, devServer, }) {
3
+ export function graphiqlMiddleware({ shopifyConfig, dev, }) {
8
4
  return async function (request, response, next) {
9
5
  const graphiqlRequest = dev && isGraphiqlRequest(request);
10
6
  if (graphiqlRequest) {
11
7
  return respondWithGraphiql(response, shopifyConfig);
12
8
  }
9
+ next();
10
+ };
11
+ }
12
+ /**
13
+ * Provides middleware to Node.js Express-like servers. Used by the Hydrogen
14
+ * Vite dev server plugin as well as production Node.js implementation.
15
+ */
16
+ export function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypoint, devServer, }) {
17
+ return async function (request, response, next) {
13
18
  const url = new URL('http://' + request.headers.host + request.originalUrl);
14
19
  const isReactHydrationRequest = url.pathname === '/react';
15
20
  /**
@@ -96,9 +101,8 @@ export default function hydrogenMiddleware({ dev, shopifyConfig, cache, indexTem
96
101
  }
97
102
  function shouldInterceptRequest(request, isReactHydrationRequest) {
98
103
  var _a;
99
- return ((/text\/html|application\/hydrogen/.test((_a = request.headers['accept']) !== null && _a !== void 0 ? _a : '') ||
100
- isReactHydrationRequest) &&
101
- request.url !== '/favicon.ico');
104
+ return (/text\/html|application\/hydrogen/.test((_a = request.headers['accept']) !== null && _a !== void 0 ? _a : '') ||
105
+ isReactHydrationRequest);
102
106
  }
103
107
  /**
104
108
  * /graphiql and /___graphql are supported
@@ -0,0 +1 @@
1
+ export declare function resolve(path: string): string;
@@ -0,0 +1,3 @@
1
+ export function resolve(path) {
2
+ return require.resolve(path);
3
+ }
@@ -1,7 +1,7 @@
1
1
  export default () => {
2
2
  return {
3
3
  name: 'vite-plugin-hydrogen-config',
4
- config: () => ({
4
+ config: (_, env) => ({
5
5
  resolve: {
6
6
  alias: {
7
7
  /**
@@ -52,6 +52,9 @@ export default () => {
52
52
  'react-router-dom',
53
53
  ],
54
54
  },
55
+ define: {
56
+ __DEV__: env.mode !== 'production',
57
+ },
55
58
  }),
56
59
  };
57
60
  };
@@ -1,6 +1,6 @@
1
1
  import path from 'path';
2
2
  import { promises as fs } from 'fs';
3
- import hydrogenMiddleware from '../middleware';
3
+ import { hydrogenMiddleware, graphiqlMiddleware } from '../middleware';
4
4
  import { InMemoryCache } from '../cache/in-memory';
5
5
  export default (shopifyConfig, pluginOptions) => {
6
6
  return {
@@ -17,7 +17,13 @@ export default (shopifyConfig, pluginOptions) => {
17
17
  const indexHtml = await fs.readFile(resolve('index.html'), 'utf-8');
18
18
  return await server.transformIndexHtml(url, indexHtml);
19
19
  }
20
- server.middlewares.use(hydrogenMiddleware({
20
+ // The default vite middleware rewrites the URL `/graphqil` to `/index.html`
21
+ // By running this middleware first, we avoid that.
22
+ server.middlewares.use(graphiqlMiddleware({
23
+ shopifyConfig,
24
+ dev: true,
25
+ }));
26
+ return () => server.middlewares.use(hydrogenMiddleware({
21
27
  dev: true,
22
28
  shopifyConfig,
23
29
  indexTemplate: getIndexTemplate,
@@ -1,5 +1,7 @@
1
+ import { normalizePath } from 'vite';
1
2
  import path from 'path';
2
3
  import { proxyClientComponent } from '../server-components';
4
+ import { resolve } from './resolver';
3
5
  export default () => {
4
6
  let config;
5
7
  return {
@@ -32,7 +34,7 @@ export default () => {
32
34
  'When using Hydrogen components within Client Components, use the `@shopify/hydrogen/client` entrypoint instead.');
33
35
  }
34
36
  },
35
- load(id, options) {
37
+ async load(id, options) {
36
38
  if (!isSSR(options))
37
39
  return null;
38
40
  // Wrapped components won't match this becase they end in ?no-proxy
@@ -54,19 +56,19 @@ export default () => {
54
56
  */
55
57
  if (id.includes('/Hydration/client-imports')) {
56
58
  // eslint-disable-next-line node/no-missing-require
57
- const hydrogenPath = path.dirname(require.resolve('@shopify/hydrogen'));
59
+ const hydrogenPath = path.dirname(resolve('@shopify/hydrogen'));
58
60
  const importerPath = path.join(hydrogenPath, 'framework', 'Hydration');
59
- const importerToRootPath = path.relative(importerPath, config.root);
60
- const [importerToRootNested] = importerToRootPath.match(/(\.\.\/)+/) || [];
61
- const userPrefix = path.normalize(path.join(importerPath, importerToRootNested));
61
+ const importerToRootPath = normalizePath(path.relative(importerPath, config.root));
62
+ const [importerToRootNested] = importerToRootPath.match(/(\.\.\/)+(\.\.)?/) || [];
63
+ const userPrefix = path.normalize(path.join(importerPath, importerToRootNested.replace(/\/?$/, path.sep)));
62
64
  const userGlob = path.join(importerToRootPath, 'src', '**/*.client.[jt]sx');
63
65
  const libPrefix = hydrogenPath + path.sep;
64
66
  const libGlob = path.join(path.relative(importerPath, hydrogenPath), 'components', '**/*.client.js');
65
67
  return code
66
- .replace('__USER_COMPONENTS_PREFIX__', userPrefix)
67
- .replace('__USER_COMPONENTS_GLOB__', userGlob)
68
- .replace('__LIB_COMPONENTS_PREFIX__', libPrefix)
69
- .replace('__LIB_COMPONENTS_GLOB__', libGlob);
68
+ .replace('__USER_COMPONENTS_PREFIX__', normalizePath(userPrefix))
69
+ .replace('__USER_COMPONENTS_GLOB__', normalizePath(userGlob))
70
+ .replace('__LIB_COMPONENTS_PREFIX__', normalizePath(libPrefix))
71
+ .replace('__LIB_COMPONENTS_GLOB__', normalizePath(libGlob));
70
72
  }
71
73
  },
72
74
  };
@@ -2,9 +2,8 @@ import { init, parse } from 'es-module-lexer';
2
2
  import { promises as fs } from 'fs';
3
3
  import { transformWithEsbuild } from 'vite';
4
4
  import MagicString from 'magic-string';
5
+ const DEFAULT_EXPORT = 'default';
5
6
  export async function proxyClientComponent({ id, src, }) {
6
- var _a;
7
- const defaultComponentName = (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
8
7
  // Modify the import ID to avoid infinite wraps
9
8
  const importFrom = `${id}?no-proxy`;
10
9
  await init;
@@ -13,56 +12,35 @@ export async function proxyClientComponent({ id, src, }) {
13
12
  }
14
13
  const { code } = await transformWithEsbuild(src, id);
15
14
  const [, exportStatements] = parse(code);
16
- const hasDefaultExport = exportStatements.includes('default');
17
- // Split namedImports in components to wrap and everything else (e.g. GQL Fragments)
18
- const namedImports = exportStatements.reduce((acc, i) => {
19
- if (i !== 'default') {
20
- // Add here any other naming pattern for a non-component export
21
- if (/^use[A-Z]|Fragment$|Context$|^[A-Z_]+$/.test(i)) {
22
- acc.other.push(i);
23
- }
24
- else {
25
- acc.components.push(i);
26
- }
15
+ // Classify exports in components to wrap vs. everything else (e.g. GQL Fragments)
16
+ const otherExports = [];
17
+ const componentExports = [];
18
+ for (const key of exportStatements) {
19
+ if (key !== DEFAULT_EXPORT &&
20
+ /^use[A-Z]|Fragment$|Context$|^[A-Z_]+$/.test(key)) {
21
+ otherExports.push(key);
27
22
  }
28
- return acc;
29
- }, { components: [], other: [] });
30
- if (!hasDefaultExport && namedImports.components.length === 0) {
31
- return `export * from '${importFrom}';\n`;
32
- }
33
- const s = new MagicString(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';`);
34
- s.append('\nimport ');
35
- if (hasDefaultExport) {
36
- s.append(defaultComponentName);
37
- if (namedImports.components.length > 0) {
38
- s.append(', ');
23
+ else {
24
+ componentExports.push(key);
39
25
  }
40
26
  }
41
- if (namedImports.components.length) {
42
- s.append('* as namedImports');
27
+ if (componentExports.length === 0) {
28
+ return `export * from '${importFrom}';\n`;
43
29
  }
44
- s.append(` from '${importFrom}';\n\n`);
30
+ const s = new MagicString(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';\n` +
31
+ `import * as allImports from '${importFrom}';\n\n`);
45
32
  // Re-export other stuff directly without wrapping
46
- if (namedImports.other.length > 0) {
47
- s.append(`export {${namedImports.other.join(', ')}} from '${importFrom}';\n`);
33
+ if (otherExports.length > 0) {
34
+ s.append(`export {${otherExports.join(', ')}} from '${importFrom}';\n`);
48
35
  }
49
- if (hasDefaultExport) {
50
- s.append(generateComponentExport({
51
- id,
52
- componentName: defaultComponentName,
53
- isDefault: true,
54
- }));
55
- }
56
- namedImports.components.forEach((name) => s.append(generateComponentExport({
57
- id,
58
- componentName: name,
59
- isDefault: false,
60
- })));
36
+ // Wrap components in Client Marker
37
+ componentExports.forEach((key) => {
38
+ var _a;
39
+ const isDefault = key === DEFAULT_EXPORT;
40
+ const componentName = isDefault
41
+ ? (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift()
42
+ : key;
43
+ s.append(`export ${isDefault ? DEFAULT_EXPORT : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: allImports['${key}'], named: ${!isDefault} });\n`);
44
+ });
61
45
  return s.toString();
62
46
  }
63
- function generateComponentExport({ id, isDefault, componentName, }) {
64
- const component = isDefault
65
- ? componentName
66
- : `namedImports['${componentName}']`;
67
- return `export ${isDefault ? 'default' : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: ${component}, named: ${!isDefault} });\n`;
68
- }