@nuxtjs/prismic 5.2.1-canary.d380eb6 → 5.3.0

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/dist/module.d.mts CHANGED
@@ -82,9 +82,9 @@ type PrismicModuleOptions = {
82
82
  * Controls which auto-imports are added by the module.
83
83
  *
84
84
  * - `"all"` will add all imports.
85
- * - `["vue"]` will add `@nuxtjs/prismic` and `@prismicio/vue` imports.
86
- * - `["javascript"]` will add `@prismicio/client` imports.
87
- * - `["content"]` will add the `Content` type import.
85
+ * - `"vue"` will add `@nuxtjs/prismic` and `@prismicio/vue` imports.
86
+ * - `"javascript"` will add `@prismicio/client` imports.
87
+ * - `"content"` will add the `Content` type import.
88
88
  * - `false` will not add any import.
89
89
  *
90
90
  * @defaultValue `["vue"]`
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/prismic",
3
- "version": "5.2.1-canary.d380eb6",
3
+ "version": "5.3.0",
4
4
  "configKey": "prismic",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.7.0"
package/dist/module.mjs CHANGED
@@ -7,7 +7,7 @@ import { addDependency } from 'nypm';
7
7
  import { readPackage } from 'pkg-types';
8
8
 
9
9
  const name = "@nuxtjs/prismic";
10
- const version = "5.2.1-canary.d380eb6";
10
+ const version = "5.3.0";
11
11
 
12
12
  const logger = useLogger("nuxt:prismic");
13
13
  const PRISMIC_CONFIG_FILENAME = "prismic.config.json";
@@ -74,21 +74,7 @@ const module$1 = defineNuxtModule({
74
74
  nuxt.options.runtimeConfig.public?.prismic,
75
75
  options
76
76
  );
77
- const prismicConfig = readPrismicConfig(
78
- nuxt.options.rootDir
79
- );
80
- const configKeys = [];
81
- if (!moduleOptions.endpoint && prismicConfig.repositoryName) {
82
- moduleOptions.endpoint = prismicConfig.repositoryName;
83
- configKeys.push("repository name");
84
- }
85
- if (!moduleOptions.clientConfig?.routes && prismicConfig.routes) {
86
- moduleOptions.clientConfig.routes = prismicConfig.routes;
87
- configKeys.push("routes");
88
- }
89
- if (configKeys.length > 0) {
90
- logger.info(`Loaded ${configKeys.join(" and ")} from \`${PRISMIC_CONFIG_FILENAME}\``);
91
- }
77
+ loadPrismicConfig();
92
78
  exposeRuntimeConfig();
93
79
  transpileDependencies();
94
80
  const ok = proxyUserFiles();
@@ -97,6 +83,29 @@ const module$1 = defineNuxtModule({
97
83
  addAutoImports();
98
84
  addPreviewRoute();
99
85
  extendESLintConfig();
86
+ function loadPrismicConfig() {
87
+ const prismicConfigPath = join(nuxt.options.rootDir, PRISMIC_CONFIG_FILENAME);
88
+ const prismicConfig = readPrismicConfig(prismicConfigPath);
89
+ const configKeys = [];
90
+ if (!moduleOptions.endpoint && prismicConfig.repositoryName) {
91
+ moduleOptions.endpoint = prismicConfig.repositoryName;
92
+ configKeys.push("repository name");
93
+ }
94
+ if (!moduleOptions.clientConfig?.routes && prismicConfig.routes) {
95
+ moduleOptions.clientConfig.routes = prismicConfig.routes;
96
+ configKeys.push("routes");
97
+ }
98
+ if (configKeys.length > 0) {
99
+ nuxt.options.watch.push(prismicConfigPath);
100
+ nuxt.hook("builder:watch", async (_, path) => {
101
+ if (path.replace(/\\/g, "/") === prismicConfigPath.replace(/\\/g, "/")) {
102
+ logger.info(`${PRISMIC_CONFIG_FILENAME} updated`);
103
+ await nuxt.callHook("restart");
104
+ }
105
+ });
106
+ logger.info(`Loaded ${configKeys.join(" and ")} from \`${PRISMIC_CONFIG_FILENAME}\``);
107
+ }
108
+ }
100
109
  function exposeRuntimeConfig() {
101
110
  nuxt.options.runtimeConfig.public ||= {};
102
111
  nuxt.options.runtimeConfig.public.prismic = moduleOptions;
@@ -314,8 +323,7 @@ function fileExists(path, extensions = ["js", "ts"]) {
314
323
  );
315
324
  return extension ? `${path}.${extension}` : null;
316
325
  }
317
- function readPrismicConfig(rootDir) {
318
- const configPath = join(rootDir, PRISMIC_CONFIG_FILENAME);
326
+ function readPrismicConfig(configPath) {
319
327
  if (!existsSync(configPath)) {
320
328
  return {};
321
329
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/prismic",
3
- "version": "5.2.1-canary.d380eb6",
3
+ "version": "5.3.0",
4
4
  "description": "Easily connect your Nuxt application to your content hosted on Prismic",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -52,27 +52,27 @@
52
52
  "test": "npm run lint && npm run types && npm run unit && npm run build"
53
53
  },
54
54
  "dependencies": {
55
- "@nuxt/kit": "^4.4.2",
55
+ "@nuxt/kit": "^4.4.4",
56
56
  "@prismicio/vue": "^6.1.3",
57
57
  "defu": "^6.1.7",
58
- "nypm": "^0.6.5",
59
- "pkg-types": "^2.3.0"
58
+ "nypm": "^0.6.6",
59
+ "pkg-types": "^2.3.1"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@nuxt/module-builder": "^1.0.2",
63
- "@nuxt/schema": "^4.4.2",
63
+ "@nuxt/schema": "^4.4.4",
64
64
  "@nuxt/test-utils": "^3.23.0",
65
65
  "@prismicio/client": "^7.21.8",
66
66
  "@trivago/prettier-plugin-sort-imports": "^6.0.2",
67
- "@types/node": "^25.5.2",
68
- "@vitest/coverage-v8": "^4.1.3",
69
- "nuxt": "^4.4.2",
70
- "oxlint": "^1.59.0",
71
- "prettier": "^3.8.1",
67
+ "@types/node": "^25.6.0",
68
+ "@vitest/coverage-v8": "^4.1.5",
69
+ "nuxt": "^4.4.4",
70
+ "oxlint": "^1.62.0",
71
+ "prettier": "^3.8.3",
72
72
  "prettier-plugin-jsdoc": "^1.8.0",
73
- "typescript": "^6.0.2",
74
- "vitest": "^4.1.3",
75
- "vue-tsc": "^3.2.6"
73
+ "typescript": "^6.0.3",
74
+ "vitest": "^4.1.5",
75
+ "vue-tsc": "^3.2.7"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@prismicio/client": "^7.21.8"
package/src/module.ts CHANGED
@@ -108,9 +108,9 @@ export type PrismicModuleOptions = {
108
108
  * Controls which auto-imports are added by the module.
109
109
  *
110
110
  * - `"all"` will add all imports.
111
- * - `["vue"]` will add `@nuxtjs/prismic` and `@prismicio/vue` imports.
112
- * - `["javascript"]` will add `@prismicio/client` imports.
113
- * - `["content"]` will add the `Content` type import.
111
+ * - `"vue"` will add `@nuxtjs/prismic` and `@prismicio/vue` imports.
112
+ * - `"javascript"` will add `@prismicio/client` imports.
113
+ * - `"content"` will add the `Content` type import.
114
114
  * - `false` will not add any import.
115
115
  *
116
116
  * @defaultValue `["vue"]`
@@ -221,28 +221,11 @@ export default defineNuxtModule<PrismicModuleOptions>({
221
221
  const resolver = createResolver(import.meta.url)
222
222
 
223
223
  const moduleOptions: PrismicModuleOptions = defu(
224
- nuxt.options.runtimeConfig.public?.prismic,
224
+ nuxt.options.runtimeConfig.public?.prismic as PrismicModuleOptions,
225
225
  options,
226
226
  )
227
227
 
228
- const prismicConfig = readPrismicConfig(
229
- nuxt.options.rootDir,
230
- )
231
-
232
- const configKeys: string[] = []
233
- if (!moduleOptions.endpoint && prismicConfig.repositoryName) {
234
- moduleOptions.endpoint = prismicConfig.repositoryName
235
- configKeys.push("repository name")
236
- }
237
- if (!moduleOptions.clientConfig?.routes && prismicConfig.routes) {
238
- moduleOptions.clientConfig!.routes = prismicConfig.routes
239
- configKeys.push("routes")
240
- }
241
-
242
- if (configKeys.length > 0) {
243
- logger.info(`Loaded ${configKeys.join(" and ")} from \`${PRISMIC_CONFIG_FILENAME}\``)
244
- }
245
-
228
+ loadPrismicConfig()
246
229
  exposeRuntimeConfig()
247
230
  transpileDependencies()
248
231
  const ok = proxyUserFiles()
@@ -252,10 +235,37 @@ export default defineNuxtModule<PrismicModuleOptions>({
252
235
  addPreviewRoute()
253
236
  extendESLintConfig()
254
237
 
238
+ function loadPrismicConfig() {
239
+ const prismicConfigPath = join(nuxt.options.rootDir, PRISMIC_CONFIG_FILENAME)
240
+ const prismicConfig = readPrismicConfig(prismicConfigPath)
241
+
242
+ const configKeys: string[] = []
243
+ if (!moduleOptions.endpoint && prismicConfig.repositoryName) {
244
+ moduleOptions.endpoint = prismicConfig.repositoryName
245
+ configKeys.push("repository name")
246
+ }
247
+ if (!moduleOptions.clientConfig?.routes && prismicConfig.routes) {
248
+ moduleOptions.clientConfig!.routes = prismicConfig.routes
249
+ configKeys.push("routes")
250
+ }
251
+
252
+ if (configKeys.length > 0) {
253
+ nuxt.options.watch.push(prismicConfigPath)
254
+ nuxt.hook("builder:watch", async (_, path) => {
255
+ if (path.replace(/\\/g, "/") === prismicConfigPath.replace(/\\/g, "/")) {
256
+ logger.info(`${PRISMIC_CONFIG_FILENAME} updated`)
257
+ await nuxt.callHook("restart")
258
+ }
259
+ })
260
+
261
+ logger.info(`Loaded ${configKeys.join(" and ")} from \`${PRISMIC_CONFIG_FILENAME}\``)
262
+ }
263
+ }
264
+
255
265
  function exposeRuntimeConfig() {
256
266
  nuxt.options.runtimeConfig.public ||=
257
267
  {} as typeof nuxt.options.runtimeConfig.public
258
- nuxt.options.runtimeConfig.public.prismic = moduleOptions
268
+ (nuxt.options.runtimeConfig.public.prismic as PrismicModuleOptions) = moduleOptions
259
269
  }
260
270
 
261
271
  function transpileDependencies() {
@@ -536,10 +546,8 @@ type PrismicConfig = {
536
546
  }
537
547
 
538
548
  function readPrismicConfig(
539
- rootDir: string,
549
+ configPath: string,
540
550
  ): PrismicConfig {
541
- const configPath = join(rootDir, PRISMIC_CONFIG_FILENAME)
542
-
543
551
  if (!existsSync(configPath)) {
544
552
  return {}
545
553
  }