@farmfe/runtime
Advanced tools
Comparing version 0.12.2 to 0.12.3
# @farmfe/runtime | ||
## 0.12.3 | ||
### Patch Changes | ||
- ae6e0ca9: Fix import compatibility | ||
## 0.12.2 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"description": "Runtime of Farm", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -6,2 +6,3 @@ import { Module } from "./module"; | ||
ResourceLoader, | ||
__global_this__, | ||
isBrowser, | ||
@@ -105,4 +106,4 @@ targetEnv, | ||
if (!(globalThis || global || window || {}).require) { | ||
(globalThis || global || window || { require: undefined }).require = | ||
if (!__global_this__.require) { | ||
__global_this__.require = | ||
this.require.bind(this); | ||
@@ -109,0 +110,0 @@ } |
@@ -13,6 +13,7 @@ // using native ability to load resources if target env is node. | ||
export const __farm_global_this__: any = '<@__farm_global_this__@>'; | ||
export const __global_this__: any = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; | ||
export const targetEnv = __farm_global_this__.__FARM_TARGET_ENV__ || 'node'; | ||
export const isBrowser = | ||
targetEnv === 'browser' && (globalThis || window).document; | ||
targetEnv === 'browser' && __global_this__.document; | ||
@@ -139,3 +140,4 @@ /** | ||
private _loadScript(path: string): Promise<void> { | ||
if (!isBrowser) { | ||
// @ts-ignore | ||
if (FARM_RUNTIME_TARGET_ENV !== 'browser') { | ||
return import(path); | ||
@@ -159,3 +161,4 @@ } else { | ||
private _loadLink(path: string): Promise<void> { | ||
if (!isBrowser) { | ||
// @ts-ignore | ||
if (FARM_RUNTIME_TARGET_ENV !== 'browser') { | ||
// return Promise.reject(new Error('Not support loading css in SSR')); | ||
@@ -162,0 +165,0 @@ // ignore css loading in SSR |
28273
673