@roku-ui/nuxt 0.30.0 → 0.31.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/module.js +36 -8
  2. package/package.json +4 -4
package/dist/module.js CHANGED
@@ -1,4 +1,5 @@
1
- import { addComponent, createResolver, defineNuxtModule } from '@nuxt/kit';
1
+ import { existsSync } from 'node:fs';
2
+ import { addComponent, createResolver, defineNuxtModule, logger } from '@nuxt/kit';
2
3
  import { rokuPreset } from '@roku-ui/preset';
3
4
  const components = [
4
5
  'AppShell',
@@ -66,22 +67,49 @@ export default defineNuxtModule({
66
67
  defaults: {
67
68
  prefix: 'R',
68
69
  },
69
- setup(options, nuxt) {
70
+ async setup(options, nuxt) {
70
71
  const prefix = options.prefix ?? 'R';
71
- const { resolve } = createResolver(import.meta.url);
72
+ const moduleResolver = createResolver(import.meta.url);
73
+ const appResolver = createResolver(nuxt.options.rootDir);
74
+ const resolvePackagePath = async (id) => {
75
+ const appPath = await appResolver.resolvePath(id, { fallbackToOriginal: true });
76
+ if (existsSync(appPath)) {
77
+ return appPath;
78
+ }
79
+ const modulePath = await moduleResolver.resolvePath(id, { fallbackToOriginal: true });
80
+ if (existsSync(modulePath)) {
81
+ return modulePath;
82
+ }
83
+ return id;
84
+ };
85
+ const vueEntry = await resolvePackagePath('@roku-ui/vue');
86
+ const cssEntry = await resolvePackagePath('@roku-ui/vue/style.css');
87
+ if (vueEntry === '@roku-ui/vue') {
88
+ logger.warn('[roku-ui] Failed to resolve @roku-ui/vue. Please install @roku-ui/vue.');
89
+ }
90
+ if (cssEntry === '@roku-ui/vue/style.css') {
91
+ logger.warn('[roku-ui] Failed to resolve @roku-ui/vue/style.css. Please install @roku-ui/vue.');
92
+ }
72
93
  for (const component of components) {
73
94
  addComponent({
74
95
  name: `${prefix}${component}`,
75
96
  export: component,
76
- filePath: '@roku-ui/vue',
97
+ filePath: vueEntry,
77
98
  global: true,
78
99
  });
79
100
  }
80
101
  const css = nuxt.options.css ?? [];
81
- if (!css.includes('@roku-ui/vue/style.css')) {
82
- css.push('@roku-ui/vue/style.css');
83
- nuxt.options.css = css;
102
+ const cssToken = '@roku-ui/vue/style.css';
103
+ const cssIndex = css.indexOf(cssToken);
104
+ if (cssIndex === -1) {
105
+ if (!css.includes(cssEntry)) {
106
+ css.push(cssEntry);
107
+ }
108
+ }
109
+ else if (cssEntry !== cssToken) {
110
+ css.splice(cssIndex, 1, cssEntry);
84
111
  }
112
+ nuxt.options.css = css;
85
113
  const transpile = nuxt.options.build.transpile ?? [];
86
114
  if (!transpile.includes('@roku-ui/vue')) {
87
115
  transpile.push('@roku-ui/vue');
@@ -89,7 +117,7 @@ export default defineNuxtModule({
89
117
  }
90
118
  nuxt.hook('prepare:types', ({ references }) => {
91
119
  references.push({
92
- path: resolve('./module.d.ts'),
120
+ path: moduleResolver.resolve('./module.d.ts'),
93
121
  });
94
122
  });
95
123
  nuxt.hook('unocss:config', (config) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@roku-ui/nuxt",
3
3
  "type": "module",
4
- "version": "0.30.0",
4
+ "version": "0.31.0",
5
5
  "author": "Jianqi Pan <jannchie@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,8 +27,7 @@
27
27
  ],
28
28
  "peerDependencies": {
29
29
  "@nuxt/kit": "^3.0.0 || ^4.0.0",
30
- "nuxt": "^3.0.0 || ^4.0.0",
31
- "@roku-ui/vue": "^0.30.0"
30
+ "nuxt": "^3.0.0 || ^4.0.0"
32
31
  },
33
32
  "peerDependenciesMeta": {
34
33
  "@nuxt/kit": {
@@ -39,7 +38,8 @@
39
38
  }
40
39
  },
41
40
  "dependencies": {
42
- "@roku-ui/preset": "^0.30.0"
41
+ "@roku-ui/preset": "^0.31.0",
42
+ "@roku-ui/vue": "^0.31.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@nuxt/kit": "^4.2.1",