@granite-js/plugin-env 0.1.30 → 0.1.32

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @granite-js/plugin-env
2
2
 
3
+ ## 0.1.32
4
+
5
+ ### Patch Changes
6
+
7
+ - 7572713: bump version up babel
8
+ - Updated dependencies [7572713]
9
+ - @granite-js/plugin-core@0.1.32
10
+ - @granite-js/utils@0.1.32
11
+
12
+ ## 0.1.31
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [9bf8b50]
17
+ - Updated dependencies [e957833]
18
+ - @granite-js/plugin-core@0.1.31
19
+ - @granite-js/utils@0.1.31
20
+
3
21
  ## 0.1.30
4
22
 
5
23
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -21,10 +21,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const crypto = __toESM(require("crypto"));
25
- const fs = __toESM(require("fs"));
26
- const path = __toESM(require("path"));
27
- const __granite_js_utils = __toESM(require("@granite-js/utils"));
24
+ let crypto = require("crypto");
25
+ crypto = __toESM(crypto);
26
+ let fs = require("fs");
27
+ fs = __toESM(fs);
28
+ let path = require("path");
29
+ let __granite_js_utils = require("@granite-js/utils");
28
30
 
29
31
  //#region src/generateEnvType.ts
30
32
  const DEF_PLACEHOLDER = "$$__DEF";
@@ -42,13 +44,11 @@ function getEnvDefinitionScript(environments) {
42
44
  const defs = Object.keys(environments).map((envName) => {
43
45
  return ` ${envName}: string;`;
44
46
  }).join("\n");
45
- const script = ENV_TYPE_TEMPLATE.replace(DEF_PLACEHOLDER, defs);
46
- return script + "\n";
47
+ return ENV_TYPE_TEMPLATE.replace(DEF_PLACEHOLDER, defs) + "\n";
47
48
  }
