Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Added lightweight subpath entries to dashboard-core (#14717)
Damian Legawiecc2d6f4091dad
diff --git a/.changeset/dashboard-core-slim-entries.md b/.changeset/dashboard-core-slim-entries.mdnew file mode 100644index 0000000000..a1cf1d5e5e--- /dev/null+++ b/.changeset/dashboard-core-slim-entries.md@@ -0,0 +1,6 @@+---+"@spree/dashboard": patch+"@spree/dashboard-core": patch+---++`@spree/dashboard-core` now exposes `@spree/dashboard-core/client` (`adminClient`) and `@spree/dashboard-core/api-client` (`setApiClient`), so a small app that only needs the Admin API client and sign-in no longer bundles the whole framework through the package entry point. `StoreSetupFields` imports only the modules it uses, cutting a minimal app that mounts it from about 2.2 MB to 0.9 MB of JavaScript.diff --git a/docs/developer/dashboard/public-api.mdx b/docs/developer/dashboard/public-api.mdxindex c717d0f843..b92858f3a4 100644--- a/docs/developer/dashboard/public-api.mdx+++ b/docs/developer/dashboard/public-api.mdx@@ -125,6 +125,15 @@ import { adminClient } from '@spree/dashboard-core'The shared `@spree/admin-sdk` instance configured for the host's API URL. Use this everywhere instead of constructing your own.+The package entry point loads the whole framework — every registry, component and translation. A small host app that builds its own screens and only needs the client and sign-in can import from subpaths instead, which keeps the rest out of its bundle:++```ts+import { adminClient } from '@spree/dashboard-core/client' // the SDK instance alone+import { setApiClient } from '@spree/dashboard-core/api-client' // registers the client the providers use+import { AuthProvider } from '@spree/dashboard-core/providers/auth-provider'+import { useAuth } from '@spree/dashboard-core/hooks/use-auth'+```+### Providers```tsdiff --git a/packages/dashboard-core/package.json b/packages/dashboard-core/package.jsonindex 232b4a9e3b..99786d2f4e 100644--- a/packages/dashboard-core/package.json+++ b/packages/dashboard-core/package.json@@ -25,6 +25,8 @@"types": "./src/index.ts","exports": {".": "./src/index.ts",+ "./client": "./src/client.ts",+ "./api-client": "./src/api-client.ts","./plugin": "./src/plugin.ts","./vite": {"types": "./src/vite/index.ts",diff --git a/packages/dashboard-core/src/components/currency-select.tsx b/packages/dashboard-core/src/components/currency-select.tsxindex bb4ab14f47..ad693dd03e 100644--- a/packages/dashboard-core/src/components/currency-select.tsx+++ b/packages/dashboard-core/src/components/currency-select.tsx@@ -13,21 +13,7 @@ import { useTranslation } from 'react-i18next'import { useDisplayName } from '../hooks/use-display-name'import { useOptionalStore } from '../providers/store-provider'-/**- * Every ISO 4217 currency code the runtime knows about — the active-currency- * counterpart to the Rails admin's `Money::Currency.table` list. Used for- * contexts where the merchant can pick *any* currency (a market's currency)- * rather than one the store already supports. Degrades to an empty list on- * runtimes without `Intl.supportedValuesOf`, so callers fall back to- * `supported_currencies`.- */-export const ALL_CURRENCY_CODES: string[] = (() => {- try {- return Intl.supportedValuesOf('currency')- } catch {- return []- }-})()+export { ALL_CURRENCY_CODES } from '../lib/currencies'interface CurrencySelectProps {/** Classes for the trigger — used to match a neighbouring control's height. */diff --git a/packages/dashboard-core/src/lib/currencies.ts b/packages/dashboard-core/src/lib/currencies.tsnew file mode 100644index 0000000000..8f999cff94--- /dev/null+++ b/packages/dashboard-core/src/lib/currencies.ts@@ -0,0 +1,15 @@+/**+ * Every ISO 4217 currency code the runtime knows about — the active-currency+ * counterpart to the Rails admin's `Money::Currency.table` list. Used for+ * contexts where the merchant can pick *any* currency (a market's currency)+ * rather than one the store already supports. Degrades to an empty list on+ * runtimes without `Intl.supportedValuesOf`, so callers fall back to+ * `supported_currencies`.+ */+export const ALL_CURRENCY_CODES: string[] = (() => {+ try {+ return Intl.supportedValuesOf('currency')+ } catch {+ return []+ }+})()diff --git a/packages/dashboard/src/components/spree/store-setup-fields.tsx b/packages/dashboard/src/components/spree/store-setup-fields.tsxindex fe9c58429f..812d19fd62 100644--- a/packages/dashboard/src/components/spree/store-setup-fields.tsx+++ b/packages/dashboard/src/components/spree/store-setup-fields.tsx@@ -1,5 +1,10 @@import type { SetupCountry } from '@spree/admin-sdk'-import { ALL_CURRENCY_CODES, useDisplayName } from '@spree/dashboard-core'+// Deep imports keep hosts that mount only this form clear of the framework+// barrel; the i18n import registers the translations the labels use.+import '@spree/dashboard-core/lib/i18n'+import { useDisplayName } from '@spree/dashboard-core/hooks/use-display-name'+import { ALL_CURRENCY_CODES } from '@spree/dashboard-core/lib/currencies'+import { CountryFlag } from '@spree/dashboard-ui/spree/country-flag'import {Combobox,ComboboxButtonTrigger,@@ -9,15 +14,16 @@ import {ComboboxList,ComboboxSearch,ComboboxTriggerPlaceholder,- CountryFlag,- Input,- Label,+} from '@spree/dashboard-ui/ui/combobox'+import { Input } from '@spree/dashboard-ui/ui/input'+import { Label } from '@spree/dashboard-ui/ui/label'+import {Select,SelectContent,SelectItem,SelectTrigger,SelectValue,-} from '@spree/dashboard-ui'+} from '@spree/dashboard-ui/ui/select'import { useCallback, useEffect, useMemo } from 'react'import { Controller, type FieldErrors, type UseFormReturn } from 'react-hook-form'import { useTranslation } from 'react-i18next'