shadcn-nuxt 2.1.0 → 2.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
@@ -3,11 +3,14 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  interface ModuleOptions {
4
4
  /**
5
5
  * Prefix for all the imported component.
6
+ * @default "Ui"
6
7
  */
7
8
  prefix?: string;
8
9
  /**
9
10
  * Directory that the component lives in.
10
- * @default "./components/ui"
11
+ * Will respect the Nuxt aliases.
12
+ * @link https://nuxt.com/docs/api/nuxt-config#alias
13
+ * @default "@/components/ui"
11
14
  */
12
15
  componentDir?: string;
13
16
  }
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "shadcn",
3
3
  "configKey": "shadcn",
4
- "version": "2.1.0",
4
+ "version": "2.3.0",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.4",
6
+ "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "unknown"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,15 +1,7 @@
1
- import { readdirSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { defineNuxtModule, createResolver, useLogger, addTemplate, findPath, addComponent } from '@nuxt/kit';
4
- import { parseSync } from '@oxc-parser/wasm';
5
-
6
- const UTILS = `import { type ClassValue, clsx } from 'clsx'
7
- import { twMerge } from 'tailwind-merge'
8
-
9
- export function cn(...inputs: ClassValue[]) {
10
- return twMerge(clsx(inputs))
11
- }
12
- `;
3
+ import { defineNuxtModule, createResolver, addComponentsDir, addComponent } from '@nuxt/kit';
4
+ import { parseSync } from 'oxc-parser';
13
5
 
14
6
  const module = defineNuxtModule({
15
7
  meta: {
@@ -18,40 +10,33 @@ const module = defineNuxtModule({
18
10
  },
19
11
  defaults: {
20
12
  prefix: "Ui",
21
- componentDir: "./components/ui"
13
+ componentDir: "@/components/ui"
22
14
  },
23
15
  async setup({ prefix, componentDir }, nuxt) {
24
16
  const COMPONENT_DIR_PATH = componentDir;
25
17
  const ROOT_DIR_PATH = nuxt.options.rootDir;
26
- const UTILS_ALIAS = "@/lib/utils";
27
18
  const { resolve, resolvePath } = createResolver(ROOT_DIR_PATH);
28
- const logger = useLogger("shadcn-nuxt");
29
- const utilsTemplate = addTemplate({
30
- filename: "shadcn-nuxt/utils.ts",
31
- getContents: () => UTILS,
32
- write: true
33
- });
34
- nuxt.options.alias = { [UTILS_ALIAS]: utilsTemplate.dst, ...nuxt.options.alias };
35
- const isRootUtilsExists = await findPath("./lib/utils.ts", { cwd: ROOT_DIR_PATH });
36
- if (isRootUtilsExists)
37
- logger.warn("[shadcn-nuxt] `lib/utils.ts` is auto generated by the module and can be safely removed.");
38
- const componentsPath = resolve(COMPONENT_DIR_PATH);
39
- nuxt.hook("components:dirs", (dirs) => {
40
- dirs.unshift({
41
- path: componentsPath,
42
- extensions: []
43
- });
19
+ const componentsPath = await resolvePath(COMPONENT_DIR_PATH);
20
+ if (!existsSync(componentsPath)) {
21
+ console.warn(`Component directory does not exist: ${componentsPath}`);
22
+ return;
23
+ }
24
+ addComponentsDir({
25
+ path: componentsPath,
26
+ extensions: [],
27
+ ignore: ["**/*"]
28
+ }, {
29
+ prepend: true
44
30
  });
45
31
  try {
46
- readdirSync(resolve(COMPONENT_DIR_PATH)).forEach(async (dir) => {
32
+ await Promise.all(readdirSync(componentsPath).map(async (dir) => {
47
33
  try {
48
34
  const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, "index"), { extensions: [".ts", ".js"] });
49
35
  const content = readFileSync(filePath, { encoding: "utf8" });
50
- const ast = parseSync(content, {
51
- sourceType: "module",
52
- sourceFilename: filePath
36
+ const ast = parseSync(filePath, content, {
37
+ sourceType: "module"
53
38
  });
54
- const exportedKeys = ast.program.body.filter((node) => node.type === "ExportNamedDeclaration").flatMap((node) => node.specifiers.map((specifier) => specifier.exported.name)).filter((key) => /^[A-Z]/.test(key));
39
+ const exportedKeys = ast.program.body.filter((node) => node.type === "ExportNamedDeclaration").flatMap((node) => node.specifiers?.map((specifier) => specifier.exported?.name) || []).filter((key) => /^[A-Z]/.test(key));
55
40
  exportedKeys.forEach((key) => {
56
41
  addComponent({
57
42
  name: `${prefix}${key}`,
@@ -66,7 +51,7 @@ const module = defineNuxtModule({
66
51
  if (err instanceof Error)
67
52
  console.warn("Module error: ", err.message);
68
53
  }
69
- });
54
+ }));
70
55
  } catch (err) {
71
56
  if (err instanceof Error)
72
57
  console.warn(err.message);
package/dist/types.d.mts CHANGED
@@ -1 +1 @@
1
- export { type ModuleOptions, default } from './module.js'
1
+ export { type ModuleOptions, default } from './module.mjs'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shadcn-nuxt",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.3.0",
5
5
  "description": "Add shadcn-vue module to Nuxt",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -14,32 +14,31 @@
14
14
  },
15
15
  "exports": {
16
16
  ".": {
17
- "types": "./dist/types.d.ts",
18
- "import": "./dist/module.mjs",
19
- "require": "./dist/module.cjs"
17
+ "types": "./dist/types.d.mts",
18
+ "import": "./dist/module.mjs"
20
19
  }
21
20
  },
22
- "main": "./dist/module.cjs",
23
- "types": "./dist/types.d.ts",
21
+ "main": "./dist/module.mjs",
24
22
  "files": [
25
23
  "dist"
26
24
  ],
27
25
  "dependencies": {
28
- "@nuxt/kit": "^3.15.4",
29
- "@oxc-parser/wasm": "^0.50.0",
30
- "typescript": "5.6.3"
26
+ "@nuxt/kit": "^3.17.4",
27
+ "oxc-parser": "^0.93.0"
31
28
  },
32
29
  "devDependencies": {
33
- "@nuxt/eslint-config": "^1.0.1",
34
- "@nuxt/module-builder": "^0.8.4",
35
- "@nuxt/schema": "^3.15.4",
36
- "@nuxt/test-utils": "^3.15.4",
30
+ "@nuxt/eslint-config": "^1.4.1",
31
+ "@nuxt/module-builder": "^1.0.1",
32
+ "@nuxt/schema": "^3.17.4",
33
+ "@nuxt/test-utils": "^3.19.1",
37
34
  "@nuxtjs/color-mode": "^3.5.2",
38
- "@nuxtjs/tailwindcss": "^6.13.1",
39
- "@types/node": "^22.13.1",
40
- "nuxt": "^3.16.0"
35
+ "@nuxtjs/tailwindcss": "^6.14.0",
36
+ "@types/node": "^22",
37
+ "nuxt": "^3.17.4",
38
+ "typescript": "^5.8.3"
41
39
  },
42
40
  "scripts": {
41
+ "build": "nuxt-module-build prepare && nuxt-module-build build",
43
42
  "dev": "nuxi dev playground",
44
43
  "dev:build": "nuxi build playground",
45
44
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- /**
5
- * Prefix for all the imported component.
6
- */
7
- prefix?: string;
8
- /**
9
- * Directory that the component lives in.
10
- * @default "./components/ui"
11
- */
12
- componentDir?: string;
13
- }
14
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
15
-
16
- export { type ModuleOptions, _default as default };
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export { type ModuleOptions, default } from './module'