@mantiq/vite 0.5.21 → 0.5.23

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/Vite.ts +12 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantiq/vite",
3
- "version": "0.5.21",
3
+ "version": "0.5.23",
4
4
  "description": "Vite dev server & manifest integration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/Vite.ts CHANGED
@@ -17,7 +17,6 @@ export class Vite {
17
17
  // ── SSR state ───────────────────────────────────────────────────────────
18
18
  private readonly ssrEntry: string | null
19
19
  private readonly ssrBundle: string
20
- private viteDevServer: any | null = null
21
20
  private ssrModuleCache: SSRModule | null = null
22
21
  /** Application base path (for resolving SSR bundle). Set via setBasePath(). */
23
22
  private basePath: string = ''
@@ -316,24 +315,12 @@ export class Vite {
316
315
  }
317
316
 
318
317
  /**
319
- * Get or lazily create the embedded Vite dev server (for SSR module loading).
320
- * Only used in development mode with SSR enabled.
321
- */
322
- private async getViteDevServer(): Promise<any> {
323
- if (this.viteDevServer) return this.viteDevServer
324
-
325
- const { createServer } = await import('vite')
326
- this.viteDevServer = await createServer({
327
- server: { middlewareMode: true },
328
- appType: 'custom',
329
- })
330
-
331
- return this.viteDevServer
332
- }
333
-
334
- /**
335
- * Load the SSR module. In dev mode, uses Vite's ssrLoadModule for HMR.
336
- * In production, imports the pre-built bundle.
318
+ * Load the SSR module.
319
+ *
320
+ * In dev mode: uses Bun's native import (handles TSX, path aliases via tsconfig).
321
+ * No embedded Vite server needed — avoids HMR conflicts with the standalone dev server.
322
+ *
323
+ * In production: imports the pre-built SSR bundle.
337
324
  */
338
325
  private async loadSSRModule(): Promise<SSRModule> {
339
326
  if (this.ssrModuleCache) return this.ssrModuleCache
@@ -345,9 +332,11 @@ export class Vite {
345
332
  let mod: any
346
333
 
347
334
  if (this.isDev()) {
348
- // Dev: use Vite's ssrLoadModule for HMR + transform
349
- const server = await this.getViteDevServer()
350
- mod = await server.ssrLoadModule(this.ssrEntry)
335
+ // Dev: use Bun's native import it handles TSX and tsconfig path aliases
336
+ const entryPath = this.basePath
337
+ ? `${this.basePath}/${this.ssrEntry}`
338
+ : this.ssrEntry
339
+ mod = await import(entryPath)
351
340
  } else {
352
341
  // Prod: import the pre-built SSR bundle
353
342
  const bundlePath = this.basePath
@@ -383,24 +372,7 @@ export class Vite {
383
372
  */
384
373
  private async renderSSR(url: string, data?: Record<string, unknown>): Promise<SSRResult> {
385
374
  const ssrModule = await this.loadSSRModule()
386
-
387
- try {
388
- return await ssrModule.render(url, data)
389
- } catch (err) {
390
- // In dev, fix the stack trace for better DX
391
- if (this.isDev() && this.viteDevServer && err instanceof Error) {
392
- this.viteDevServer.ssrFixStacktrace(err)
393
- }
394
- throw err
395
- }
396
- }
397
-
398
- /** Close the embedded Vite dev server (cleanup). */
399
- async closeDevServer(): Promise<void> {
400
- if (this.viteDevServer) {
401
- await this.viteDevServer.close()
402
- this.viteDevServer = null
403
- }
375
+ return await ssrModule.render(url, data)
404
376
  }
405
377
 
406
378
  // ── HTML Shell ───────────────────────────────────────────────────────────