@builder.io/sdk-svelte 0.12.4 → 0.12.5

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 +1 @@
1
- export declare const SDK_VERSION = "0.12.4";
1
+ export declare const SDK_VERSION = "0.12.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.12.4";
1
+ export const SDK_VERSION = "0.12.5";
@@ -12,8 +12,9 @@ import { runInBrowser } from './browser-runtime/browser.js';
12
12
  * types can be resolved correctly.
13
13
  */
14
14
  import { evaluator } from '../../../browser/functions/evaluate/browser-runtime/index.js';
15
+ import { shouldForceBrowserRuntimeInNode } from './should-force-browser-runtime-in-node.js';
15
16
  /**
16
17
  * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
17
18
  * end up sending the server runtime code to the browser (most notably in dev mode).
18
19
  */
19
- export const chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : evaluator(args);
20
+ export const chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : evaluator(args);
@@ -0,0 +1 @@
1
+ export declare const shouldForceBrowserRuntimeInNode: () => boolean;
@@ -0,0 +1,21 @@
1
+ import { logger } from '../../helpers/logger.js';
2
+ import { isNodeRuntime } from '../is-node-runtime.js';
3
+ export const shouldForceBrowserRuntimeInNode = () => {
4
+ if (!isNodeRuntime())
5
+ return false;
6
+ const isArm64 = process.arch === 'arm64';
7
+ const isNode20 = process.version.startsWith('v20');
8
+ // if the user passed this node option, then the `isolated-vm` package will work
9
+ const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes('--no-node-snapshot');
10
+ /**
11
+ * https://github.com/laverdet/isolated-vm/issues/424
12
+ */
13
+ if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
14
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
15
+ If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
16
+ See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
17
+ `);
18
+ return true;
19
+ }
20
+ return false;
21
+ };
@@ -1,4 +1,4 @@
1
- import { checkIsDefined } from '../helpers/nullable';
1
+ import { checkIsDefined } from '../helpers/nullable.js';
2
2
  /**
3
3
  * Identifies node runtime
4
4
  */
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.12.4";
1
+ export declare const SDK_VERSION = "0.12.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.12.4";
1
+ export const SDK_VERSION = "0.12.5";
@@ -12,8 +12,9 @@ import { runInBrowser } from './browser-runtime/browser.js';
12
12
  * types can be resolved correctly.
13
13
  */
14
14
  import { evaluator } from '../../../edge/functions/evaluate/edge-runtime/index.js';
15
+ import { shouldForceBrowserRuntimeInNode } from './should-force-browser-runtime-in-node.js';
15
16
  /**
16
17
  * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
17
18
  * end up sending the server runtime code to the browser (most notably in dev mode).
18
19
  */
19
- export const chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : evaluator(args);
20
+ export const chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : evaluator(args);
@@ -0,0 +1 @@
1
+ export declare const shouldForceBrowserRuntimeInNode: () => boolean;
@@ -0,0 +1,21 @@
1
+ import { logger } from '../../helpers/logger.js';
2
+ import { isNodeRuntime } from '../is-node-runtime.js';
3
+ export const shouldForceBrowserRuntimeInNode = () => {
4
+ if (!isNodeRuntime())
5
+ return false;
6
+ const isArm64 = process.arch === 'arm64';
7
+ const isNode20 = process.version.startsWith('v20');
8
+ // if the user passed this node option, then the `isolated-vm` package will work
9
+ const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes('--no-node-snapshot');
10
+ /**
11
+ * https://github.com/laverdet/isolated-vm/issues/424
12
+ */
13
+ if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
14
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
15
+ If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
16
+ See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
17
+ `);
18
+ return true;
19
+ }
20
+ return false;
21
+ };
@@ -1,4 +1,4 @@
1
- import { checkIsDefined } from '../helpers/nullable';
1
+ import { checkIsDefined } from '../helpers/nullable.js';
2
2
  /**
3
3
  * Identifies node runtime
4
4
  */
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.12.4";
1
+ export declare const SDK_VERSION = "0.12.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.12.4";
1
+ export const SDK_VERSION = "0.12.5";
@@ -12,8 +12,9 @@ import { runInBrowser } from './browser-runtime/browser.js';
12
12
  * types can be resolved correctly.
