@farmfe/runtime
Advanced tools
Comparing version 0.9.0 to 0.9.1
# @farmfe/runtime | ||
## 0.9.1 | ||
### Patch Changes | ||
- 736e6620: fix #878 | ||
## 0.9.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Runtime of Farm", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -101,2 +101,4 @@ import { Module } from './module'; | ||
if (!initializer) { | ||
// TODO: fix `const assert = require('assert');` when assert is external. This leads to `assert is not a function` error caused by default export different from esm and cjs | ||
// TODO: we may need to add `@swc/helpers/_/_interop_require_default` for external modules, replace `const assert = require('assert');` to `const assert = _interop_require_default(require('assert'));` | ||
if (this.externalModules[moduleId]) { | ||
@@ -110,2 +112,3 @@ return this.externalModules[moduleId]; | ||
} | ||
this.pluginContainer.hookSerial('moduleNotFound', moduleId); | ||
// return a empty module if the module is not registered | ||
@@ -253,3 +256,2 @@ console.log(`[Farm] Module "${moduleId}" is not registered`); | ||
// The public paths are injected during compile time | ||
// This method can also be called during runtime to add new public paths | ||
setPublicPaths(publicPaths: string[]): void { | ||
@@ -261,9 +263,19 @@ this.publicPaths = publicPaths; | ||
// The plugins are injected during compile time. | ||
// This method can also be called during runtime to add new plugins | ||
setPlugins(plugins: FarmRuntimePlugin[]): void { | ||
this.pluginContainer.plugins = plugins; | ||
} | ||
// This method can be called during runtime to add new plugins | ||
addPlugin(plugin: FarmRuntimePlugin): void { | ||
if (this.pluginContainer.plugins.every((p) => p.name !== plugin.name)) { | ||
this.pluginContainer.plugins.push(plugin); | ||
} | ||
} | ||
// This method can be called during runtime to remove plugins | ||
removePlugin(pluginName: string): void { | ||
this.pluginContainer.plugins = this.pluginContainer.plugins.filter( | ||
(p) => p.name !== pluginName | ||
); | ||
} | ||
// The external modules are injected during compile time. | ||
// This method can also be called during runtime to add new plugins | ||
setExternalModules(externalModules: Record<string, any>): void { | ||
@@ -270,0 +282,0 @@ Object.assign(this.externalModules, externalModules || {}); |
@@ -15,2 +15,4 @@ import { Module } from './module'; | ||
readModuleCache?: (module: Module) => boolean | Promise<boolean>; | ||
// called when module is not found | ||
moduleNotFound?: (moduleId: string) => void | Promise<void>; | ||
} | ||
@@ -17,0 +19,0 @@ |
21682
523