@dxup/nuxt 0.2.1 → 0.2.2

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 CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  This is a TypeScript plugin that improves Nuxt DX.
8
8
 
9
+ > [!note]
10
+ > It's now an experimental builtin feature of Nuxt. Please refer to the [documentation](https://nuxt.com/docs/4.x/guide/going-further/experimental-features#typescriptplugin) for more details.
11
+
9
12
  ## Installation
10
13
 
11
14
  ```bash
@@ -26,11 +29,15 @@ export default defineNuxtConfig({
26
29
 
27
30
  ## Features
28
31
 
29
- ### components
32
+ ### 1. components
30
33
 
31
34
  Update references when renaming auto imported component files.
32
35
 
33
- ### importGlob
36
+ For example, when renaming `components/foo/bar.vue` to `components/foo/baz.vue`, all usages of `<FooBar />` will be updated to `<FooBaz />`.
37
+
38
+ It only works when the dev server is active.
39
+
40
+ ### 2. importGlob
34
41
 
35
42
  Go to definition for dynamic imports with glob patterns.
36
43
 
@@ -41,7 +48,7 @@ import.meta.glob("~/assets/*.webp");
41
48
  // ^^^^^^^^^^^^^^^^^
42
49
  ```
43
50
 
44
- ### nitroRoutes
51
+ ### 3. nitroRoutes
45
52
 
46
53
  Go to definition for nitro routes in data fetching methods.
47
54
 
@@ -53,7 +60,7 @@ useFetch("/api/foo");
53
60
 
54
61
  It will fallback to resolve the URL from your `public` directory when no nitro routes match.
55
62
 
56
- ### runtimeConfig
63
+ ### 4. runtimeConfig
57
64
 
58
65
  Go to definition for runtime config.
59
66
 
@@ -64,6 +71,6 @@ Go to definition for runtime config.
64
71
  </template>
65
72
  ```
66
73
 
67
- ### unimport
74
+ ### 5. unimport
68
75
 
69
76
  Please refer to the [@dxup/unimport](/packages/unimport) package for more details.
@@ -98,7 +98,7 @@ var module_default = defineNuxtModule({
98
98
  return JSON.stringify(data, null, 2);
99
99
  }
100
100
  });
101
- (await createEventClient(nuxt)).on("components:rename", (data) => onComponentsRename(nuxt, data));
101
+ if (nuxt.options.dev) (await createEventClient(nuxt)).on("components:rename", (data) => onComponentsRename(nuxt, data));
102
102
  }
103
103
  });
104
104
  function append(plugins, target, ...keys) {
@@ -1,32 +1,6 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let pathe = require("pathe");
25
- pathe = __toESM(pathe);
26
1
  let node_fs_promises = require("node:fs/promises");
27
- node_fs_promises = __toESM(node_fs_promises);
2
+ let pathe = require("pathe");
28
3
  let tinyglobby = require("tinyglobby");
29
- tinyglobby = __toESM(tinyglobby);
30
4
 
31
5
  //#region src/event/server.ts
32
6
  function createEventServer(info) {
@@ -39,6 +13,39 @@ function createEventServer(info) {
39
13
  return { write };
40
14
  }
41
15
 
16
+ //#endregion
17
+ //#region src/typescript/data.ts
18
+ const initialValue = {
19
+ buildDir: "",
20
+ publicDir: "",
21
+ configFiles: [],
22
+ nitroRoutes: {},
23
+ features: {
24
+ components: true,
25
+ importGlob: true,
26
+ nitroRoutes: true,
27
+ runtimeConfig: true
28
+ }
29
+ };
30
+ const callbacks = {};
31
+ function createData(ts, info) {
32
+ const path = (0, pathe.join)(info.languageServiceHost.getCurrentDirectory(), "dxup/data.json");
33
+ const data = {};
34
+ const updates = callbacks[path] ??= (ts.sys.watchFile?.(path, () => {
35
+ const text$1 = ts.sys.readFile(path);
36
+ for (const update of updates) update(text$1);
37
+ }), []);
38
+ updates.push((text$1) => {
39
+ Object.assign(data, {
40
+ ...initialValue,
41
+ ...text$1 ? JSON.parse(text$1) : {}
42
+ });
43
+ });
44
+ const text = ts.sys.readFile(path);
45
+ updates.at(-1)(text);
46
+ return data;
47
+ }
48
+
42
49
  //#endregion
43
50
  //#region src/typescript/features/findRenameLocations.ts
44
51
  function findRenameLocations(context, findRenameLocations$1) {
@@ -360,32 +367,6 @@ const plugin = (module$1) => {
360
367
  } };
361
368
  };
362
369
  var typescript_default = plugin;
363
- function createData(ts, info) {
364
- const initialValue = {
365
- buildDir: "",
366
- publicDir: "",
367
- configFiles: [],
368
- nitroRoutes: {},
369
- features: {
370
- components: true,
371
- importGlob: true,
372
- nitroRoutes: true,
373
- runtimeConfig: true
374
- }
375
- };
376
- const path = (0, pathe.join)(info.languageServiceHost.getCurrentDirectory(), "dxup/data.json");
377
- const data = {};
378
- update();
379
- ts.sys.watchFile?.(path, update);
380
- return data;
381
- function update() {
382
- const text = ts.sys.readFile(path);
383
- Object.assign(data, {
384
- ...initialValue,
385
- ...text ? JSON.parse(text) : {}
386
- });
387
- }
388
- }
389
370
 
390
371
  //#endregion
391
372
  module.exports = typescript_default;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@dxup/nuxt",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "TypeScript plugin for Nuxt",
6
6
  "author": "KazariEX",
7
7
  "license": "MIT",
8
8
  "repository": "KazariEX/dxup",
9
9
  "exports": {
10
- ".": "./dist/module.js",
10
+ ".": "./dist/module.mjs",
11
11
  "./package.json": "./package.json"
12
12
  },
13
13
  "main": "./dist/typescript.cjs",
@@ -16,18 +16,18 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@nuxt/kit": "^4.2.0",
19
+ "@nuxt/kit": "^4.2.1",
20
20
  "chokidar": "^4.0.3",
21
21
  "pathe": "^2.0.3",
22
22
  "tinyglobby": "^0.2.15",
23
- "@dxup/unimport": "^0.1.1"
23
+ "@dxup/unimport": "^0.1.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@dxup/shared": "",
27
27
  "@volar/language-core": "^2.4.23",
28
28
  "@volar/typescript": "^2.4.23",
29
29
  "@vue/language-core": "^3.1.3",
30
- "nuxt": "^4.2.0",
30
+ "nuxt": "^4.2.1",
31
31
  "typescript": "^5.9.3"
32
32
  },
33
33
  "scripts": {
File without changes