@dynect/base 0.19.1 → 0.19.3
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 +24 -9
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
|
|
1
|
+
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule, resolvePath } 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';
|
|
5
6
|
import { join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
// Directory of this file — used to resolve sub-modules from @dynect/base's own
|
|
10
|
+
// node_modules (not the consuming app's). resolvePath uses mlly which handles
|
|
11
|
+
// ESM packages with "exports" field, unlike require.resolve which does not.
|
|
12
|
+
const moduleDir = fileURLToPath(new URL('.', import.meta.url));
|
|
13
|
+
|
|
14
|
+
async function resolveModule(id: string): Promise<string> {
|
|
15
|
+
return resolvePath(id, { cwd: moduleDir });
|
|
16
|
+
}
|
|
6
17
|
|
|
7
18
|
export interface DynectBaseOptions {
|
|
8
19
|
/** Component folder groups to register. Defaults to all. */
|
|
@@ -128,8 +139,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
128
139
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
129
140
|
if (options.shadcn !== false) {
|
|
130
141
|
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
131
|
-
|
|
132
|
-
await installModule(
|
|
142
|
+
const { default: shadcnNuxt } = await import(await resolveModule('shadcn-nuxt')) as { default: NuxtModule };
|
|
143
|
+
await installModule(shadcnNuxt, {
|
|
133
144
|
prefix: '',
|
|
134
145
|
componentDir: shadcnComponentDir,
|
|
135
146
|
...options.shadcn,
|
|
@@ -137,11 +148,13 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
137
148
|
}
|
|
138
149
|
|
|
139
150
|
if (options.veeValidate !== false) {
|
|
140
|
-
await
|
|
151
|
+
const { default: veeValidateNuxt } = await import(await resolveModule('@vee-validate/nuxt')) as { default: NuxtModule };
|
|
152
|
+
await installModule(veeValidateNuxt, options.veeValidate ?? {});
|
|
141
153
|
}
|
|
142
154
|
|
|
143
155
|
if (options.colorMode !== false) {
|
|
144
|
-
await
|
|
156
|
+
const { default: colorMode } = await import(await resolveModule('@nuxtjs/color-mode')) as { default: NuxtModule };
|
|
157
|
+
await installModule(colorMode, {
|
|
145
158
|
preference: 'system',
|
|
146
159
|
fallback: 'light',
|
|
147
160
|
classPrefix: '',
|
|
@@ -154,8 +167,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
154
167
|
|
|
155
168
|
if (options.i18n !== false) {
|
|
156
169
|
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
157
|
-
|
|
158
|
-
await installModule(
|
|
170
|
+
const { default: i18n } = await import(await resolveModule('@nuxtjs/i18n')) as { default: NuxtModule };
|
|
171
|
+
await installModule(i18n, {
|
|
159
172
|
locales: [
|
|
160
173
|
{ code: 'en', iso: 'en_US', file: 'en.json', name: 'English' },
|
|
161
174
|
{ code: 'ms', iso: 'ms_MY', file: 'ms.json', name: 'Bahasa' },
|
|
@@ -175,7 +188,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
175
188
|
}
|
|
176
189
|
|
|
177
190
|
if (options.icon !== false) {
|
|
178
|
-
await
|
|
191
|
+
const { default: icon } = await import(await resolveModule('@nuxt/icon')) as { default: NuxtModule };
|
|
192
|
+
await installModule(icon, {
|
|
179
193
|
provider: 'server',
|
|
180
194
|
mode: 'svg',
|
|
181
195
|
serverBundle: {
|
|
@@ -186,7 +200,8 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
186
200
|
});
|
|
187
201
|
}
|
|
188
202
|
|
|
189
|
-
await
|
|
203
|
+
const { default: pinia } = await import(await resolveModule('@pinia/nuxt')) as { default: NuxtModule };
|
|
204
|
+
await installModule(pinia);
|
|
190
205
|
|
|
191
206
|
// ── CJS dependency pre-bundling ──────────────────────────────────────────
|
|
192
207
|
// bind-event-listener is CJS-only (no ESM export map). Force Vite's esbuild
|