@farmfe/runtime
Advanced tools
Comparing version 0.6.1 to 0.6.2
# @farmfe/runtime | ||
## 0.6.2 | ||
### Patch Changes | ||
- 3073e19: Isolate runtime from globalThis for script entries | ||
## 0.6.1 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Runtime of Farm", | ||
@@ -5,0 +5,0 @@ "author": { |
import { ModuleSystem } from './module-system'; | ||
// Injected during build | ||
declare const __farm_global_this__: any; | ||
type FarmGlobalThis = (Window & | ||
typeof globalThis & | ||
typeof global & | ||
typeof self) & { | ||
noop: () => void; | ||
__farm_module_system__: ModuleSystem; | ||
}; | ||
const __farm_global_this__ = (globalThis || | ||
window || | ||
global || | ||
self) as FarmGlobalThis; | ||
__farm_global_this__.noop = function () { | ||
/* do nothing */ | ||
}; | ||
__farm_global_this__.__farm_module_system__ = (function () { | ||
@@ -21,0 +6,0 @@ const moduleSystem = new ModuleSystem(); |
@@ -5,2 +5,4 @@ import { Module } from './module'; | ||
declare const __farmNodeRequire: (moduleId: string) => any; | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
@@ -85,8 +87,2 @@ // @ts-ignore swc helpers does not have type definition | ||
if (targetEnv === 'node') { | ||
const { __farmNodeRequire } = | ||
// TODO: polyfill globalThis | ||
globalThis as unknown as { | ||
__farmNodeRequire: (id: string) => any; | ||
}; | ||
return __farmNodeRequire(moduleId); | ||
@@ -93,0 +89,0 @@ } |
@@ -8,7 +8,6 @@ // using native ability to load resources if target env is node. | ||
export const targetEnv = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore do not check type here | ||
(globalThis || global || window || self).__FARM_TARGET_ENV__ || 'node'; | ||
declare const __farm_global_this__: any; | ||
export const targetEnv = __farm_global_this__.__FARM_TARGET_ENV__ || 'node'; | ||
/** | ||
@@ -15,0 +14,0 @@ * Loading resources according to their type and target env. |
16888
427