mokup 2.3.2 → 2.3.5

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/dist/vite.cjs CHANGED
@@ -46,6 +46,11 @@ function normalizeMokupOptions(options) {
46
46
  "[mokup] Invalid config: use mokup({ entries: { ... } }) instead of mokup({ dir, prefix, ... })."
47
47
  );
48
48
  }
49
+ if (options.runtime === "vite") {
50
+ throw new Error(
51
+ '[mokup] Invalid config: runtime "vite" is no longer supported. Use "node" or "worker".'
52
+ );
53
+ }
49
54
  return options;
50
55
  }
51
56
  function normalizeOptions(options) {
@@ -214,8 +219,12 @@ function createRouteRefresher(params) {
214
219
  state.configFiles,
215
220
  state.disabledConfigFiles
216
221
  );
222
+ const changed = signature !== state.lastSignature || options?.force;
223
+ if (changed && state.swRoutes.length > 0) {
224
+ state.swModuleVersion = (state.swModuleVersion ?? 0) + 1;
225
+ }
217
226
  if (isViteDevServer(server) && server.ws) {
218
- const shouldNotify = !options?.silent && state.lastSignature && (signature !== state.lastSignature || options?.force);
227
+ const shouldNotify = !options?.silent && state.lastSignature && changed;
219
228
  if (shouldNotify) {
220
229
  server.ws.send({
221
230
  type: "custom",
@@ -449,6 +458,9 @@ async function configureDevServer(params) {
449
458
  watchEnabled
450
459
  } = params;
451
460
  await refreshRoutes(server);
461
+ if (enableViteMiddleware && state.serverRoutes.length > 0) {
462
+ addMiddlewareFirst(server, core.createMiddleware(() => state.app, logger));
463
+ }
452
464
  addMiddlewareFirst(server, playgroundMiddleware);
453
465
  if (playgroundConfig.enabled) {
454
466
  const playgroundPath = resolveRegisterPath(base, playgroundConfig.path);
@@ -468,7 +480,8 @@ async function configureDevServer(params) {
468
480
  root,
469
481
  runtimeImportPath: resolveSwRuntimeImportPath(base),
470
482
  loggerImportPath: resolveSwLoggerImportPath(base),
471
- basePaths: swConfig?.basePaths ?? []
483
+ basePaths: swConfig?.basePaths ?? [],
484
+ moduleVersion: state.swModuleVersion
472
485
  });
473
486
  res.statusCode = 200;
474
487
  res.setHeader("Content-Type", "application/javascript; charset=utf-8");
@@ -482,9 +495,6 @@ async function configureDevServer(params) {
482
495
  }
483
496
  });
484
497
  }
485
- if (enableViteMiddleware && state.serverRoutes.length > 0) {
486
- server.middlewares.use(core.createMiddleware(() => state.app, logger));
487
- }
488
498
  if (!watchEnabled) {
489
499
  return;
490
500
  }
@@ -512,6 +522,9 @@ async function configurePreviewServer(params) {
512
522
  watchEnabled
513
523
  } = params;
514
524
  await refreshRoutes(server);
525
+ if (enableViteMiddleware && state.serverRoutes.length > 0) {
526
+ addMiddlewareFirst(server, core.createMiddleware(() => state.app, logger));
527
+ }
515
528
  addMiddlewareFirst(server, playgroundMiddleware);
516
529
  const swPath = swConfig ? resolveRegisterPath(base, swConfig.path) : null;
517
530
  if (swPath && hasSwRoutes()) {
@@ -525,7 +538,8 @@ async function configurePreviewServer(params) {
525
538
  const code = core.buildSwScript({
526
539
  routes: state.swRoutes,
527
540
  root,
528
- basePaths: swConfig?.basePaths ?? []
541
+ basePaths: swConfig?.basePaths ?? [],
542
+ moduleVersion: state.swModuleVersion
529
543
  });
530
544
  res.statusCode = 200;
531
545
  res.setHeader("Content-Type", "application/javascript; charset=utf-8");
@@ -539,9 +553,6 @@ async function configurePreviewServer(params) {
539
553
  }
540
554
  });
541
555
  }
542
- if (enableViteMiddleware && state.serverRoutes.length > 0) {
543
- server.middlewares.use(core.createMiddleware(() => state.app, logger));
544
- }
545
556
  if (!watchEnabled) {
546
557
  return null;
547
558
  }
@@ -602,12 +613,11 @@ function buildSwLifecycleScript(params) {
602
613
  importPath,
603
614
  swConfig,
604
615
  unregisterConfig,
605
- hasSwEntries,
606
616
  hasSwRoutes,
607
617
  resolveRequestPath,
608
618
  resolveRegisterScope
609
619
  } = params;
610
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
620
+ const shouldUnregister = unregisterConfig.unregister === true;
611
621
  if (shouldUnregister) {
612
622
  const path2 = resolveRequestPath(unregisterConfig.path);
613
623
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -642,12 +652,11 @@ function buildSwLifecycleInlineScript(params) {
642
652
  const {
643
653
  swConfig,
644
654
  unregisterConfig,
645
- hasSwEntries,
646
655
  hasSwRoutes,
647
656
  resolveRequestPath,
648
657
  resolveRegisterScope
649
658
  } = params;
650
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
659
+ const shouldUnregister = unregisterConfig.unregister === true;
651
660
  if (shouldUnregister) {
652
661
  const path2 = resolveRequestPath(unregisterConfig.path);
653
662
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -743,19 +752,20 @@ function createMokupPlugin(options = {}) {
743
752
  configFiles: [],
744
753
  disabledConfigFiles: [],
745
754
  app: null,
746
- lastSignature: null
755
+ lastSignature: null,
756
+ swModuleVersion: 0
747
757
  };
748
758
  let previewWatcher = null;
749
759
  let currentServer = null;
750
760
  const normalizedOptions = normalizeMokupOptions(options);
751
- const runtime = normalizedOptions.runtime ?? "vite";
761
+ const runtime = normalizedOptions.runtime ?? "node";
752
762
  const enableViteMiddleware = runtime !== "worker";
753
763
  const optionList = normalizeOptions(normalizedOptions);
754
764
  const logEnabled = optionList.every((entry) => entry.log !== false);
755
765
  const watchEnabled = optionList.every((entry) => entry.watch !== false);
756
766
  const playgroundConfig = core.resolvePlaygroundOptions(normalizedOptions.playground);
757
767
  const logger = core.createLogger(logEnabled);
758
- const hasSwEntries = optionList.some((entry) => entry.mode === "sw");
768
+ optionList.some((entry) => entry.mode === "sw");
759
769
  const swConfig = core.resolveSwConfig(optionList, logger);
760
770
  const unregisterConfig = core.resolveSwUnregisterConfig(optionList, logger);
761
771
  const resolveAllDirs = createDirResolver(optionList, () => root);
@@ -787,7 +797,6 @@ function createMokupPlugin(options = {}) {
787
797
  importPath: resolveSwImportPath(base),
788
798
  swConfig,
789
799
  unregisterConfig,
790
- hasSwEntries,
791
800
  hasSwRoutes: hasSwRoutes(),
792
801
  resolveRequestPath: resolveSwRequestPath,
793
802
  resolveRegisterScope: resolveSwRegisterScope
@@ -855,7 +864,6 @@ function createMokupPlugin(options = {}) {
855
864
  importPath,
856
865
  swConfig,
857
866
  unregisterConfig,
858
- hasSwEntries,
859
867
  hasSwRoutes: hasSwRoutes(),
860
868
  resolveRequestPath: resolveSwRequestPath,
861
869
  resolveRegisterScope: resolveSwRegisterScope
@@ -869,7 +877,8 @@ function createMokupPlugin(options = {}) {
869
877
  return core.buildSwScript({
870
878
  routes: state.swRoutes,
871
879
  root,
872
- basePaths: swConfig?.basePaths ?? []
880
+ basePaths: swConfig?.basePaths ?? [],
881
+ moduleVersion: state.swModuleVersion
873
882
  });
874
883
  },
875
884
  async buildStart() {
@@ -881,7 +890,6 @@ function createMokupPlugin(options = {}) {
881
890
  importPath: "mokup/sw",
882
891
  swConfig,
883
892
  unregisterConfig,
884
- hasSwEntries,
885
893
  hasSwRoutes: hasSwRoutes(),
886
894
  resolveRequestPath: resolveSwRequestPath,
887
895
  resolveRegisterScope: resolveSwRegisterScope
@@ -915,7 +923,6 @@ function createMokupPlugin(options = {}) {
915
923
  importPath: command === "build" ? "mokup/sw" : resolveSwImportPath(base),
916
924
  swConfig,
917
925
  unregisterConfig,
918
- hasSwEntries,
919
926
  hasSwRoutes: hasSwRoutes(),
920
927
  resolveRequestPath: resolveSwRequestPath,
921
928
  resolveRegisterScope: resolveSwRegisterScope
@@ -1007,7 +1014,6 @@ function createMokupPlugin(options = {}) {
1007
1014
  const swScript = buildSwLifecycleInlineScript({
1008
1015
  swConfig,
1009
1016
  unregisterConfig,
1010
- hasSwEntries,
1011
1017
  hasSwRoutes: hasSwRoutes(),
1012
1018
  resolveRequestPath: resolveSwRequestPath,
1013
1019
  resolveRegisterScope: resolveSwRegisterScope
package/dist/vite.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MokupPluginOptions } from '@mokup/core';
2
- export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
2
+ export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, RuntimeTarget, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
3
3
  import { Plugin } from 'vite';
4
4
 
5
5
  /**
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MokupPluginOptions } from '@mokup/core';
2
- export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
2
+ export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, RuntimeTarget, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
3
3
  import { Plugin } from 'vite';
4
4
 
5
5
  /**
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./types/virtual.d.ts" />
2
2
 
3
3
  import { MokupPluginOptions } from '@mokup/core';
4
- export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
4
+ export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, RuntimeTarget, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
5
5
  import { Plugin } from 'vite';
6
6
 
7
7
  /**
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cwd } from 'node:process';
2
- import { resolveDirs, scanRoutes, sortRoutes, createHonoApp, formatOutputLine, stripAnsi, createDebouncer, isInDirs, buildSwScript, createMiddleware, resolvePlaygroundOptions, createLogger, resolveSwConfig, resolveSwUnregisterConfig, createPlaygroundMiddleware, buildBundleModule, writePlaygroundBuild } from '@mokup/core';
2
+ import { resolveDirs, scanRoutes, sortRoutes, createHonoApp, formatOutputLine, stripAnsi, createDebouncer, isInDirs, createMiddleware, buildSwScript, resolvePlaygroundOptions, createLogger, resolveSwConfig, resolveSwUnregisterConfig, createPlaygroundMiddleware, buildBundleModule, writePlaygroundBuild } from '@mokup/core';
3
3
  import { r as resolvePlaygroundDist } from './shared/mokup.BZpTBIrj.mjs';
4
4
  import pc from 'picocolors';
5
5
  import { isAbsolute, resolve, dirname } from 'node:path';
@@ -38,6 +38,11 @@ function normalizeMokupOptions(options) {
38
38
  "[mokup] Invalid config: use mokup({ entries: { ... } }) instead of mokup({ dir, prefix, ... })."
39
39
  );
40
40
  }
41
+ if (options.runtime === "vite") {
42
+ throw new Error(
43
+ '[mokup] Invalid config: runtime "vite" is no longer supported. Use "node" or "worker".'
44
+ );
45
+ }
41
46
  return options;
42
47
  }
43
48
  function normalizeOptions(options) {
@@ -206,8 +211,12 @@ function createRouteRefresher(params) {
206
211
  state.configFiles,
207
212
  state.disabledConfigFiles
208
213
  );
214
+ const changed = signature !== state.lastSignature || options?.force;
215
+ if (changed && state.swRoutes.length > 0) {
216
+ state.swModuleVersion = (state.swModuleVersion ?? 0) + 1;
217
+ }
209
218
  if (isViteDevServer(server) && server.ws) {
210
- const shouldNotify = !options?.silent && state.lastSignature && (signature !== state.lastSignature || options?.force);
219
+ const shouldNotify = !options?.silent && state.lastSignature && changed;
211
220
  if (shouldNotify) {
212
221
  server.ws.send({
213
222
  type: "custom",
@@ -441,6 +450,9 @@ async function configureDevServer(params) {
441
450
  watchEnabled
442
451
  } = params;
443
452
  await refreshRoutes(server);
453
+ if (enableViteMiddleware && state.serverRoutes.length > 0) {
454
+ addMiddlewareFirst(server, createMiddleware(() => state.app, logger));
455
+ }
444
456
  addMiddlewareFirst(server, playgroundMiddleware);
445
457
  if (playgroundConfig.enabled) {
446
458
  const playgroundPath = resolveRegisterPath(base, playgroundConfig.path);
@@ -460,7 +472,8 @@ async function configureDevServer(params) {
460
472
  root,
461
473
  runtimeImportPath: resolveSwRuntimeImportPath(base),
462
474
  loggerImportPath: resolveSwLoggerImportPath(base),
463
- basePaths: swConfig?.basePaths ?? []
475
+ basePaths: swConfig?.basePaths ?? [],
476
+ moduleVersion: state.swModuleVersion
464
477
  });
465
478
  res.statusCode = 200;
466
479
  res.setHeader("Content-Type", "application/javascript; charset=utf-8");
@@ -474,9 +487,6 @@ async function configureDevServer(params) {
474
487
  }
475
488
  });
476
489
  }
477
- if (enableViteMiddleware && state.serverRoutes.length > 0) {
478
- server.middlewares.use(createMiddleware(() => state.app, logger));
479
- }
480
490
  if (!watchEnabled) {
481
491
  return;
482
492
  }
@@ -504,6 +514,9 @@ async function configurePreviewServer(params) {
504
514
  watchEnabled
505
515
  } = params;
506
516
  await refreshRoutes(server);
517
+ if (enableViteMiddleware && state.serverRoutes.length > 0) {
518
+ addMiddlewareFirst(server, createMiddleware(() => state.app, logger));
519
+ }
507
520
  addMiddlewareFirst(server, playgroundMiddleware);
508
521
  const swPath = swConfig ? resolveRegisterPath(base, swConfig.path) : null;
509
522
  if (swPath && hasSwRoutes()) {
@@ -517,7 +530,8 @@ async function configurePreviewServer(params) {
517
530
  const code = buildSwScript({
518
531
  routes: state.swRoutes,
519
532
  root,
520
- basePaths: swConfig?.basePaths ?? []
533
+ basePaths: swConfig?.basePaths ?? [],
534
+ moduleVersion: state.swModuleVersion
521
535
  });
522
536
  res.statusCode = 200;
523
537
  res.setHeader("Content-Type", "application/javascript; charset=utf-8");
@@ -531,9 +545,6 @@ async function configurePreviewServer(params) {
531
545
  }
532
546
  });
533
547
  }
534
- if (enableViteMiddleware && state.serverRoutes.length > 0) {
535
- server.middlewares.use(createMiddleware(() => state.app, logger));
536
- }
537
548
  if (!watchEnabled) {
538
549
  return null;
539
550
  }
@@ -594,12 +605,11 @@ function buildSwLifecycleScript(params) {
594
605
  importPath,
595
606
  swConfig,
596
607
  unregisterConfig,
597
- hasSwEntries,
598
608
  hasSwRoutes,
599
609
  resolveRequestPath,
600
610
  resolveRegisterScope
601
611
  } = params;
602
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
612
+ const shouldUnregister = unregisterConfig.unregister === true;
603
613
  if (shouldUnregister) {
604
614
  const path2 = resolveRequestPath(unregisterConfig.path);
605
615
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -634,12 +644,11 @@ function buildSwLifecycleInlineScript(params) {
634
644
  const {
635
645
  swConfig,
636
646
  unregisterConfig,
637
- hasSwEntries,
638
647
  hasSwRoutes,
639
648
  resolveRequestPath,
640
649
  resolveRegisterScope
641
650
  } = params;
642
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
651
+ const shouldUnregister = unregisterConfig.unregister === true;
643
652
  if (shouldUnregister) {
644
653
  const path2 = resolveRequestPath(unregisterConfig.path);
645
654
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -735,19 +744,20 @@ function createMokupPlugin(options = {}) {
735
744
  configFiles: [],
736
745
  disabledConfigFiles: [],
737
746
  app: null,
738
- lastSignature: null
747
+ lastSignature: null,
748
+ swModuleVersion: 0
739
749
  };
740
750
  let previewWatcher = null;
741
751
  let currentServer = null;
742
752
  const normalizedOptions = normalizeMokupOptions(options);
743
- const runtime = normalizedOptions.runtime ?? "vite";
753
+ const runtime = normalizedOptions.runtime ?? "node";
744
754
  const enableViteMiddleware = runtime !== "worker";
745
755
  const optionList = normalizeOptions(normalizedOptions);
746
756
  const logEnabled = optionList.every((entry) => entry.log !== false);
747
757
  const watchEnabled = optionList.every((entry) => entry.watch !== false);
748
758
  const playgroundConfig = resolvePlaygroundOptions(normalizedOptions.playground);
749
759
  const logger = createLogger(logEnabled);
750
- const hasSwEntries = optionList.some((entry) => entry.mode === "sw");
760
+ optionList.some((entry) => entry.mode === "sw");
751
761
  const swConfig = resolveSwConfig(optionList, logger);
752
762
  const unregisterConfig = resolveSwUnregisterConfig(optionList, logger);
753
763
  const resolveAllDirs = createDirResolver(optionList, () => root);
@@ -779,7 +789,6 @@ function createMokupPlugin(options = {}) {
779
789
  importPath: resolveSwImportPath(base),
780
790
  swConfig,
781
791
  unregisterConfig,
782
- hasSwEntries,
783
792
  hasSwRoutes: hasSwRoutes(),
784
793
  resolveRequestPath: resolveSwRequestPath,
785
794
  resolveRegisterScope: resolveSwRegisterScope
@@ -847,7 +856,6 @@ function createMokupPlugin(options = {}) {
847
856
  importPath,
848
857
  swConfig,
849
858
  unregisterConfig,
850
- hasSwEntries,
851
859
  hasSwRoutes: hasSwRoutes(),
852
860
  resolveRequestPath: resolveSwRequestPath,
853
861
  resolveRegisterScope: resolveSwRegisterScope
@@ -861,7 +869,8 @@ function createMokupPlugin(options = {}) {
861
869
  return buildSwScript({
862
870
  routes: state.swRoutes,
863
871
  root,
864
- basePaths: swConfig?.basePaths ?? []
872
+ basePaths: swConfig?.basePaths ?? [],
873
+ moduleVersion: state.swModuleVersion
865
874
  });
866
875
  },
867
876
  async buildStart() {
@@ -873,7 +882,6 @@ function createMokupPlugin(options = {}) {
873
882
  importPath: "mokup/sw",
874
883
  swConfig,
875
884
  unregisterConfig,
876
- hasSwEntries,
877
885
  hasSwRoutes: hasSwRoutes(),
878
886
  resolveRequestPath: resolveSwRequestPath,
879
887
  resolveRegisterScope: resolveSwRegisterScope
@@ -907,7 +915,6 @@ function createMokupPlugin(options = {}) {
907
915
  importPath: command === "build" ? "mokup/sw" : resolveSwImportPath(base),
908
916
  swConfig,
909
917
  unregisterConfig,
910
- hasSwEntries,
911
918
  hasSwRoutes: hasSwRoutes(),
912
919
  resolveRequestPath: resolveSwRequestPath,
913
920
  resolveRegisterScope: resolveSwRegisterScope
@@ -999,7 +1006,6 @@ function createMokupPlugin(options = {}) {
999
1006
  const swScript = buildSwLifecycleInlineScript({
1000
1007
  swConfig,
1001
1008
  unregisterConfig,
1002
- hasSwEntries,
1003
1009
  hasSwRoutes: hasSwRoutes(),
1004
1010
  resolveRequestPath: resolveSwRequestPath,
1005
1011
  resolveRegisterScope: resolveSwRegisterScope
package/dist/webpack.cjs CHANGED
@@ -36,12 +36,11 @@ function buildSwLifecycleScript(params) {
36
36
  importPath,
37
37
  swConfig,
38
38
  unregisterConfig,
39
- hasSwEntries,
40
39
  hasSwRoutes,
41
40
  resolveRequestPath,
42
41
  resolveRegisterScope
43
42
  } = params;
44
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
43
+ const shouldUnregister = unregisterConfig.unregister === true;
45
44
  if (shouldUnregister) {
46
45
  const path2 = resolveRequestPath(unregisterConfig.path);
47
46
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -80,7 +79,6 @@ function createBundleBuilder(params) {
80
79
  root,
81
80
  swConfig,
82
81
  unregisterConfig,
83
- hasSwEntries,
84
82
  hasSwRoutes,
85
83
  resolveRequestPath,
86
84
  resolveRegisterScope,
@@ -94,7 +92,6 @@ function createBundleBuilder(params) {
94
92
  importPath: "mokup/sw",
95
93
  swConfig,
96
94
  unregisterConfig,
97
- hasSwEntries,
98
95
  hasSwRoutes: hasSwRoutes(),
99
96
  resolveRequestPath,
100
97
  resolveRegisterScope
@@ -342,7 +339,7 @@ function createMokupWebpackPlugin(options = {}) {
342
339
  const watchEnabled = optionList.every((entry) => entry.watch !== false);
343
340
  const playgroundConfig = core.resolvePlaygroundOptions(normalizedOptions.playground);
344
341
  const logger = core.createLogger(logEnabled);
345
- const hasSwEntries = optionList.some((entry) => entry.mode === "sw");
342
+ optionList.some((entry) => entry.mode === "sw");
346
343
  const swConfig = core.resolveSwConfig(optionList, logger);
347
344
  const unregisterConfig = core.resolveSwUnregisterConfig(optionList, logger);
348
345
  let root = process.cwd();
@@ -393,7 +390,6 @@ function createMokupWebpackPlugin(options = {}) {
393
390
  root: () => root,
394
391
  swConfig,
395
392
  unregisterConfig,
396
- hasSwEntries,
397
393
  hasSwRoutes,
398
394
  resolveRequestPath: (path) => resolveRegisterPath(base, path),
399
395
  resolveRegisterScope: (scope) => resolveRegisterScope(base, scope),
@@ -116,7 +116,9 @@ type WebpackPluginOptions = MokupPluginOptions;
116
116
  */
117
117
  type WebpackPluginOptionsInput = MokupPluginOptions;
118
118
 
119
- type WebpackConfig = Configuration;
119
+ type WebpackConfig = Configuration & {
120
+ devServer?: Record<string, unknown>;
121
+ };
120
122
  type WebpackConfigFactory = (...args: unknown[]) => WebpackConfig | WebpackConfig[] | Promise<WebpackConfig | WebpackConfig[]>;
121
123
  type WebpackConfigInput = WebpackConfig | WebpackConfig[] | WebpackConfigFactory;
122
124
  type WithMokup<T> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<WithMokup<Awaited<R>>> : T extends Array<infer U> ? Array<WithMokup<U>> : T extends WebpackConfig ? T : WebpackConfig;
@@ -116,7 +116,9 @@ type WebpackPluginOptions = MokupPluginOptions;
116
116
  */
117
117
  type WebpackPluginOptionsInput = MokupPluginOptions;
118
118
 
119
- type WebpackConfig = Configuration;
119
+ type WebpackConfig = Configuration & {
120
+ devServer?: Record<string, unknown>;
121
+ };
120
122
  type WebpackConfigFactory = (...args: unknown[]) => WebpackConfig | WebpackConfig[] | Promise<WebpackConfig | WebpackConfig[]>;
121
123
  type WebpackConfigInput = WebpackConfig | WebpackConfig[] | WebpackConfigFactory;
122
124
  type WithMokup<T> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<WithMokup<Awaited<R>>> : T extends Array<infer U> ? Array<WithMokup<U>> : T extends WebpackConfig ? T : WebpackConfig;
package/dist/webpack.d.ts CHANGED
@@ -116,7 +116,9 @@ type WebpackPluginOptions = MokupPluginOptions;
116
116
  */
117
117
  type WebpackPluginOptionsInput = MokupPluginOptions;
118
118
 
119
- type WebpackConfig = Configuration;
119
+ type WebpackConfig = Configuration & {
120
+ devServer?: Record<string, unknown>;
121
+ };
120
122
  type WebpackConfigFactory = (...args: unknown[]) => WebpackConfig | WebpackConfig[] | Promise<WebpackConfig | WebpackConfig[]>;
121
123
  type WebpackConfigInput = WebpackConfig | WebpackConfig[] | WebpackConfigFactory;
122
124
  type WithMokup<T> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<WithMokup<Awaited<R>>> : T extends Array<infer U> ? Array<WithMokup<U>> : T extends WebpackConfig ? T : WebpackConfig;
package/dist/webpack.mjs CHANGED
@@ -29,12 +29,11 @@ function buildSwLifecycleScript(params) {
29
29
  importPath,
30
30
  swConfig,
31
31
  unregisterConfig,
32
- hasSwEntries,
33
32
  hasSwRoutes,
34
33
  resolveRequestPath,
35
34
  resolveRegisterScope
36
35
  } = params;
37
- const shouldUnregister = unregisterConfig.unregister === true || !hasSwEntries;
36
+ const shouldUnregister = unregisterConfig.unregister === true;
38
37
  if (shouldUnregister) {
39
38
  const path2 = resolveRequestPath(unregisterConfig.path);
40
39
  const scope2 = resolveRegisterScope(unregisterConfig.scope);
@@ -73,7 +72,6 @@ function createBundleBuilder(params) {
73
72
  root,
74
73
  swConfig,
75
74
  unregisterConfig,
76
- hasSwEntries,
77
75
  hasSwRoutes,
78
76
  resolveRequestPath,
79
77
  resolveRegisterScope,
@@ -87,7 +85,6 @@ function createBundleBuilder(params) {
87
85
  importPath: "mokup/sw",
88
86
  swConfig,
89
87
  unregisterConfig,
90
- hasSwEntries,
91
88
  hasSwRoutes: hasSwRoutes(),
92
89
  resolveRequestPath,
93
90
  resolveRegisterScope
@@ -335,7 +332,7 @@ function createMokupWebpackPlugin(options = {}) {
335
332
  const watchEnabled = optionList.every((entry) => entry.watch !== false);
336
333
  const playgroundConfig = resolvePlaygroundOptions(normalizedOptions.playground);
337
334
  const logger = createLogger(logEnabled);
338
- const hasSwEntries = optionList.some((entry) => entry.mode === "sw");
335
+ optionList.some((entry) => entry.mode === "sw");
339
336
  const swConfig = resolveSwConfig(optionList, logger);
340
337
  const unregisterConfig = resolveSwUnregisterConfig(optionList, logger);
341
338
  let root = cwd();
@@ -386,7 +383,6 @@ function createMokupWebpackPlugin(options = {}) {
386
383
  root: () => root,
387
384
  swConfig,
388
385
  unregisterConfig,
389
- hasSwEntries,
390
386
  hasSwRoutes,
391
387
  resolveRequestPath: (path) => resolveRegisterPath(base, path),
392
388
  resolveRegisterScope: (scope) => resolveRegisterScope(base, scope),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mokup",
3
3
  "type": "module",
4
- "version": "2.3.2",
4
+ "version": "2.3.5",
5
5
  "description": "Mock utilities and Vite plugin for mokup.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://mokup.icebreaker.top",
@@ -164,12 +164,12 @@
164
164
  },
165
165
  "dependencies": {
166
166
  "picocolors": "^1.1.1",
167
- "@mokup/cli": "1.1.2",
168
- "@mokup/core": "1.1.1",
169
- "@mokup/playground": "0.1.1",
170
- "@mokup/runtime": "1.0.8",
171
- "@mokup/server": "1.2.2",
172
- "@mokup/shared": "1.1.3"
167
+ "@mokup/cli": "1.1.4",
168
+ "@mokup/core": "1.1.3",
169
+ "@mokup/playground": "0.2.1",
170
+ "@mokup/runtime": "1.0.9",
171
+ "@mokup/server": "1.2.4",
172
+ "@mokup/shared": "1.1.4"
173
173
  },
174
174
  "scripts": {
175
175
  "build": "unbuild",