@builder.io/react 2.0.8-3 → 2.0.8-4
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/builder-react-lite.cjs.js +1 -1
- package/dist/builder-react-lite.cjs.js.map +1 -1
- package/dist/builder-react-lite.esm.js +1 -1
- package/dist/builder-react-lite.esm.js.map +1 -1
- package/dist/builder-react.browser.js +1 -1
- package/dist/builder-react.browser.js.map +1 -1
- package/dist/builder-react.cjs.js +1 -1
- package/dist/builder-react.cjs.js.map +1 -1
- package/dist/builder-react.es5.js +1 -1
- package/dist/builder-react.es5.js.map +1 -1
- package/dist/builder-react.unpkg.js +1 -1
- package/dist/builder-react.unpkg.js.map +1 -1
- package/dist/lib/package.json +1 -1
- package/dist/lib/src/functions/safe-dynamic-require.js +19 -3
- package/dist/lib/src/functions/safe-dynamic-require.js.map +1 -1
- package/package.json +1 -1
- package/src/functions/safe-dynamic-require.ts +21 -3
package/dist/lib/package.json
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
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; };
|
|
6
|
+
// Allow us to require things dynamically safe from webpack bundling
|
|
7
|
+
var localSafeDynamicRequire;
|
|
5
8
|
/*
|
|
6
9
|
* The if condition below used to be if (typeof globalThis.require === "function"
|
|
7
10
|
* That broke in case Builder was running on the server (Next, SSR use-cases) where
|
|
8
11
|
* globalThis.require was undefined. Avoiding use of Builder.isServer for Cloudflare worker cases
|
|
12
|
+
* That said, if we have change it to
|
|
13
|
+
*
|
|
14
|
+
* if (typeof require === 'function') {
|
|
15
|
+
* localSafeDynamicRequire = eval('require');
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* Then the TSC compiler over-optimizes and replaces the if condition with true always
|
|
19
|
+
* causing it to blow up on the client side. Hence this convoluted way of doing it.
|
|
9
20
|
*/
|
|
10
|
-
if (typeof require === 'function')
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
if (typeof globalThis.require === 'function') {
|
|
22
|
+
localSafeDynamicRequire = eval('globalThis.require');
|
|
23
|
+
}
|
|
24
|
+
if (localSafeDynamicRequire === undefined && sdk_1.Builder.isServer) {
|
|
25
|
+
localSafeDynamicRequire = eval('require');
|
|
26
|
+
}
|
|
27
|
+
localSafeDynamicRequire !== null && localSafeDynamicRequire !== void 0 ? localSafeDynamicRequire : (localSafeDynamicRequire = noop);
|
|
28
|
+
exports.safeDynamicRequire = localSafeDynamicRequire;
|
|
13
29
|
//# 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;;;
|
|
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"}
|
package/package.json
CHANGED
|
@@ -5,12 +5,30 @@ 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
|
-
|
|
8
|
+
let localSafeDynamicRequire: typeof require | undefined;
|
|
9
9
|
|
|
10
10
|
/*
|
|
11
11
|
* The if condition below used to be if (typeof globalThis.require === "function"
|
|
12
12
|
* That broke in case Builder was running on the server (Next, SSR use-cases) where
|
|
13
13
|
* globalThis.require was undefined. Avoiding use of Builder.isServer for Cloudflare worker cases
|
|
14
|
+
* That said, if we have change it to
|
|
15
|
+
*
|
|
16
|
+
* if (typeof require === 'function') {
|
|
17
|
+
* localSafeDynamicRequire = eval('require');
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* Then the TSC compiler over-optimizes and replaces the if condition with true always
|
|
21
|
+
* causing it to blow up on the client side. Hence this convoluted way of doing it.
|
|
14
22
|
*/
|
|
15
|
-
if (typeof require === 'function')
|
|
16
|
-
|
|
23
|
+
if (typeof globalThis.require === 'function') {
|
|
24
|
+
localSafeDynamicRequire = eval('globalThis.require');
|
|
25
|
+
}
|
|
26
|
+
|
|
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
|
+
|