@salesforce/storefront-next-dev 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
@@ -100,6 +100,12 @@ const createStorefront = async (options = {}) => {
100
100
  recursive: true,
101
101
  force: true
102
102
  });
103
+ let templateRelease;
104
+ const generatedPkgPath = path.join(outputPath, "package.json");
105
+ if (fs.existsSync(generatedPkgPath)) try {
106
+ templateRelease = JSON.parse(fs.readFileSync(generatedPkgPath, "utf8"))?.storefrontNext?.templateRelease;
107
+ } catch {}
108
+ if (!templateRelease) logger.warn("This template is missing its \"storefrontNext\" origin metadata in package.json. You can still build and run it, but it won’t record which template release it came from.");
103
109
  const workspaceYamlPath = path.join(outputPath, "pnpm-workspace.yaml");
104
110
  if (!fs.existsSync(workspaceYamlPath)) logger.warn(`Template is missing pnpm-workspace.yaml at ${workspaceYamlPath}. The generated project may not work correctly without a workspace configuration.`);
105
111
  if (isLocalPath(template) || options.localPackagesDir) {
@@ -173,7 +179,7 @@ const createStorefront = async (options = {}) => {
173
179
  ║ CONGRATULATIONS ║
174
180
  ╚══════════════════════════════════════════════════════════════════╝
175
181
 
176
- 🎉 Congratulations! Your storefront is ready to use! 🎉
182
+ 🎉 Congratulations! Your storefront is ready to use! 🎉${templateRelease ? `\n 📦 Generated from template release: ${templateRelease}` : ""}
177
183
  What's next:
178
184
  - Navigate to the storefront directory: cd ${outputPath}
179
185
  - Install dependencies: pnpm install
package/dist/index.js CHANGED
@@ -1796,6 +1796,17 @@ function i18nPlugin(config) {
1796
1796
  * - `optimizeDeps.include`: forces Vite's dep optimizer to pre-bundle
1797
1797
  * `react-router` and its `/internal/react-server-client` entry so the
1798
1798
  * React Router dev plugin resolves a single shared instance on the client.
1799
+ * It also pre-bundles the React-importing entry points of the runtime SDK
1800
+ * (`/config`, `/security/react`, `/site-context`, `/design/react/core`,
1801
+ * `/routing/app-wrapper`, `/i18n/client`). Without this, Vite optimizes the
1802
+ * app's own React first, then *discovers* these SDK subpaths the first time a
1803
+ * component imports them at request time, triggers a dep re-optimization, and
1804
+ * forces a full-page reload. During that window the SDK's React hooks
1805
+ * (`useConfig` → `useContext`) momentarily resolve against a second, freshly
1806
+ * optimized React instance — surfacing as "Invalid hook call" / "Cannot read
1807
+ * properties of null (reading 'useContext')" until the reload settles.
1808
+ * Including them up front means a single first-pass optimization with one
1809
+ * shared React, so no mid-session re-optimize and no transient duplicate.
1799
1810
  * - `ssr.noExternal`: forces the SDK through Vite's SSR transform pipeline
1800
1811
  * in dev. The SDK exports module-level singletons (router contexts, etc.)
1801
1812
  * whose object identity is load-bearing — they're used as `Map` keys, so
@@ -1824,7 +1835,18 @@ const baseConfigPlugin = () => ({
1824
1835
  "react-dom",
1825
1836
  "react-router"
1826
1837
  ] },
1827
- optimizeDeps: { include: ["react-router", "react-router/internal/react-server-client"] },
1838
+ optimizeDeps: { include: [
1839
+ "react-router",
1840
+ "react-router/internal/react-server-client",
1841
+ "@salesforce/storefront-next-runtime/config",
1842
+ "@salesforce/storefront-next-runtime/security/react",
1843
+ "@salesforce/storefront-next-runtime/site-context",
1844
+ "@salesforce/storefront-next-runtime/design/react/core",
1845
+ "@salesforce/storefront-next-runtime/routing/app-wrapper",
1846
+ "@salesforce/storefront-next-runtime/i18n/client",
1847
+ "i18next-browser-languagedetector",
1848
+ "remix-i18next/middleware"
1849
+ ] },
1828
1850
  ssr: { noExternal: ["@salesforce/storefront-next-runtime"] }
1829
1851
  };
1830
1852
  }