@shopware/nuxt-module 1.4.2 → 1.4.4
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/README.md +10 -5
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +40 -11
- package/package.json +13 -12
- package/plugin.ts +11 -4
package/README.md
CHANGED
|
@@ -161,11 +161,16 @@ Import your custom types from local files and export them as shown above. This a
|
|
|
161
161
|
|
|
162
162
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/nuxt-module/CHANGELOG.md)
|
|
163
163
|
|
|
164
|
-
### Latest changes: 1.4.
|
|
164
|
+
### Latest changes: 1.4.4
|
|
165
165
|
|
|
166
166
|
### Patch Changes
|
|
167
167
|
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
- [#2370](https://github.com/shopware/frontends/pull/2370) [`9661432`](https://github.com/shopware/frontends/commit/96614324dfed3d9d83fbf85710145dd529a23f46) Thanks [@patzick](https://github.com/patzick)! - Fix SSR and CSR Shopware endpoint handling in the Nuxt module.
|
|
169
|
+
|
|
170
|
+
The module now persists the resolved SSR endpoint into private runtime config,
|
|
171
|
+
avoids reading private runtime config on the client, and correctly honors both
|
|
172
|
+
`endpoint` and deprecated `shopwareEndpoint` values during server rendering.
|
|
173
|
+
|
|
174
|
+
- Updated dependencies [[`22fc8a7`](https://github.com/shopware/frontends/commit/22fc8a7301f6a7d2612d907ab73555978b651c00), [`bea7f58`](https://github.com/shopware/frontends/commit/bea7f5882cb58c6d47c84a82db5c8ecaf9bcf8ef), [`b8c0091`](https://github.com/shopware/frontends/commit/b8c00913c3afb5e1e63de9565105f8f8e3bf299f)]:
|
|
175
|
+
- @shopware/helpers@1.7.1
|
|
176
|
+
- @shopware/composables@1.11.1
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
1
3
|
import { addCustomTab } from '@nuxt/devtools-kit';
|
|
2
|
-
import { defineNuxtModule, useLogger, createResolver, addPlugin } from '@nuxt/kit';
|
|
4
|
+
import { defineNuxtModule, useLogger, createResolver, addPlugin, addTypeTemplate } from '@nuxt/kit';
|
|
3
5
|
import { defu } from 'defu';
|
|
4
|
-
import 'node:fs';
|
|
5
|
-
import { dirname, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const distDir = dirname(fileURLToPath(import.meta.url));
|
|
@@ -21,27 +21,47 @@ const index = defineNuxtModule({
|
|
|
21
21
|
async setup(options, nuxt) {
|
|
22
22
|
const logger = useLogger(MODULE_ID);
|
|
23
23
|
const resolver = createResolver(import.meta.url);
|
|
24
|
-
|
|
24
|
+
nuxt.options.runtimeConfig.shopware = defu(
|
|
25
|
+
nuxt.options.runtimeConfig.shopware || {},
|
|
26
|
+
options || {}
|
|
27
|
+
);
|
|
25
28
|
nuxt.options.runtimeConfig.public.shopware = defu(
|
|
26
29
|
nuxt.options.runtimeConfig.public.shopware || {},
|
|
27
30
|
options || {}
|
|
28
31
|
);
|
|
29
|
-
|
|
32
|
+
const resolvedPublicShopwareConfig = nuxt.options.runtimeConfig.public.shopware;
|
|
33
|
+
const resolvedPrivateShopwareConfig = nuxt.options.runtimeConfig.shopware;
|
|
34
|
+
if (isConfigDeprecated(resolvedPublicShopwareConfig) || isConfigDeprecated(resolvedPrivateShopwareConfig)) {
|
|
30
35
|
logger.warn(
|
|
31
36
|
"You are using deprecated configuration (shopwareEndpoint or shopwareAccessToken). 'shopware' prefix is not needed anymore. Please update your _nuxt.config.ts_ "
|
|
32
37
|
);
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const envPublicEndpoint = process.env.NUXT_PUBLIC_SHOPWARE_ENDPOINT || process.env.NUXT_PUBLIC_SHOPWARE_SHOPWARE_ENDPOINT;
|
|
40
|
+
const envPrivateEndpoint = process.env.NUXT_SHOPWARE_ENDPOINT || process.env.NUXT_SHOPWARE_SHOPWARE_ENDPOINT;
|
|
41
|
+
const csrEndpoint = envPublicEndpoint || resolvedPublicShopwareConfig?.endpoint || resolvedPublicShopwareConfig?.shopwareEndpoint;
|
|
42
|
+
const ssrEndpoint = envPrivateEndpoint || resolvedPrivateShopwareConfig?.endpoint || resolvedPrivateShopwareConfig?.shopwareEndpoint || csrEndpoint;
|
|
43
|
+
if (ssrEndpoint) {
|
|
44
|
+
nuxt.options.runtimeConfig.shopware = defu(
|
|
45
|
+
nuxt.options.runtimeConfig.shopware || {},
|
|
46
|
+
{
|
|
47
|
+
endpoint: ssrEndpoint
|
|
48
|
+
}
|
|
37
49
|
);
|
|
38
50
|
}
|
|
39
|
-
|
|
40
|
-
`
|
|
41
|
-
|
|
51
|
+
if (ssrEndpoint) {
|
|
52
|
+
logger.info(`You are using SSR Shopware API endpoint: ${ssrEndpoint}`);
|
|
53
|
+
}
|
|
54
|
+
logger.info(`CSR Shopware API endpoint: ${csrEndpoint}`);
|
|
42
55
|
addPlugin({
|
|
43
56
|
src: resolver.resolve("../plugin.ts")
|
|
44
57
|
});
|
|
58
|
+
const projectShopwareTypes = resolve(nuxt.options.rootDir, "shopware.d.ts");
|
|
59
|
+
if (!existsSync(projectShopwareTypes)) {
|
|
60
|
+
addTypeTemplate({
|
|
61
|
+
filename: "shopware.d.ts",
|
|
62
|
+
src: resolver.resolve("../shopware.d.ts")
|
|
63
|
+
});
|
|
64
|
+
}
|
|
45
65
|
addCustomTab({
|
|
46
66
|
name: "shopware-frontends",
|
|
47
67
|
title: "Shopware Frontends",
|
|
@@ -51,6 +71,15 @@ const index = defineNuxtModule({
|
|
|
51
71
|
src: "https://frontends.shopware.com/"
|
|
52
72
|
}
|
|
53
73
|
});
|
|
74
|
+
addCustomTab({
|
|
75
|
+
name: "shopware-cms",
|
|
76
|
+
title: "CMS Elements",
|
|
77
|
+
icon: "carbon:assembly-cluster",
|
|
78
|
+
view: {
|
|
79
|
+
type: "iframe",
|
|
80
|
+
src: "https://frontends.shopware.com/getting-started/cms/"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/nuxt-module",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Nuxt 3 module for Shopware Frontends",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"repository": {
|
|
@@ -34,20 +34,21 @@
|
|
|
34
34
|
"index.cjs"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nuxt/kit": "4.
|
|
38
|
-
"defu": "6.1.
|
|
39
|
-
"h3": "1.15.
|
|
37
|
+
"@nuxt/kit": "4.4.6",
|
|
38
|
+
"defu": "6.1.7",
|
|
39
|
+
"h3": "1.15.11",
|
|
40
40
|
"js-cookie": "3.0.5",
|
|
41
|
-
"@shopware/composables": "1.
|
|
42
|
-
"@shopware/helpers": "1.
|
|
43
|
-
"@shopware/api-client": "1.
|
|
41
|
+
"@shopware/composables": "1.11.1",
|
|
42
|
+
"@shopware/helpers": "1.7.1",
|
|
43
|
+
"@shopware/api-client": "1.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@biomejs/biome": "1.8.3",
|
|
47
|
-
"@nuxt/schema": "4.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
47
|
+
"@nuxt/schema": "4.4.6",
|
|
48
|
+
"@typescript/native-preview": "7.0.0-dev.20260205.1",
|
|
49
|
+
"nuxt": "4.4.6",
|
|
50
50
|
"unbuild": "2.0.0",
|
|
51
|
+
"vitest": "4.1.6",
|
|
51
52
|
"tsconfig": "0.0.0"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"dev": "unbuild --stub",
|
|
56
57
|
"lint": "biome check .",
|
|
57
58
|
"lint:fix": "biome check . --write && pnpm run typecheck",
|
|
58
|
-
"typecheck": "
|
|
59
|
-
"test": "
|
|
59
|
+
"typecheck": "tsgo --noEmit",
|
|
60
|
+
"test": "vitest run"
|
|
60
61
|
}
|
|
61
62
|
}
|
package/plugin.ts
CHANGED
|
@@ -31,14 +31,18 @@ export default defineNuxtPlugin((NuxtApp) => {
|
|
|
31
31
|
|
|
32
32
|
const shopwareRuntimeConfigPublic = runtimeConfig.public
|
|
33
33
|
.shopware as ShopwareNuxtOptions;
|
|
34
|
-
const shopwareRuntimeConfig =
|
|
34
|
+
const shopwareRuntimeConfig = import.meta.server
|
|
35
|
+
? (runtimeConfig.shopware as ShopwareNuxtOptions)
|
|
36
|
+
: undefined;
|
|
35
37
|
|
|
36
38
|
const shopwareEndpointCSR =
|
|
37
39
|
shopwareRuntimeConfigPublic?.endpoint ??
|
|
38
40
|
shopwareRuntimeConfigPublic?.shopwareEndpoint;
|
|
39
41
|
|
|
40
42
|
const shopwareEndpointSSR =
|
|
41
|
-
(NuxtApp.ssrContext &&
|
|
43
|
+
(NuxtApp.ssrContext &&
|
|
44
|
+
(shopwareRuntimeConfig?.endpoint ??
|
|
45
|
+
shopwareRuntimeConfig?.shopwareEndpoint)) ||
|
|
42
46
|
shopwareEndpointCSR;
|
|
43
47
|
|
|
44
48
|
const shopwareEndpoint = import.meta.server
|
|
@@ -68,6 +72,10 @@ export default defineNuxtPlugin((NuxtApp) => {
|
|
|
68
72
|
headers?: Record<string, string>;
|
|
69
73
|
};
|
|
70
74
|
|
|
75
|
+
const privateApiClientConfig = import.meta.server
|
|
76
|
+
? (runtimeConfig.apiClientConfig as ApiClientConfig)
|
|
77
|
+
: undefined;
|
|
78
|
+
|
|
71
79
|
const apiClient = createAPIClient({
|
|
72
80
|
baseURL: shopwareEndpoint,
|
|
73
81
|
accessToken: shopwareAccessToken,
|
|
@@ -75,8 +83,7 @@ export default defineNuxtPlugin((NuxtApp) => {
|
|
|
75
83
|
? contextTokenFromCookie
|
|
76
84
|
: "",
|
|
77
85
|
defaultHeaders:
|
|
78
|
-
(NuxtApp.ssrContext &&
|
|
79
|
-
(runtimeConfig.apiClientConfig as ApiClientConfig)?.headers) ||
|
|
86
|
+
(NuxtApp.ssrContext && privateApiClientConfig?.headers) ||
|
|
80
87
|
(runtimeConfig.public?.apiClientConfig as ApiClientConfig)?.headers,
|
|
81
88
|
});
|
|
82
89
|
|