@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.
- package/dist/{chunk-CUXQPZR7.js → chunk-VDS3W3XK.js} +24 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/rollup.js +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -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] ===
|
|
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
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
package/dist/rollup.js
CHANGED
package/dist/vite.js
CHANGED
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@variant-forge/unplugin",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
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
|
".": {
|