@thi.ng/expose 1.2.7 → 1.2.9

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/index.js +8 -27
  3. package/package.json +7 -4
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-09T19:12:03Z
3
+ - **Last updated**: 2023-12-18T13:41:19Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/index.js CHANGED
@@ -1,28 +1,9 @@
1
- /**
2
- * Exposes given `value` as `id` in global scope, iff `always = true` (default:
3
- * false) or if `process.env.NODE_ENV != "production"` or if the
4
- * `UMBRELLA_GLOBALS` or `VITE_UMBRELLA_GLOBALS` env var is set to 1.
5
- *
6
- * @param id -
7
- * @param value -
8
- * @param always -
9
- */
10
- export const exposeGlobal = (id, value, always = false) => {
11
- const glob = typeof global !== "undefined"
12
- ? global
13
- : typeof window !== "undefined"
14
- ? window
15
- : undefined;
16
- if (glob &&
17
- (always ||
18
- (typeof process !== "undefined" && process.env !== undefined
19
- ? process.env.NODE_ENV !== "production" ||
20
- !!process.env.UMBRELLA_GLOBALS
21
- : import.meta.env
22
- ? import.meta.env.MODE !== "production" ||
23
- !!import.meta.env.UMBRELLA_GLOBALS ||
24
- !!import.meta.env.VITE_UMBRELLA_GLOBALS
25
- : true))) {
26
- glob[id] = value;
27
- }
1
+ const exposeGlobal = (id, value, always = false) => {
2
+ const glob = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : void 0;
3
+ if (glob && (always || (typeof process !== "undefined" && process.env !== void 0 ? process.env.NODE_ENV !== "production" || !!process.env.UMBRELLA_GLOBALS : import.meta.env ? import.meta.env.MODE !== "production" || !!import.meta.env.UMBRELLA_GLOBALS || !!import.meta.env.VITE_UMBRELLA_GLOBALS : true))) {
4
+ glob[id] = value;
5
+ }
6
+ };
7
+ export {
8
+ exposeGlobal
28
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/expose",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "Conditional global variable exposition",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -24,7 +24,9 @@
24
24
  "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && tsc --declaration",
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
28
30
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
29
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -35,6 +37,7 @@
35
37
  "devDependencies": {
36
38
  "@microsoft/api-extractor": "^7.38.3",
37
39
  "@types/node": "^20.10.2",
40
+ "esbuild": "^0.19.8",
38
41
  "rimraf": "^5.0.5",
39
42
  "tools": "^0.0.1",
40
43
  "typedoc": "^0.25.4",
@@ -54,7 +57,7 @@
54
57
  "setTimeout": false
55
58
  },
56
59
  "engines": {
57
- "node": ">=12.7"
60
+ "node": ">=18"
58
61
  },
59
62
  "files": [
60
63
  "./*.js",
@@ -66,5 +69,5 @@
66
69
  }
67
70
  },
68
71
  "thi.ng": {},
69
- "gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
72
+ "gitHead": "25a42a81fac8603a1e440a7aa8bc343276211ff4\n"
70
73
  }