@dynect/base 0.8.1 → 0.9.0

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/package.json +1 -1
  2. package/src/module.ts +26 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynect/base",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Reusable Nuxt base module — components, composables, utils, plugins and i18n from the Dynect design system.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/module.ts CHANGED
@@ -1,12 +1,4 @@
1
- import {
2
- addComponentsDir,
3
- addImports,
4
- addImportsDir,
5
- addPlugin,
6
- createResolver,
7
- defineNuxtModule,
8
- installModule,
9
- } from '@nuxt/kit';
1
+ import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
10
2
  import { existsSync } from 'node:fs';
11
3
  import { join } from 'node:path';
12
4
 
@@ -80,38 +72,35 @@ export default defineNuxtModule<DynectBaseOptions>({
80
72
  // @/lib/utils → runtime/lib/utils (when not present in consuming app)
81
73
  // This one works via nuxt.options.alias because lib/utils is not prefixed with @
82
74
  if (!existsSync(join(srcDir, 'lib', 'utils.ts'))) {
83
- nuxt.options.alias[join(srcDir, 'lib', 'utils')] =
84
- resolver.resolve('./runtime/lib/utils');
75
+ nuxt.options.alias[join(srcDir, 'lib', 'utils')] = resolver.resolve('./runtime/lib/utils');
85
76
  }
86
77
 
87
78
  // @/components/ui/* → runtime/components/ui/*
88
79
  // Must run BEFORE @ is resolved, so we use a regex alias in vite:extendConfig.
89
80
  // Only applied when the consuming app has no own components/ui directory.
90
- if (isStandalone && !existsSync(join(srcDir, 'components', 'ui'))) {
91
- const uiRuntimePath = join(runtimeComponentsDir, 'ui');
92
-
93
- nuxt.hook('vite:extendConfig', (config) => {
94
- config.resolve ??= {};
95
-
96
- const entry = { find: /^[@~]\/components\/ui/, replacement: uiRuntimePath };
97
-
98
- if (Array.isArray(config.resolve.alias)) {
99
- (config.resolve.alias as any[]).unshift(entry);
100
- } else {
101
- const existing = config.resolve.alias ?? {};
102
- config.resolve.alias = [
103
- entry,
104
- ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement })),
105
- ];
106
- }
107
- });
108
- }
81
+ // if (isStandalone && !existsSync(join(srcDir, 'components', 'ui'))) {
82
+ // const uiRuntimePath = join(runtimeComponentsDir, 'ui');
83
+
84
+ // nuxt.hook('vite:extendConfig', (config) => {
85
+ // config.resolve ??= {};
86
+
87
+ // const entry = { find: /^[@~]\/components\/ui/, replacement: uiRuntimePath };
88
+
89
+ // if (Array.isArray(config.resolve.alias)) {
90
+ // (config.resolve.alias as any[]).unshift(entry);
91
+ // } else {
92
+ // const existing = config.resolve.alias ?? {};
93
+ // config.resolve.alias = [
94
+ // entry,
95
+ // ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement })),
96
+ // ];
97
+ // }
98
+ // });
99
+ // }
109
100
 
110
101
  // ── Install required Nuxt modules ────────────────────────────────────────
111
102
  if (options.shadcn !== false) {
112
- const shadcnComponentDir = isStandalone
113
- ? join(runtimeComponentsDir, 'ui')
114
- : '~/components/ui';
103
+ const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
115
104
 
116
105
  await installModule('shadcn-nuxt', {
117
106
  prefix: '',
@@ -137,9 +126,7 @@ export default defineNuxtModule<DynectBaseOptions>({
137
126
  }
138
127
 
139
128
  if (options.i18n !== false) {
140
- const langDir = isStandalone
141
- ? resolver.resolve('./runtime/assets/lang')
142
- : resolver.resolve('../../../app/assets/lang');
129
+ const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
143
130
 
144
131
  await installModule('@nuxtjs/i18n', {
145
132
  locales: [
@@ -175,9 +162,7 @@ export default defineNuxtModule<DynectBaseOptions>({
175
162
  await installModule('@pinia/nuxt');
176
163
 
177
164
  // ── CSS ──────────────────────────────────────────────────────────────────
178
- const cssPath = isStandalone
179
- ? resolver.resolve('./runtime/assets/css/main.css')
180
- : resolver.resolve('../../../app/assets/css/main.css');
165
+ const cssPath = isStandalone ? resolver.resolve('./runtime/assets/css/main.css') : resolver.resolve('../../../app/assets/css/main.css');
181
166
 
182
167
  if (existsSync(cssPath)) {
183
168
  nuxt.options.css.unshift(cssPath);
@@ -197,18 +182,14 @@ export default defineNuxtModule<DynectBaseOptions>({
197
182
  }
198
183
 
199
184
  // ── Composables ──────────────────────────────────────────────────────────
200
- const composablesPath = isStandalone
201
- ? resolver.resolve('./runtime/composables')
202
- : resolver.resolve('../../../app/composables');
185
+ const composablesPath = isStandalone ? resolver.resolve('./runtime/composables') : resolver.resolve('../../../app/composables');
203
186
 
204
187
  if (existsSync(composablesPath)) {
205
188
  addImportsDir(composablesPath);
206
189
  }
207
190
 
208
191
  // ── Utils ────────────────────────────────────────────────────────────────
209
- const utilsPath = isStandalone
210
- ? resolver.resolve('./runtime/utils')
211
- : resolver.resolve('../../../app/utils');
192
+ const utilsPath = isStandalone ? resolver.resolve('./runtime/utils') : resolver.resolve('../../../app/utils');
212
193
 
213
194
  if (existsSync(utilsPath)) {
214
195
  addImportsDir(utilsPath);