@nuxtjs/prismic 5.2.1-canary.776ac17 → 5.2.1-canary.8cc2d3e

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.776ac17",
3
+ "version": "5.2.1-canary.8cc2d3e",
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.776ac17";
10
+ const version = "5.2.1-canary.8cc2d3e";
11
11
 
12
12
  const logger = useLogger("nuxt:prismic");
13
13
  const PRISMIC_CONFIG_FILENAME = "prismic.config.json";
@@ -74,7 +74,21 @@ const module$1 = defineNuxtModule({
74
74
  nuxt.options.runtimeConfig.public?.prismic,
75
75
  options
76
76
  );
77
- loadPrismicConfig();
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
+ }
78
92
  exposeRuntimeConfig();
79
93
  transpileDependencies();
80
94
  const ok = proxyUserFiles();
@@ -83,29 +97,6 @@ const module$1 = defineNuxtModule({
83
97
  addAutoImports();
84
98
  addPreviewRoute();
85
99
  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
- }
109
100
  function exposeRuntimeConfig() {
110
101
  nuxt.options.runtimeConfig.public ||= {};
111
102
  nuxt.options.runtimeConfig.public.prismic = moduleOptions;
@@ -323,7 +314,8 @@ function fileExists(path, extensions = ["js", "ts"]) {
323
314
  );
324
315
  return extension ? `${path}.${extension}` : null;
325
316
  }
326
- function readPrismicConfig(configPath) {
317
+ function readPrismicConfig(rootDir) {
318
+ const configPath = join(rootDir, PRISMIC_CONFIG_FILENAME);
327
319
  if (!existsSync(configPath)) {
328
320
  return {};
329
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/prismic",
3
- "version": "5.2.1-canary.776ac17",
3
+ "version": "5.2.1-canary.8cc2d3e",
4
4
  "description": "Easily connect your Nuxt application to your content hosted on Prismic",
5
5
  "keywords": [
6
6
  "nuxt",
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"]`
@@ -225,7 +225,24 @@ export default defineNuxtModule<PrismicModuleOptions>({
225
225
  options,
226
226
  )
227
227
 
228
- loadPrismicConfig()
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
+
229
246
  exposeRuntimeConfig()
230
247
  transpileDependencies()
231
248
  const ok = proxyUserFiles()
@@ -235,33 +252,6 @@ export default defineNuxtModule<PrismicModuleOptions>({
235
252
  addPreviewRoute()
236
253
  extendESLintConfig()
237
254
 
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
-
265
255
  function exposeRuntimeConfig() {
266
256
  nuxt.options.runtimeConfig.public ||=
267
257
  {} as typeof nuxt.options.runtimeConfig.public
@@ -546,8 +536,10 @@ type PrismicConfig = {
546
536
  }
547
537
 
548
538
  function readPrismicConfig(
549
- configPath: string,
539
+ rootDir: string,
550
540
  ): PrismicConfig {
541
+ const configPath = join(rootDir, PRISMIC_CONFIG_FILENAME)
542
+
551
543
  if (!existsSync(configPath)) {
552
544
  return {}
553
545
  }