@ditojs/server 2.2.16 → 2.3.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "2.2.16",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/server",
@@ -22,10 +22,10 @@
22
22
  "node >= 18"
23
23
  ],
24
24
  "dependencies": {
25
- "@ditojs/admin": "^2.2.16",
26
- "@ditojs/build": "^2.2.3",
27
- "@ditojs/router": "^2.2.0",
28
- "@ditojs/utils": "^2.2.0",
25
+ "@ditojs/admin": "^2.3.1",
26
+ "@ditojs/build": "^2.3.0",
27
+ "@ditojs/router": "^2.3.0",
28
+ "@ditojs/utils": "^2.3.0",
29
29
  "@koa/cors": "^4.0.0",
30
30
  "@koa/multer": "^3.0.2",
31
31
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -88,7 +88,7 @@
88
88
  "typescript": "^5.0.4"
89
89
  },
90
90
  "types": "types",
91
- "gitHead": "722b79d58335e249802d250fca9d250bad511b8c",
91
+ "gitHead": "1b5f5121a2e8e6d3741f0bb2b81d38c2343810d6",
92
92
  "scripts": {
93
93
  "types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
94
94
  },
@@ -394,8 +394,32 @@ export class Application extends Koa {
394
394
  )
395
395
  }
396
396
 
397
+ defineAdminViteConfig(config) {
398
+ return this.getAdminController()?.defineViteConfig(config) || null
399
+ }
400
+
397
401
  getAdminViteConfig(config) {
398
- return this.getAdminController()?.getViteConfig(config) || null
402
+ deprecate(
403
+ `app.getAdminViteConfig() is deprecated. Use app.defineAdminViteConfig() instead.`
404
+ )
405
+
406
+ return this.defineAdminViteConfig(config)
407
+ }
408
+
409
+ async loadAdminViteConfig() {
410
+ const cwd = process.cwd()
411
+ for (const extension of ['js', 'mjs', 'cjs', 'ts']) {
412
+ const file = path.join(cwd, `admin.vite.config.${extension}`)
413
+ try {
414
+ await fs.access(file)
415
+ return (await import(file)).default
416
+ } catch (error) {
417
+ if (error.code !== 'ENOENT') {
418
+ throw error
419
+ }
420
+ }
421
+ }
422
+ return null
399
423
  }
400
424
 
401
425
  getAssetConfig({
@@ -805,7 +829,7 @@ export class Application extends Koa {
805
829
  }
806
830
 
807
831
  startOrExit() {
808
- deprecate(`app.startOrExit() is deprecated. Call app.execute() instead.`)
832
+ deprecate(`app.startOrExit() is deprecated. Use app.execute() instead.`)
809
833
  return this.execute()
810
834
  }
811
835
 
@@ -128,7 +128,11 @@ export class AdminController extends Controller {
128
128
  }
129
129
 
130
130
  async setupViteServer() {
131
- const config = this.getViteConfig()
131
+ const config = (
132
+ (await this.app.loadAdminViteConfig()) ||
133
+ this.defineViteConfig()
134
+ )
135
+
132
136
  const development = this.mode === 'development'
133
137
  const server = await createServer({
134
138
  ...config,
@@ -167,7 +171,7 @@ export class AdminController extends Controller {
167
171
  )
168
172
  }
169
173
 
170
- getViteConfig(config = {}) {
174
+ defineViteConfig(config = {}) {
171
175
  const development = this.mode === 'development'
172
176
 
173
177
  const cwd = process.cwd()
@@ -202,37 +206,37 @@ export class AdminController extends Controller {
202
206
  }
203
207
  }
204
208
  ],
205
- build: {
206
- ...(!development && {
207
- outDir: this.getPath('dist'),
208
- assetsDir: '.',
209
- emptyOutDir: true,
210
- chunkSizeWarningLimit: 1000,
211
- rollupOptions: {
212
- output: {
213
- manualChunks(id) {
214
- if (id.startsWith(views)) {
215
- return 'views'
216
- } else if (id.startsWith(cwd)) {
217
- return 'common'
218
- } else {
219
- const module = id.match(
220
- /node_modules\/((?:@[^/]*\/)?[^/$]*)/
221
- )?.[1]
222
- // Internal ids (vite modules) don't come from
223
- // node_modules, and the ids actually start with \0x00.
224
- return (
225
- !module ||
226
- testModuleIdentifier(module, coreDependencies)
227
- )
228
- ? 'core'
229
- : 'vendor'
209
+ build: development
210
+ ? {}
211
+ : {
212
+ outDir: this.getPath('dist'),
213
+ assetsDir: '.',
214
+ emptyOutDir: true,
215
+ chunkSizeWarningLimit: 1000,
216
+ rollupOptions: {
217
+ output: {
218
+ manualChunks(id) {
219
+ if (id.startsWith(views)) {
220
+ return 'views'
221
+ } else if (id.startsWith(cwd)) {
222
+ return 'common'
223
+ } else {
224
+ const module = id.match(
225
+ /node_modules\/((?:@[^/]*\/)?[^/$]*)/
226
+ )?.[1]
227
+ // Internal ids (vite modules) don't come from
228
+ // node_modules, and the ids actually start with \0x00.
229
+ return (
230
+ !module ||
231
+ testModuleIdentifier(module, coreDependencies)
232
+ )
233
+ ? 'core'
234
+ : 'vendor'
235
+ }
230
236
  }
231
237
  }
232
238
  }
233
- }
234
- })
235
- },
239
+ },
236
240
  css: {
237
241
  postcss: getPostCssConfig(),
238
242
  devSourcemap: development
package/types/index.d.ts CHANGED
@@ -1089,6 +1089,8 @@ export class AdminController extends Controller {
1089
1089
  sendDitoObject(ctx: Koa.Context): void
1090
1090
  middleware(): Koa.Middleware
1091
1091
  setupViteServer(): void
1092
+ defineViteConfig(config: UserConfig): UserConfig
1093
+ /** @deprecated Use `defineViteConfig` instead. */
1092
1094
  getViteConfig(config: UserConfig): UserConfig
1093
1095
  }
1094
1096
  type ModelControllerHookType = 'collection' | 'member'