@wervt/nuxt 0.2.6 → 0.2.7

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.
Files changed (2) hide show
  1. package/dist/module.js +15 -1
  2. package/package.json +1 -1
package/dist/module.js CHANGED
@@ -18,6 +18,7 @@ var module_default = defineNuxtModule({
18
18
  const resolver = createResolver(import.meta.url);
19
19
  const nitro = nuxt.options.nitro;
20
20
  if (!nuxt.options.dev) nitro.preset ||= "deno-server";
21
+ const nitroMajor = Number.parseInt(getNuxtVersion(nuxt), 10) >= 5 ? 3 : 2;
21
22
  if (!hasNuxtModule("evlog/nuxt", nuxt)) {
22
23
  const app = await resolveAppName(nuxt.options.rootDir, options.app);
23
24
  const config = nuxt.options;
@@ -33,6 +34,17 @@ var module_default = defineNuxtModule({
33
34
  ...config.evlog
34
35
  };
35
36
  await installModule(evlog, void 0, nuxt);
37
+ if (nitroMajor >= 3) {
38
+ const v3 = (path) => path.replace(EVLOG_NITRO2_RE, "$1/v3/$2");
39
+ const serverPlugins = nuxt.options._serverPlugins;
40
+ for (const entry of serverPlugins ?? []) if (typeof entry.plugin === "string") entry.plugin = v3(entry.plugin);
41
+ nuxt.hook("nitro:config", (config) => {
42
+ const options = config;
43
+ options.plugins = options.plugins?.map(v3);
44
+ const handler = options.errorHandler;
45
+ if (handler) options.errorHandler = Array.isArray(handler) ? handler.map(v3) : v3(handler);
46
+ });
47
+ }
36
48
  }
37
49
  const useContentDatabase = !nuxt.options.dev && hasNuxtModule("@nuxt/content", nuxt);
38
50
  if (useContentDatabase) {
@@ -108,7 +120,7 @@ var module_default = defineNuxtModule({
108
120
  ...nitro.experimental,
109
121
  tasks: true
110
122
  };
111
- const nitroVersion = Number.parseInt(getNuxtVersion(nuxt), 10) >= 5 ? "nitro3" : "nitro2";
123
+ const nitroVersion = nitroMajor >= 3 ? "nitro3" : "nitro2";
112
124
  addServerHandler({
113
125
  route: "/_wervt/tasks/**",
114
126
  method: "post",
@@ -180,6 +192,8 @@ var module_default = defineNuxtModule({
180
192
  ]);
181
193
  }
182
194
  });
195
+ /** evlog's Nitro 2 plugin and error handler, as evlog/nuxt resolves them. */
196
+ const EVLOG_NITRO2_RE = /([\\/]evlog[\\/]dist[\\/]nitro)[\\/](plugin|errorHandler)(\.mjs)?$/;
183
197
  const BUILTINS = new Set(builtinModules.filter((name) => !name.startsWith("_")));
184
198
  /** Rewrites `from 'os'` / `import('os')` to `node:os` in the output chunks. */
185
199
  function prefixNodeBuiltins() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wervt/nuxt",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Nuxt module for apps hosted on wervt: database, live data and runtime setup.",
5
5
  "keywords": [
6
6
  "drizzle",