twd-js 0.5.2 → 0.7.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.
package/README.md CHANGED
@@ -289,6 +289,25 @@ npx twd-js init <public-dir> [--save]
289
289
 
290
290
  This will copy `mock-sw.js` to your public directory.
291
291
 
292
+ **Removing the Service Worker in Production Builds**
293
+
294
+ The service worker file (`mock-sw.js`) is only needed during development for API mocking. To remove it from production builds, use the `removeMockServiceWorker` Vite plugin:
295
+
296
+ ```ts
297
+ // vite.config.ts
298
+ import { defineConfig } from 'vite';
299
+ import { removeMockServiceWorker } from 'twd-js';
300
+
301
+ export default defineConfig({
302
+ plugins: [
303
+ // ... other plugins
304
+ removeMockServiceWorker()
305
+ ]
306
+ });
307
+ ```
308
+
309
+ This plugin will automatically remove `mock-sw.js` from your build output during production builds.
310
+
292
311
  ### Mock Requests
293
312
 
294
313
  Use `twd.mockRequest()` to define API mocks in your tests:
@@ -0,0 +1,8 @@
1
+ // global.d.ts
2
+ export {};
3
+
4
+ declare global {
5
+ interface Window {
6
+ __testRunner?: TestRunner;
7
+ }
8
+ }