@builder.io/react 2.0.8-4 → 2.0.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/react",
3
- "version": "2.0.8-3",
3
+ "version": "2.0.8",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/builder-react.cjs.js",
@@ -84,7 +84,7 @@
84
84
  "jest": "^28.1.3",
85
85
  "jest-environment-jsdom": "^28.1.3",
86
86
  "lint-staged": "^7.0.0",
87
- "prettier": "^1.4.4",
87
+ "prettier": "^2.6.2",
88
88
  "prompt": "^1.0.0",
89
89
  "react": ">=16.8.0",
90
90
  "react-dom": ">=16.8.0",
@@ -3,27 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.safeDynamicRequire = void 0;
4
4
  var sdk_1 = require("@builder.io/sdk");
5
5
  var noop = function () { return null; };
6
- // Allow us to require things dynamically safe from webpack bundling
7
- var localSafeDynamicRequire;
8
6
  /*
9
- * The if condition below used to be if (typeof globalThis.require === "function"
7
+ * The if condition below used to be
8
+ *
9
+ * if (typeof globalThis.require === "function")
10
+ *
10
11
  * That broke in case Builder was running on the server (Next, SSR use-cases) where
11
12
  * globalThis.require was undefined. Avoiding use of Builder.isServer for Cloudflare worker cases
12
- * That said, if we have change it to
13
+ * That said, if change it to
13
14
  *
14
15
  * if (typeof require === 'function') {
15
16
  * localSafeDynamicRequire = eval('require');
16
17
  * }
17
18
  *
18
- * Then the TSC compiler over-optimizes and replaces the if condition with true always
19
+ * Then the TSC / rollup compiler over-optimizes and replaces the if condition with true always
19
20
  * causing it to blow up on the client side. Hence this convoluted way of doing it.
21
+ *
22
+ * In Summary:
23
+ *
24
+ * 1. Node -> globalThis.require does not work
25
+ * 2. Client -> typeof require === 'function' does not work because of overoptimization by the compiler
26
+ * 3. Cloudflare edge -> only globalThis.require works
20
27
  */
21
- if (typeof globalThis.require === 'function') {
22
- localSafeDynamicRequire = eval('globalThis.require');
23
- }
24
- if (localSafeDynamicRequire === undefined && sdk_1.Builder.isServer) {
25
- localSafeDynamicRequire = eval('require');
28
+ if (typeof globalThis.require === 'function' || sdk_1.Builder.isServer) {
29
+ exports.safeDynamicRequire = eval('require');
26
30
  }
27
- localSafeDynamicRequire !== null && localSafeDynamicRequire !== void 0 ? localSafeDynamicRequire : (localSafeDynamicRequire = noop);
28
- exports.safeDynamicRequire = localSafeDynamicRequire;
31
+ exports.safeDynamicRequire !== null && exports.safeDynamicRequire !== void 0 ? exports.safeDynamicRequire : (exports.safeDynamicRequire = noop);
29
32
  //# sourceMappingURL=safe-dynamic-require.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-dynamic-require.js","sourceRoot":"","sources":["../../../../src/functions/safe-dynamic-require.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,uCAA0C;AAE1C,IAAM,IAAI,GAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;AACxB,oEAAoE;AAEpE,IAAI,uBAAmD,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE;IAC5C,uBAAuB,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC;CACtD;AAED,IAAI,uBAAuB,KAAK,SAAS,IAAI,aAAO,CAAC,QAAQ,EAAE;IAC7D,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;CAC3C;AAED,uBAAuB,aAAvB,uBAAuB,cAAvB,uBAAuB,IAAvB,uBAAuB,GAAK,IAAW,EAAC;AAE7B,QAAA,kBAAkB,GAAoB,uBAAyB,CAAC"}
1
+ {"version":3,"file":"safe-dynamic-require.js","sourceRoot":"","sources":["../../../../src/functions/safe-dynamic-require.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,uCAA0C;AAE1C,IAAM,IAAI,GAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;AAKxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU,IAAI,aAAO,CAAC,QAAQ,EAAE;IAChE,0BAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;CACtC;AAED,0BAAkB,aAAlB,0BAAkB,cAAlB,0BAAkB,IAAlB,0BAAkB,GAAK,IAAW,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/react",
3
- "version": "2.0.8-4",
3
+ "version": "2.0.9",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/builder-react.cjs.js",
@@ -84,7 +84,7 @@
84
84
  "jest": "^28.1.3",
85
85
  "jest-environment-jsdom": "^28.1.3",
86
86
  "lint-staged": "^7.0.0",
87
- "prettier": "^1.4.4",
87
+ "prettier": "^2.6.2",
88
88
  "prompt": "^1.0.0",
89
89
  "react": ">=16.8.0",
90
90
  "react-dom": ">=16.8.0",
@@ -5,30 +5,32 @@ import { Builder } from '@builder.io/sdk';
5
5
  const noop = () => null;
6
6
  // Allow us to require things dynamically safe from webpack bundling
7
7
 
8
- let localSafeDynamicRequire: typeof require | undefined;
8
+ export let safeDynamicRequire: typeof require;
9
9
 
10
10
  /*
11
- * The if condition below used to be if (typeof globalThis.require === "function"
11
+ * The if condition below used to be
12
+ *
13
+ * if (typeof globalThis.require === "function")
14
+ *
12
15
  * That broke in case Builder was running on the server (Next, SSR use-cases) where
13
16
  * globalThis.require was undefined. Avoiding use of Builder.isServer for Cloudflare worker cases
14
- * That said, if we have change it to
15
- *
17
+ * That said, if change it to
18
+ *
16
19
  * if (typeof require === 'function') {
17
20
  * localSafeDynamicRequire = eval('require');
18
21
  * }
19
- *
20
- * Then the TSC compiler over-optimizes and replaces the if condition with true always
22
+ *
23
+ * Then the TSC / rollup compiler over-optimizes and replaces the if condition with true always
21
24
  * causing it to blow up on the client side. Hence this convoluted way of doing it.
25
+ *
26
+ * In Summary:
27
+ *
28
+ * 1. Node -> globalThis.require does not work
29
+ * 2. Client -> typeof require === 'function' does not work because of overoptimization by the compiler
30
+ * 3. Cloudflare edge -> only globalThis.require works
22
31
  */
23
- if (typeof globalThis.require === 'function') {
24
- localSafeDynamicRequire = eval('globalThis.require');
32
+ if (typeof globalThis.require === 'function' || Builder.isServer) {
33
+ safeDynamicRequire = eval('require');
25
34
  }
26
35
 
27
- if (localSafeDynamicRequire === undefined && Builder.isServer) {
28
- localSafeDynamicRequire = eval('require');
29
- }
30
-
31
- localSafeDynamicRequire ??= noop as any;
32
-
33
- export let safeDynamicRequire : typeof require = localSafeDynamicRequire!!;
34
-
36
+ safeDynamicRequire ??= noop as any;