Skip to content

Commit bc362e8

Browse files
committed
fix: automatically switch to fetch mode when runtime is set
1 parent 087a721 commit bc362e8

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
See [https://github.com/ice-lab/icestark/releases](https://github.com/ice-lab/icestark/releases) for what has changed in each version of icestark.
44

5+
# 2.8.4
6+
7+
- [fix] automatically switch to "fetch" mode when runtime is set.
8+
59
# 2.8.3
610

711
- [feat] support `runtime.url` as an array for loading multiple types of resources.

packages/icestark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/stark",
3-
"version": "2.8.3",
3+
"version": "2.8.4",
44
"description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.",
55
"scripts": {
66
"build": "rm -rf lib && tsc",

packages/icestark/src/AppRoute.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ export default class AppRoute extends React.Component<AppRouteProps, AppRouteSta
8686
};
8787
const { loadScriptMode, runtime } = props;
8888

89-
if (loadScriptMode && loadScriptMode !== 'fetch' && runtime) {
90-
console.error('[icestark] runtime option can only be used when loadScriptMode is set to "fetch"');
89+
if (runtime) {
90+
if (loadScriptMode && loadScriptMode !== 'fetch') {
91+
console.error('[icestark] runtime option can only be used when loadScriptMode is set to "fetch"');
92+
} else if (!loadScriptMode) {
93+
console.warn('[icestark] Runtime option detected but loadScriptMode not set - automatically switching to "fetch" mode');
94+
}
9195
}
9296
}
9397

packages/icestark/src/apps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,14 @@ function mergeThenUpdateAppConfig(name: string, configuration?: StartConfigurati
374374
return;
375375
}
376376

377-
const { umd, sandbox } = appConfig;
377+
const { umd, sandbox, runtime } = appConfig;
378378

379379
// Generate appSandbox
380380
const appSandbox = createSandbox(sandbox) as Sandbox;
381381

382382
// Merge loadScriptMode
383383
const sandboxEnabled = sandbox && !appSandbox.sandboxDisabled;
384-
const loadScriptMode = appConfig.loadScriptMode ?? (umd || sandboxEnabled ? 'fetch' : 'script');
384+
const loadScriptMode = appConfig.loadScriptMode ?? (umd || sandboxEnabled || (runtime && runtime.length > 0) ? 'fetch' : 'script');
385385

386386
// Merge global configuration
387387
const cfgs = {

0 commit comments

Comments
 (0)