@variant-forge/unplugin 0.1.4 → 0.1.6

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.
@@ -19,7 +19,7 @@ var unplugin = createUnplugin((options) => {
19
19
  const context = options.context || {};
20
20
  for (const key of options.configs || []) {
21
21
  fetchedConfigs[key] = client.getConfig(key, context);
22
- if (fetchedConfigs[key] === void 0) {
22
+ if (fetchedConfigs[key] === null) {
23
23
  fetchedConfigs[key] = client.isFeatureEnabled(key, context);
24
24
  }
25
25
  }
@@ -49,6 +49,29 @@ var unplugin = createUnplugin((options) => {
49
49
  return code;
50
50
  }
51
51
  return null;
52
+ },
53
+ vite: {
54
+ config() {
55
+ if (!options.injectEnv) return;
56
+ const prefix = options.envPrefix ?? "VARIANT_";
57
+ const defines = {};
58
+ for (const [key, value] of Object.entries(fetchedConfigs)) {
59
+ defines[`import.meta.env.${prefix}${key}`] = JSON.stringify(value);
60
+ defines[`process.env.${prefix}${key}`] = JSON.stringify(value);
61
+ }
62
+ return { define: defines };
63
+ }
64
+ },
65
+ webpack(compiler) {
66
+ if (!options.injectEnv) return;
67
+ const prefix = options.envPrefix ?? "VARIANT_";
68
+ const defines = {};
69
+ for (const [key, value] of Object.entries(fetchedConfigs)) {
70
+ defines[`process.env.${prefix}${key}`] = JSON.stringify(value);
71
+ }
72
+ if (compiler.webpack && compiler.webpack.DefinePlugin) {
73
+ compiler.options.plugins.push(new compiler.webpack.DefinePlugin(defines));
74
+ }
52
75
  }
53
76
  };
54
77
  });
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin
3
- } from "./chunk-CUXQPZR7.js";
3
+ } from "./chunk-VDS3W3XK.js";
4
4
 
5
5
  // src/esbuild.ts
6
6
  var esbuild_default = unplugin.esbuild;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,15 @@ interface VariantUnpluginOptions {
14
14
  * Optional context for targeting evaluation.
15
15
  */
16
16
  context?: Record<string, string | number | boolean | null>;
17
+ /**
18
+ * If true, also injects the fetched configs as global environment variables.
19
+ * By default, variables are prefixed with 'VARIANT_' (e.g. process.env.VARIANT_FEATURE).
20
+ */
21
+ injectEnv?: boolean;
22
+ /**
23
+ * Prefix used for injected environment variables. Defaults to 'VARIANT_'.
24
+ */
25
+ envPrefix?: string;
17
26
  }
18
27
  declare const unplugin: unplugin$1.UnpluginInstance<VariantUnpluginOptions, boolean>;
19
28
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  index_default,
3
3
  unplugin
4
- } from "./chunk-CUXQPZR7.js";
4
+ } from "./chunk-VDS3W3XK.js";
5
5
  export {
6
6
  index_default as default,
7
7
  unplugin
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin
3
- } from "./chunk-CUXQPZR7.js";
3
+ } from "./chunk-VDS3W3XK.js";
4
4
 
5
5
  // src/rollup.ts
6
6
  var rollup_default = unplugin.rollup;
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin
3
- } from "./chunk-CUXQPZR7.js";
3
+ } from "./chunk-VDS3W3XK.js";
4
4
 
5
5
  // src/vite.ts
6
6
  var vite_default = unplugin.vite;
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin
3
- } from "./chunk-CUXQPZR7.js";
3
+ } from "./chunk-VDS3W3XK.js";
4
4
 
5
5
  // src/webpack.ts
6
6
  var webpack_default = unplugin.webpack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@variant-forge/unplugin",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "unplugin": "^3.4.0",
13
- "@variant-forge/sdk-node": "0.1.3"
13
+ "@variant-forge/sdk-node": "0.1.5"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/node": "^22.15.3",
@@ -21,10 +21,10 @@
21
21
  "@package/typescript-config": "0.0.0"
22
22
  },
23
23
  "scripts": {
24
- "build": "tsup src/index.ts src/vite.ts src/webpack.ts src/rollup.ts src/esbuild.ts --format esm --dts --clean",
24
+ "build": "tsup src/index.ts src/vite.ts src/webpack.ts src/rollup.ts src/esbuild.ts --format esm --dts-resolve --clean",
25
25
  "lint": "eslint . --max-warnings 0",
26
26
  "check-types": "tsc --noEmit",
27
- "release": "pnpm publish --access public"
27
+ "release": "pnpm run build && pnpm publish --access public"
28
28
  },
29
29
  "exports": {
30
30
  ".": {