13
13
  */
14
14
  import { evaluator } from '../../../node/functions/evaluate/node-runtime/index.js';
15
+ import { shouldForceBrowserRuntimeInNode } from './should-force-browser-runtime-in-node.js';
15
16
  /**
16
17
  * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
17
18
  * end up sending the server runtime code to the browser (most notably in dev mode).
18
19
  */
19
- export const chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : evaluator(args);
20
+ export const chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : evaluator(args);
@@ -0,0 +1 @@
1
+ export declare const shouldForceBrowserRuntimeInNode: () => boolean;
@@ -0,0 +1,21 @@
1
+ import { logger } from '../../helpers/logger.js';
2
+ import { isNodeRuntime } from '../is-node-runtime.js';
3
+ export const shouldForceBrowserRuntimeInNode = () => {
4
+ if (!isNodeRuntime())
5
+ return false;
6
+ const isArm64 = process.arch === 'arm64';
7
+ const isNode20 = process.version.startsWith('v20');
8
+ // if the user passed this node option, then the `isolated-vm` package will work
9
+ const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes('--no-node-snapshot');
10
+ /**
11
+ * https://github.com/laverdet/isolated-vm/issues/424
12
+ */
13
+ if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
14
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
15
+ If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
16
+ See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
17
+ `);
18
+ return true;
19
+ }
20
+ return false;
21
+ };
@@ -1,4 +1,4 @@
1
- import { checkIsDefined } from '../helpers/nullable';
1
+ import { checkIsDefined } from '../helpers/nullable.js';
2
2
  /**
3
3
  * Identifies node runtime
4
4
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "0.12.4",
4
+ "version": "0.12.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.12.4"
1
+ export const SDK_VERSION = "0.12.5"
@@ -14,9 +14,10 @@ import type { ExecutorArgs } from './helpers.js';
14
14
  * types can be resolved correctly.
15
15
  */
16
16
  import { evaluator } from 'placeholder-runtime';
17
+ import { shouldForceBrowserRuntimeInNode } from './should-force-browser-runtime-in-node.js';
17
18
 
18
19
  /**
19
20
  * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
20
21
  * end up sending the server runtime code to the browser (most notably in dev mode).
21
22
  */
22
- export const chooseBrowserOrServerEval = (args: ExecutorArgs) => isBrowser() ? runInBrowser(args) : evaluator(args)
23
+ export const chooseBrowserOrServerEval = (args: ExecutorArgs) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : evaluator(args)
@@ -0,0 +1,22 @@
1
+ import { logger } from '../../helpers/logger.js';
2
+ import { isNodeRuntime } from '../is-node-runtime.js';
3
+ export const shouldForceBrowserRuntimeInNode = () => {
4
+ if (!isNodeRuntime()) return false;
5
+ const isArm64 = process.arch === 'arm64';
6
+ const isNode20 = process.version.startsWith('v20');
7
+
8
+ // if the user passed this node option, then the `isolated-vm` package will work
9
+ const hasNoNodeSnapshotNodeOption = process.env.NODE_OPTIONS?.includes('--no-node-snapshot');
10
+
11
+ /**
12
+ * https://github.com/laverdet/isolated-vm/issues/424
13
+ */
14
+ if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
15
+ logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
16
+ If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
17
+ See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
18
+ `);
19
+ return true;
20
+ }
21
+ return false;
22
+ }
@@ -1,4 +1,4 @@
1
- import { checkIsDefined } from '../helpers/nullable';
1
+ import { checkIsDefined } from '../helpers/nullable.js';
2
2
 
3
3
  /**
4
4
  * Identifies node runtime