Skip to content

Commit

Permalink
feat: new a Renderer instance if option "use" is a function
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsieh Chin Fan committed Oct 16, 2024
1 parent c83d483 commit c2724bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mapclay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ const prepareRenderer = async config => {
renderer = config
} else if (config.use.steps) {
renderer = config.use
} else {
} else if (typeof config.use === 'function') {
renderer = new config.use()
} else if (typeof config.use === 'string') {
const RendererClass = (await import(config.use)).default
renderer = new RendererClass()
} else {
throw `Cannot get Renderer by config.use ${config.use}`
}

Object.entries(config).forEach(([key, value]) => (renderer[key] = value))
Expand Down

0 comments on commit c2724bc

Please sign in to comment.