From 76ae89d97b5778e8a91071a1e4e0e9e03079a86e Mon Sep 17 00:00:00 2001 From: sushichan044 <71284054+sushichan044@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:19:34 +0900 Subject: [PATCH 1/2] docs: use declare module --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 55debed..ca1a0a8 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ A feature flag plugin for Vite. ## How to use -1. Install the plugin. +1. Install the plugin. ```bash pnpm add -D @virtual-live-lab/vite-plugin-feature-flags ``` -2. Add this plugin to `vite.config.ts`. +2. Add this plugin to `vite.config.ts`. ```ts import { defineConfig } from "vite"; @@ -29,18 +29,20 @@ A feature flag plugin for Vite. }); ``` -3. Add type declaration for feature flags. +3. Add type declaration for feature flags. ```ts - /// - - interface ImportMetaFeatures { - hoge: boolean; - fuga: boolean; + declare module "@virtual-live-lab/vite-plugin-feature-flags/client" { + interface ImportMetaFeatures { + hoge: boolean; + fuga: boolean; + } } + + export {}; // Declaration merging is only available in modules. ``` -4. Use feature flags in your code. +4. Use feature flags in your code. ```ts if (import.meta.features.hoge) { From 558ede6ab41ebbd1eae83c6a9729dbbb873a3da2 Mon Sep 17 00:00:00 2001 From: sushichan044 <71284054+sushichan044@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:21:05 +0900 Subject: [PATCH 2/2] tidy --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index ca1a0a8..ec61449 100644 --- a/README.md +++ b/README.md @@ -8,44 +8,44 @@ A feature flag plugin for Vite. 1. Install the plugin. - ```bash - pnpm add -D @virtual-live-lab/vite-plugin-feature-flags - ``` + ```bash + pnpm add -D @virtual-live-lab/vite-plugin-feature-flags + ``` 2. Add this plugin to `vite.config.ts`. - ```ts - import { defineConfig } from "vite"; - import { featuresPlugin } from "vite-plugin-feature-flags"; - - export default defineConfig({ - plugins: [ - featuresPlugin({ - // your feature flags - hoge: true, - fuga: false, - }), - ], - }); - ``` + ```ts + import { defineConfig } from "vite"; + import { featuresPlugin } from "vite-plugin-feature-flags"; + + export default defineConfig({ + plugins: [ + featuresPlugin({ + // your feature flags + hoge: true, + fuga: false, + }), + ], + }); + ``` 3. Add type declaration for feature flags. - ```ts - declare module "@virtual-live-lab/vite-plugin-feature-flags/client" { - interface ImportMetaFeatures { - hoge: boolean; - fuga: boolean; - } - } + ```ts + declare module "@virtual-live-lab/vite-plugin-feature-flags/client" { + interface ImportMetaFeatures { + hoge: boolean; + fuga: boolean; + } + } - export {}; // Declaration merging is only available in modules. - ``` + export {}; // Declaration merging is only available in modules. + ``` 4. Use feature flags in your code. - ```ts - if (import.meta.features.hoge) { - console.log("hoge is enabled"); - } - ``` + ```ts + if (import.meta.features.hoge) { + console.log("hoge is enabled"); + } + ```