48
49
  function generateEnvTypeImpl(rootPath, environments) {
49
50
  const sourcePath = (0, path.join)(rootPath, "src");
50
- const stat = fs.default.statSync(sourcePath);
51
- if (!stat.isDirectory()) {
51
+ if (!fs.default.statSync(sourcePath).isDirectory()) {
52
52
  console.warn("Failed to generate env type. <rootDir>/src directory not found.");
53
53
  return;
54
54
  }
@@ -59,13 +59,12 @@ const generateEnvType = (0, __granite_js_utils.ensureSafetyInvokeSync)(generateE
59
59
  //#endregion
60
60
  //#region src/getRuntimeEnvScript.ts
61
61
  function getRuntimeEnvScript(serializableObject) {
62
- const assignExpressions = Object.entries(serializableObject).map(([key, value]) => `global.__granite.meta.env['${key}'] = ${JSON.stringify(String(value))};`);
63
62
  return `
64
63
  (function (global) {
65
64
  global.__granite = global.__granite || {};
66
65
  global.__granite.meta = global.__granite.meta || {};
67
66
  global.__granite.meta.env = global.__granite.meta.env || {};
68
- ${assignExpressions.join("\n")}
67
+ ${Object.entries(serializableObject).map(([key, value]) => `global.__granite.meta.env['${key}'] = ${JSON.stringify(String(value))};`).join("\n")}
69
68
  })(
70
69
  typeof globalThis !== 'undefined'
71
70
  ? globalThis
@@ -89,8 +88,7 @@ const envPlugin = (environments, options) => {
89
88
  const packageRoot = (0, __granite_js_utils.getPackageRoot)();
90
89
  const script = getRuntimeEnvScript(environments);
91
90
  const hash = crypto.default.createHash("sha256").update(script).digest("hex").slice(0, 8);
92
- const localDir = (0, __granite_js_utils.prepareLocalDirectory)(packageRoot);
93
- const envFilePath = (0, path.join)(localDir, `.granite-${hash}.env.js`);
91
+ const envFilePath = (0, path.join)((0, __granite_js_utils.prepareLocalDirectory)(packageRoot), `.granite-${hash}.env.js`);
94
92
  const setup = () => {
95
93
  fs.default.writeFileSync(envFilePath, script, "utf-8");
96
94
  if (completeOptions.dts) generateEnvType(packageRoot, environments);
package/dist/index.d.cts CHANGED
@@ -4,7 +4,6 @@ import { GranitePluginCore } from "@granite-js/plugin-core";
4
4
  interface SerializableObject {
5
5
  [key: string]: string | number | boolean | null | undefined | SerializableObject;
6
6
  }
7
-
8
7
  //#endregion
9
8
  //#region src/envPlugin.d.ts
10
9
  interface EnvPluginOptions {
@@ -16,6 +15,5 @@ interface EnvPluginOptions {
16
15
  dts?: boolean;
17
16
  }
18
17
  declare const envPlugin: (environments: SerializableObject, options?: EnvPluginOptions) => GranitePluginCore;
19
-
20
18
  //#endregion
21
19
  export { envPlugin as env };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ import { GranitePluginCore } from "@granite-js/plugin-core";
4
4
  interface SerializableObject {
5
5
  [key: string]: string | number | boolean | null | undefined | SerializableObject;
6
6
  }
7
-
8
7
  //#endregion
9
8
  //#region src/envPlugin.d.ts
10
9
  interface EnvPluginOptions {
@@ -16,6 +15,5 @@ interface EnvPluginOptions {
16
15
  dts?: boolean;
17
16
  }
18
17
  declare const envPlugin: (environments: SerializableObject, options?: EnvPluginOptions) => GranitePluginCore;
19
-
20
18
  //#endregion
21
19
  export { envPlugin as env };
package/dist/index.js CHANGED
@@ -24,13 +24,11 @@ function getEnvDefinitionScript(environments) {
24
24
  const defs = Object.keys(environments).map((envName) => {
25
25
  return ` ${envName}: string;`;
26
26
  }).join("\n");
27
- const script = ENV_TYPE_TEMPLATE.replace(DEF_PLACEHOLDER, defs);
28
- return script + "\n";
27
+ return ENV_TYPE_TEMPLATE.replace(DEF_PLACEHOLDER, defs) + "\n";
29
28
  }
30
29
  function generateEnvTypeImpl(rootPath, environments) {
31
30
  const sourcePath = join(rootPath, "src");
32
- const stat = fs.statSync(sourcePath);
33
- if (!stat.isDirectory()) {
31
+ if (!fs.statSync(sourcePath).isDirectory()) {
34
32
  console.warn("Failed to generate env type. <rootDir>/src directory not found.");
35
33
  return;
36
34
  }
@@ -41,13 +39,12 @@ const generateEnvType = ensureSafetyInvokeSync(generateEnvTypeImpl);
41
39
  //#endregion
42
40
  //#region src/getRuntimeEnvScript.ts
43
41
  function getRuntimeEnvScript(serializableObject) {
44
- const assignExpressions = Object.entries(serializableObject).map(([key, value]) => `global.__granite.meta.env['${key}'] = ${JSON.stringify(String(value))};`);
45
42
  return `
46
43
  (function (global) {
47
44
  global.__granite = global.__granite || {};
48
45
  global.__granite.meta = global.__granite.meta || {};
49
46
  global.__granite.meta.env = global.__granite.meta.env || {};
50
- ${assignExpressions.join("\n")}
47
+ ${Object.entries(serializableObject).map(([key, value]) => `global.__granite.meta.env['${key}'] = ${JSON.stringify(String(value))};`).join("\n")}
51
48
  })(
52
49
  typeof globalThis !== 'undefined'
53
50
  ? globalThis
@@ -71,8 +68,7 @@ const envPlugin = (environments, options) => {
71
68
  const packageRoot = getPackageRoot();
72
69
  const script = getRuntimeEnvScript(environments);
73
70
  const hash = crypto.createHash("sha256").update(script).digest("hex").slice(0, 8);
74
- const localDir = prepareLocalDirectory(packageRoot);
75
- const envFilePath = join(localDir, `.granite-${hash}.env.js`);
71
+ const envFilePath = join(prepareLocalDirectory(packageRoot), `.granite-${hash}.env.js`);
76
72
  const setup = () => {
77
73
  fs.writeFileSync(envFilePath, script, "utf-8");
78
74
  if (completeOptions.dts) generateEnvType(packageRoot, environments);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@granite-js/plugin-env",
3
3
  "type": "module",
4
- "version": "0.1.30",
4
+ "version": "0.1.32",
5
5
  "license": "Apache-2.0",
6
6
  "description": "An env plugin for Granite",
7
7
  "scripts": {
@@ -35,18 +35,18 @@
35
35
  "dist"
36
36
  ],
37
37
  "devDependencies": {
38
- "@babel/core": "7.23.9",
39
- "@babel/types": "7.23.9",
38
+ "@babel/core": "7.28.5",
39
+ "@babel/types": "7.28.5",
40
40
  "@types/babel__core": "^7.20.5",
41
41
  "@types/node": "^22.10.2",
42
- "@vitest/coverage-v8": "^3.1.3",
43
- "tsdown": "^0.11.12",
42
+ "@vitest/coverage-v8": "^4.0.12",
43
+ "tsdown": "^0.16.5",
44
44
  "typescript": "^5.6.3",
45
- "vitest": "^3.1.3"
45
+ "vitest": "^4.0.12"
46
46
  },
47
47
  "dependencies": {
48
- "@granite-js/plugin-core": "0.1.30",
49
- "@granite-js/utils": "0.1.30"
48
+ "@granite-js/plugin-core": "0.1.32",
49
+ "@granite-js/utils": "0.1.32"
50
50
  },
51
51
  "sideEffects": false
52
52
  }