@farmfe/runtime
Advanced tools
Comparing version 0.6.2 to 0.7.0
# @farmfe/runtime | ||
## 0.7.0 | ||
### Minor Changes | ||
- d604b5e: Support React SSR | ||
## 0.6.2 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Runtime of Farm", | ||
@@ -5,0 +5,0 @@ "author": { |
import { ModuleSystem } from './module-system'; | ||
// Injected during build | ||
declare const __farm_global_this__: any; | ||
import { __farm_global_this__ } from './resource-loader'; | ||
@@ -5,0 +4,0 @@ __farm_global_this__.__farm_module_system__ = (function () { |
@@ -8,3 +8,10 @@ // using native ability to load resources if target env is node. | ||
declare const __farm_global_this__: any; | ||
// Injected during build | ||
declare const __farm_namespace__: string; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
export const __farm_global_this__: any = (globalThis || | ||
window || | ||
global || | ||
self)[__farm_namespace__]; | ||
@@ -26,3 +33,12 @@ export const targetEnv = __farm_global_this__.__FARM_TARGET_ENV__ || 'node'; | ||
load(resource: Resource): Promise<void> { | ||
if (targetEnv === 'node') { | ||
if (resource.type === 'script') { | ||
return this._loadScript(`./${resource.path}`); | ||
} else if (resource.type === 'link') { | ||
return this._loadLink(`./${resource.path}`); | ||
} | ||
} | ||
let index = 0; | ||
while (index < this.publicPaths.length) { | ||
@@ -79,5 +95,5 @@ const publicPath = this.publicPaths[index]; | ||
if (targetEnv === 'node') { | ||
return Promise.reject(new Error('Not support loading css in SSR')); | ||
// await import(path); | ||
// TODO investigate how to load css in SSR | ||
// return Promise.reject(new Error('Not support loading css in SSR')); | ||
// ignore css loading in SSR | ||
return Promise.resolve(); | ||
} else { | ||
@@ -84,0 +100,0 @@ return new Promise((resolve, reject) => { |
17383
440