@poveste/plugin-nuxt 0.9.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -10
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import replace from '@rollup/plugin-replace';
4
+ import { onPovesteCleanup } from 'poveste';
4
5
  const ignorePlugins = [
5
6
  'nuxt:vite-node-server',
6
7
  'nuxt:dev-style-ssr',
@@ -36,12 +37,25 @@ export function wrapPluginsForTolerantBoot(source) {
36
37
  }
37
38
  export function HstNuxt(options = {}) {
38
39
  let nuxt;
40
+ let closed = false;
41
+ // Reachable from several places now, and Nuxt is not asked to close twice.
42
+ async function closeNuxt() {
43
+ if (closed) {
44
+ return;
45
+ }
46
+ closed = true;
47
+ await nuxt?.close();
48
+ }
39
49
  return {
40
50
  name: '@poveste/plugin-nuxt',
41
51
  async defaultConfig() {
42
52
  const nuxtViteConfig = await useNuxtViteConfig([...DEFAULT_EXCLUDED_PLUGINS, ...(options.excludePlugins ?? [])]);
43
53
  const { viteConfig } = nuxtViteConfig;
44
- nuxt = nuxtViteConfig.nuxt; // We save it to close it later
54
+ nuxt = nuxtViteConfig.nuxt;
55
+ // Registered here rather than in a command hook: this instance exists from
56
+ // config resolution onwards, and a failure before those hooks run left it
57
+ // going with nothing to close it (#434).
58
+ onPovesteCleanup(closeNuxt);
45
59
  const plugins = viteConfig.plugins.filter((p) => !ignorePlugins.includes(p?.name));
46
60
  return {
47
61
  vite: {
@@ -109,17 +123,15 @@ export async function setupVue3 () {
109
123
  };
110
124
  },
111
125
  onDev(api, onCleanup) {
112
- onCleanup(async () => {
113
- nuxt?.close();
114
- });
126
+ onCleanup(closeNuxt);
115
127
  },
116
- onBuild(api) {
117
- api.onBuildEnd(() => {
118
- nuxt?.close();
119
- });
128
+ onBuild(api, onCleanup) {
129
+ // Not `onBuildEnd`: that only runs when the build succeeded, so anything
130
+ // this instance holds outlived every build that failed (#434).
131
+ onCleanup(closeNuxt);
120
132
  },
121
- onPreview() {
122
- nuxt?.close();
133
+ async onPreview() {
134
+ await closeNuxt();
123
135
  },
124
136
  };
125
137
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poveste/plugin-nuxt",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.11.0",
5
5
  "description": "Poveste plugin to integrate with Nuxt 4",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan"
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "nuxt": "^4.5.0",
52
- "@poveste/plugin-vue": "^0.9.0",
53
- "poveste": "^0.9.0"
52
+ "@poveste/plugin-vue": "^0.11.0",
53
+ "poveste": "^0.11.0"
54
54
  },
55
55
  "dependencies": {
56
56
  "@nuxt/kit": "^4.5.2",
@@ -65,7 +65,7 @@
65
65
  "typescript": "5.6.3",
66
66
  "vite": "^8.2.0",
67
67
  "vitest": "^4.1.10",
68
- "poveste": "0.9.0"
68
+ "poveste": "0.11.0"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "rimraf dist && tsc -d",