@mframework/ui 0.0.5 → 0.0.6-beta

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.
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: (nuxtApp: any) => void;
2
2
  export default _default;
@@ -1,8 +1,7 @@
1
- import { defineNuxtPlugin } from '#app';
2
1
  import { getSearchClient } from './client';
3
- export default defineNuxtPlugin((nuxtApp) => {
2
+ export default (nuxtApp) => {
4
3
  const client = getSearchClient();
5
4
  const indexName = process.env.NUXT_PUBLIC_SEARCH_INDEX || 'default';
6
5
  nuxtApp.provide('mSearchClient', client);
7
6
  nuxtApp.provide('mSearchIndex', indexName);
8
- });
7
+ };
package/module.ts CHANGED
@@ -56,11 +56,34 @@ export default defineNuxtModule<MFrameworkUiOptions>({
56
56
  await installModule('@nuxt/fonts', options.fonts || {})
57
57
 
58
58
  //
59
- // 4. Install Vuetify via vuetify-nuxt-module
59
+ // 4. Install Vuetify via vuetify-nuxt-module (optional).
60
+ // First check whether the consuming project actually has `vuetify`
61
+ // installed to avoid Nuxt failing during module resolution.
60
62
  //
61
- await installModule('vuetify', {
62
- vuetifyOptions: options.vuetify?.vuetifyOptions || {}
63
- })
63
+ let vuetifyInstalled = false
64
+ try {
65
+ // Use Node resolution from this project's root to detect installed package
66
+ // without triggering Nuxt's module loader.
67
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
68
+ const { createRequire } = 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
+ }
81
+ } 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
86
+ }
64
87
 
65
88
  //
66
89
  // 5. Tailwind + Vuetify coexistence
@@ -71,7 +94,9 @@ export default defineNuxtModule<MFrameworkUiOptions>({
71
94
 
72
95
  nuxt.options.postcss = nuxt.options.postcss || { plugins: {}, order: [] }
73
96
  nuxt.options.postcss.plugins = nuxt.options.postcss.plugins || {}
74
- nuxt.options.postcss.plugins['tailwindcss'] = {}
97
+ // Use the new PostCSS adapter package name so Nuxt doesn't try to
98
+ // use the old `tailwindcss` package as a PostCSS plugin.
99
+ nuxt.options.postcss.plugins['@tailwindcss/postcss'] = {}
75
100
  nuxt.options.postcss.plugins['autoprefixer'] = {}
76
101
 
77
102
  nuxt.options.tailwindcss = {
@@ -80,11 +105,22 @@ export default defineNuxtModule<MFrameworkUiOptions>({
80
105
  }
81
106
 
82
107
  //
83
- // 6. Register plugins (icons, theme, icon switching, search)
108
+ // 6. Register plugins (icons, theme, icon switching, search).
109
+ // Only register plugins that require Vuetify when Vuetify is available.
84
110
  //
85
- addPlugin(resolve('./runtime/plugins/theme'))
86
- addPlugin(resolve('./runtime/plugins/icon-switcher'))
87
- addPlugin(resolve('./runtime/search/plugin'))
111
+ if (vuetifyInstalled) {
112
+ addPlugin(resolve('./runtime/plugins/theme'))
113
+ addPlugin(resolve('./runtime/plugins/icon-switcher'))
114
+ addPlugin(resolve('./runtime/search/plugin'))
115
+ } else {
116
+ // If Vuetify isn't installed, we still register a minimal search plugin
117
+ // that doesn't depend on Vuetify, if present. Keep module resilient.
118
+ try {
119
+ addPlugin(resolve('./runtime/search/plugin'))
120
+ } catch (e) {
121
+ // ignore — plugin not critical
122
+ }
123
+ }
88
124
 
89
125
  //
90
126
  // 7. Auto-import components from this module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mframework/ui",
3
- "version": "0.0.5",
3
+ "version": "0.0.6-beta",
4
4
  "description": "Official opinionated UI module for the M Framework.",
5
5
  "keywords": [
6
6
  "ui",
@@ -1,10 +1,9 @@
1
- import { defineNuxtPlugin } from '#app'
2
1
  import { getSearchClient } from './client'
3
2
 
4
- export default defineNuxtPlugin((nuxtApp) => {
3
+ export default (nuxtApp: any) => {
5
4
  const client = getSearchClient()
6
5
  const indexName = process.env.NUXT_PUBLIC_SEARCH_INDEX || 'default'
7
6
 
8
7
  nuxtApp.provide('mSearchClient', client)
9
8
  nuxtApp.provide('mSearchIndex', indexName)
10
- })
9
+ }