@dynect/base 0.19.0 → 0.19.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/package.json +1 -1
- package/src/module.ts +30 -8
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
|
|
2
|
+
import type { NuxtModule } from '@nuxt/schema';
|
|
2
3
|
import tailwindcss from '@tailwindcss/vite';
|
|
3
4
|
import { defu } from 'defu';
|
|
4
5
|
import { existsSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
5
7
|
import { join } from 'node:path';
|
|
6
8
|
|
|
9
|
+
// Resolve sub-module paths from this package's own node_modules,
|
|
10
|
+
// not from the consuming app's node_modules.
|
|
11
|
+
const _require = createRequire(import.meta.url);
|
|
12
|
+
function resolveModule(id: string): string {
|
|
13
|
+
return _require.resolve(id);
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
export interface DynectBaseOptions {
|
|
8
17
|
/** Component folder groups to register. Defaults to all. */
|
|
9
18
|
dirs?: Array<'dynect' | 'ui' | 'base' | 'chart'>;
|
|
@@ -128,8 +137,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
128
137
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
129
138
|
if (options.shadcn !== false) {
|
|
130
139
|
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
131
|
-
|
|
132
|
-
await installModule(
|
|
140
|
+
const { default: shadcnNuxt } = await import(resolveModule('shadcn-nuxt')) as { default: NuxtModule };
|
|
141
|
+
await installModule(shadcnNuxt, {
|
|
133
142
|
prefix: '',
|
|
134
143
|
componentDir: shadcnComponentDir,
|
|
135
144
|
...options.shadcn,
|
|
@@ -137,11 +146,13 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
if (options.veeValidate !== false) {
|
|
140
|
-
await
|
|
149
|
+
const { default: veeValidateNuxt } = await import(resolveModule('@vee-validate/nuxt')) as { default: NuxtModule };
|
|
150
|
+
await installModule(veeValidateNuxt, options.veeValidate ?? {});
|
|
141
151
|
}
|
|
142
152
|
|
|
143
153
|
if (options.colorMode !== false) {
|
|
144
|
-
await
|
|
154
|
+
const { default: colorMode } = await import(resolveModule('@nuxtjs/color-mode')) as { default: NuxtModule };
|
|
155
|
+
await installModule(colorMode, {
|
|
145
156
|
preference: 'system',
|
|
146
157
|
fallback: 'light',
|
|
147
158
|
classPrefix: '',
|
|
@@ -154,8 +165,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
154
165
|
|
|
155
166
|
if (options.i18n !== false) {
|
|
156
167
|
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
157
|
-
|
|
158
|
-
await installModule(
|
|
168
|
+
const { default: i18n } = await import(resolveModule('@nuxtjs/i18n')) as { default: NuxtModule };
|
|
169
|
+
await installModule(i18n, {
|
|
159
170
|
locales: [
|
|
160
171
|
{ code: 'en', iso: 'en_US', file: 'en.json', name: 'English' },
|
|
161
172
|
{ code: 'ms', iso: 'ms_MY', file: 'ms.json', name: 'Bahasa' },
|
|
@@ -175,7 +186,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
175
186
|
}
|
|
176
187
|
|
|
177
188
|
if (options.icon !== false) {
|
|
178
|
-
await
|
|
189
|
+
const { default: icon } = await import(resolveModule('@nuxt/icon')) as { default: NuxtModule };
|
|
190
|
+
await installModule(icon, {
|
|
179
191
|
provider: 'server',
|
|
180
192
|
mode: 'svg',
|
|
181
193
|
serverBundle: {
|
|
@@ -186,7 +198,17 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
186
198
|
});
|
|
187
199
|
}
|
|
188
200
|
|
|
189
|
-
await
|
|
201
|
+
const { default: pinia } = await import(resolveModule('@pinia/nuxt')) as { default: NuxtModule };
|
|
202
|
+
await installModule(pinia);
|
|
203
|
+
|
|
204
|
+
// ── CJS dependency pre-bundling ──────────────────────────────────────────
|
|
205
|
+
// bind-event-listener is CJS-only (no ESM export map). Force Vite's esbuild
|
|
206
|
+
// pre-bundler to convert it so named imports like { bind } work at runtime.
|
|
207
|
+
nuxt.options.vite.optimizeDeps ??= {};
|
|
208
|
+
nuxt.options.vite.optimizeDeps.include ??= [];
|
|
209
|
+
if (!nuxt.options.vite.optimizeDeps.include.includes('bind-event-listener')) {
|
|
210
|
+
nuxt.options.vite.optimizeDeps.include.push('bind-event-listener');
|
|
211
|
+
}
|
|
190
212
|
|
|
191
213
|
// ── CSS ──────────────────────────────────────────────────────────────────
|
|
192
214
|
const cssPath = isStandalone ? resolver.resolve('./runtime/assets/css/main.css') : resolver.resolve('../../../app/assets/css/main.css');
|