@builder.io/react 2.0.8 → 2.0.10-0

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
+ "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",
@@ -1,13 +1,32 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.safeDynamicRequire = void 0;
4
+ var sdk_1 = require("@builder.io/sdk");
4
5
  var noop = function () { return null; };
5
6
  /*
6
- * 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
+ *
7
11
  * That broke in case Builder was running on the server (Next, SSR use-cases) where
8
12
  * globalThis.require was undefined. Avoiding use of Builder.isServer for Cloudflare worker cases
13
+ * That said, if change it to
14
+ *
15
+ * if (typeof require === 'function') {
16
+ * localSafeDynamicRequire = eval('require');
17
+ * }
18
+ *
19
+ * Then the TSC / rollup compiler over-optimizes and replaces the if condition with true always
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
9
27
  */
10
- if (typeof require === 'function')
28
+ if (typeof globalThis.require === 'function' || sdk_1.Builder.isServer) {
11
29
  exports.safeDynamicRequire = eval('require');
30
+ }
12
31
  exports.safeDynamicRequire !== null && exports.safeDynamicRequire !== void 0 ? exports.safeDynamicRequire : (exports.safeDynamicRequire = noop);
13
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;;;AAIb,IAAM,IAAI,GAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;AAKxB;;;;GAIG;AACH,IAAI,OAAO,OAAO,KAAK,UAAU;IAAE,0BAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;AACxE,0BAAkB,aAAlB,0BAAkB,cAAlB,0BAAkB,IAAlB,0BAAkB,GAAK,IAAW,EAAC"}
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",
3
+ "version": "2.0.10-0",
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",
@@ -8,9 +8,29 @@ const noop = () => null;
8
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
17
+ * That said, if change it to
18
+ *
19
+ * if (typeof require === 'function') {
20
+ * localSafeDynamicRequire = eval('require');
21
+ * }
22
+ *
23
+ * Then the TSC / rollup compiler over-optimizes and replaces the if condition with true always
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
14
31
  */
15
- if (typeof require === 'function') safeDynamicRequire = eval('require');
32
+ if (typeof globalThis.require === 'function' || Builder.isServer) {
33
+ safeDynamicRequire = eval('require');
34
+ }
35
+
16
36
  safeDynamicRequire ??= noop as any;