Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less magic in voxel-plugins require() plugin loading #8

Closed
deathcap opened this issue Dec 30, 2015 · 0 comments
Closed

Less magic in voxel-plugins require() plugin loading #8

deathcap opened this issue Dec 30, 2015 · 0 comments

Comments

@deathcap
Copy link
Member

The use of require() to find plugins is slightly confusing, that is, the caller passes in their own "require" function that locates the plugins, which they themselves manually require but do not assign the return value, to get picked up by browserify's static analysis. Example:

require 'voxel-artpacks'
require 'voxel-wireframe'
require 'voxel-chunkborder'
require 'voxel-outline'a bunch of plugins …

  createEngine {require:require, exposeGlobal:true, pluginOpts:plugin configuration (also required) …
    'voxel-artpacks': {}
    'voxel-wireframe': {}
    'voxel-chunkborder': {}
    'voxel-outline': {}

it may be more intuitive and less unnecessarily automagical although somewhat more verbose if the caller directly passed in the return value of require() for each plugin. Something like:

'voxel-wireframe': {
  load: require('voxel-wireframe'),
   other options…
},

'voxel-chunkborder': {
  load: require('voxel-chunkborder'),},

or pass in a list of where to find each plugin, and the options still separately:


plugins: [
 require('voxel-wireframe'),
 require('voxel-chunkborder'),
]
pluginOpts: {
 'voxel-wireframe': {},
 'voxel-chunkborder'; {},
}

Object literals in JavaScript use string keys so we probably cannot do something along the lines of this: (at least not in ES5?)

pluginOpts: {
  require('voxel-wireframe'): {},
  require('voxel-chunkborder'): {},
}

plus then there's the problem of finding the canonical plugin name (string passed to require()).

deathcap added a commit to voxel/voxel-engine-stackgl that referenced this issue Jan 10, 2016
Replaces the use of implicit require()'s with an explicit 'loaders'
object, for details see: voxel/voxel-plugins#8
deathcap added a commit to voxel/voxelmetaverse that referenced this issue Jan 10, 2016
New in voxel-engine-stackgl 1.1.0, voxel-plugins 0.5.0
See voxel/voxel-plugins#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant