@mframework/ui 0.0.6-beta4 → 0.0.6-beta6

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/module.ts +20 -85
  2. package/package.json +1 -1
package/module.ts CHANGED
@@ -4,22 +4,22 @@ import {
4
4
  addPlugin,
5
5
  addComponentsDir,
6
6
  createResolver,
7
- installModule
7
+ installModule,
8
+ resolveModule
8
9
  } from '@nuxt/kit'
9
10
 
10
11
  export interface MFrameworkUiOptions {
11
- image ? : Record < string, any >
12
- fonts ? : Record < string, any >
13
- vuetify ? : {
14
- vuetifyOptions ? : Record < string,
15
- any >
16
- }
17
- tailwind ? : {
18
- enable ? : boolean
12
+ image?: Record<string, any>
13
+ fonts?: Record<string, any>
14
+ vuetify?: {
15
+ vuetifyOptions?: Record<string, any>
16
+ }
17
+ tailwind?: {
18
+ enable?: boolean
19
19
  }
20
20
  }
21
21
 
22
- export default defineNuxtModule < MFrameworkUiOptions > ({
22
+ export default defineNuxtModule<MFrameworkUiOptions>({
23
23
  meta: {
24
24
  name: '@mframework/ui',
25
25
  configKey: 'mframeworkUi'
@@ -38,10 +38,9 @@ export default defineNuxtModule < MFrameworkUiOptions > ({
38
38
  enable: true
39
39
  }
40
40
  },
41
+
41
42
  async setup(options, nuxt) {
42
- const {
43
- resolve
44
- } = createResolver(import.meta.url)
43
+ const { resolve } = createResolver(import.meta.url)
45
44
 
46
45
  //
47
46
  // 1. Expose options to runtime
@@ -49,89 +48,25 @@ export default defineNuxtModule < MFrameworkUiOptions > ({
49
48
  nuxt.options.runtimeConfig.public.mframeworkUi = options
50
49
 
51
50
  //
52
- // 3. Install @nuxt/fonts
51
+ // 2. Install @nuxt/fonts
53
52
  //
54
53
  await installModule('@nuxt/fonts', options.fonts || {})
55
54
 
56
55
  //
57
- // 4. Install Vuetify via vuetify-nuxt-module (optional).
56
+ // 3. Install Vuetify via vuetify-nuxt-module (optional).
58
57
  // First check whether the consuming project actually has `vuetify`
59
58
  // installed to avoid Nuxt failing during module resolution.
60
59
  //
61
- let vuetifyInstalled = false
60
+ let vuetifyModulePath: string | null = null
62
61
  try {
63
- // Use Node resolution from this project's root to detect installed package
64
- // without triggering Nuxt's module loader.
65
- // eslint-disable-next-line @typescript-eslint/no-var-requires
66
- const {
67
- createRequire
68
- } = await import('module')
69
- const req = createRequire(import.meta.url)
70
- try {
71
- req.resolve('vuetify')
72
- // Vuetify is present in the project's node_modules. We won't call
73
- // `installModule` here to avoid forcing Nuxt to load the module
74
- // during `nuxt prepare` (which can fail in some install environments).
75
- vuetifyInstalled = true
76
- } catch (e) {
77
- // Vuetify not found — skip installing the module
78
- // eslint-disable-next-line no-console
79
- console.warn('@mframework/ui: Vuetify not found in project dependencies; skipping Vuetify integration.')
80
- }
62
+ vuetifyModulePath = resolveModule('vuetify-nuxt-module', { paths: [nuxt.options.modulesDir] })
81
63
  } catch (err) {
82
- // If resolution itself fails for any reason, avoid breaking the setup.
83
- // eslint-disable-next-line no-console
84
- console.warn('@mframework/ui: Failed to detect Vuetify availability; skipping Vuetify integration.')
85
- vuetifyInstalled = false
64
+ // Module not found, skip Vuetify installation
65
+ console.warn('[mframework-ui] Vuetify not found, skipping Vuetify setup.')
86
66
  }
87
67
 
88
- //
89
- // 5. Tailwind + Vuetify coexistence
90
- //
91
- if (options.tailwind?.enable !== false) {
92
- nuxt.options.css = nuxt.options.css || []
93
- nuxt.options.css.push(resolve('./runtime/assets/css/tailwind.css'))
94
-
95
- nuxt.options.postcss = nuxt.options.postcss || {
96
- plugins: {},
97
- order: []
98
- }
99
- nuxt.options.postcss.plugins = nuxt.options.postcss.plugins || {}
100
- // Use the new PostCSS adapter package name so Nuxt doesn't try to
101
- // use the old `tailwindcss` package as a PostCSS plugin.
102
- nuxt.options.postcss.plugins['@tailwindcss/postcss'] = {}
103
- nuxt.options.postcss.plugins['autoprefixer'] = {}
104
-
105
- nuxt.options.tailwindcss = {
106
- configPath: resolve('./runtime/assets/config/tailwind.config.cjs')
107
- }
68
+ if (vuetifyModulePath) {
69
+ await installModule(vuetifyModulePath, options.vuetify || {})
108
70
  }
109
-
110
- //
111
- // 6. Register plugins (icons, theme, icon switching, search).
112
- // Only register plugins that require Vuetify when Vuetify is available.
113
- //
114
- // Install Vuetify first
115
- await installModule(resolveModule('vuetify-nuxt-module'), {
116
- vuetifyOptions: options.vuetify?.vuetifyOptions || {}
117
- })
118
-
119
- // THEN load plugins that depend on Vuetify
120
- addPlugin(resolve('./runtime/plugins/theme'))
121
- addPlugin(resolve('./runtime/plugins/icon-switcher'))
122
-
123
- //
124
- // 7. Auto-import components from this module
125
- //
126
- addComponentsDir({
127
- path: resolve('./runtime/components'),
128
- pathPrefix: false,
129
- prefix: 'M'
130
- })
131
-
132
- addComponentsDir({
133
- path: resolve('./runtime/search/components'),
134
- prefix: 'M'
135
- })
136
71
  }
137
72
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mframework/ui",
3
- "version": "0.0.6-beta4",
3
+ "version": "0.0.6-beta6",
4
4
  "description": "Official opinionated UI module for the M Framework.",
5
5
  "keywords": [
6
6
  "ui",