@dynect/base 0.19.2 → 0.19.4
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 +19 -20
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
|
|
2
|
-
import type { NuxtModule } from '@nuxt/schema';
|
|
1
|
+
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule, resolvePath } from '@nuxt/kit';
|
|
3
2
|
import tailwindcss from '@tailwindcss/vite';
|
|
4
3
|
import { defu } from 'defu';
|
|
5
4
|
import { existsSync } from 'node:fs';
|
|
6
|
-
import { createRequire } from 'node:module';
|
|
7
5
|
import { join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
8
7
|
|
|
9
|
-
//
|
|
10
|
-
// not
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
// Directory of this file — used to resolve sub-modules from @dynect/base's own
|
|
9
|
+
// node_modules (not the consuming app's). resolvePath uses mlly which handles
|
|
10
|
+
// ESM packages with "exports" field, unlike require.resolve which does not.
|
|
11
|
+
const moduleDir = fileURLToPath(new URL('.', import.meta.url));
|
|
12
|
+
|
|
13
|
+
async function resolveModule(id: string): Promise<string> {
|
|
14
|
+
return resolvePath(id, { cwd: moduleDir });
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface DynectBaseOptions {
|
|
@@ -135,10 +136,13 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
139
|
+
// Modules are resolved to absolute paths from @dynect/base's own node_modules
|
|
140
|
+
// so pnpm strict isolation doesn't break resolution. The resolved path string
|
|
141
|
+
// is passed to installModule so Nuxt loads each module through jiti (which
|
|
142
|
+
// handles Nuxt's internal #imports alias). Direct import() bypasses jiti.
|
|
138
143
|
if (options.shadcn !== false) {
|
|
139
144
|
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
140
|
-
|
|
141
|
-
await installModule(shadcnNuxt, {
|
|
145
|
+
await installModule(await resolveModule('shadcn-nuxt'), {
|
|
142
146
|
prefix: '',
|
|
143
147
|
componentDir: shadcnComponentDir,
|
|
144
148
|
...options.shadcn,
|
|
@@ -146,13 +150,11 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
if (options.veeValidate !== false) {
|
|
149
|
-
|
|
150
|
-
await installModule(veeValidateNuxt, options.veeValidate ?? {});
|
|
153
|
+
await installModule(await resolveModule('@vee-validate/nuxt'), options.veeValidate ?? {});
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
if (options.colorMode !== false) {
|
|
154
|
-
|
|
155
|
-
await installModule(colorMode, {
|
|
157
|
+
await installModule(await resolveModule('@nuxtjs/color-mode'), {
|
|
156
158
|
preference: 'system',
|
|
157
159
|
fallback: 'light',
|
|
158
160
|
classPrefix: '',
|
|
@@ -165,8 +167,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
165
167
|
|
|
166
168
|
if (options.i18n !== false) {
|
|
167
169
|
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
168
|
-
|
|
169
|
-
await installModule(i18n, {
|
|
170
|
+
await installModule(await resolveModule('@nuxtjs/i18n'), {
|
|
170
171
|
locales: [
|
|
171
172
|
{ code: 'en', iso: 'en_US', file: 'en.json', name: 'English' },
|
|
172
173
|
{ code: 'ms', iso: 'ms_MY', file: 'ms.json', name: 'Bahasa' },
|
|
@@ -186,8 +187,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
if (options.icon !== false) {
|
|
189
|
-
|
|
190
|
-
await installModule(icon, {
|
|
190
|
+
await installModule(await resolveModule('@nuxt/icon'), {
|
|
191
191
|
provider: 'server',
|
|
192
192
|
mode: 'svg',
|
|
193
193
|
serverBundle: {
|
|
@@ -198,8 +198,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
await installModule(pinia);
|
|
201
|
+
await installModule(await resolveModule('@pinia/nuxt'));
|
|
203
202
|
|
|
204
203
|
// ── CJS dependency pre-bundling ──────────────────────────────────────────
|
|
205
204
|
// bind-event-listener is CJS-only (no ESM export map). Force Vite's esbuild
|