-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Motivation
In order to allow more flexibility for dependencies, transforms and readFile resolution, I suggest to create a minimalist interface with the logic of glslify-deps avoiding restrictions associated to the environment. This will delegates on top level, which strategy use for shader resolution in order to make this library compatible with systems without filesystem or node_modules. This library may be used in an environment which has not such capability, like a browser.
Drawbacks of the existing version
This library is using find-up and resolver for find packages, so this behaviour is restricted to be used in an environment where the system has a filesystem discoverable with node_packages directory. Also transform are retrieved using nodejs commonjs require.
Line 2 in 2683223
| var findup = require('@choojs/findup') |
Line 10 in 2683223
| var nodeResolve = require('resolve') |
Line 294 in 2683223
| transform = require(transform) |
Main goals of this proposal
There are functions with the same functionality duplicate in both files sync and async
Lines 296 to 309 in 2683223
function glslifyPreprocessor(data) { return /#pragma glslify:/.test(data) } function glslifyExport(data) { return /#pragma glslify:\s*export\(([^\)]+)\)/.exec(data) } function glslifyImport(data) { return /#pragma glslify:\s*([^=\s]+)\s*=\s*require\(([^\)]+)\)/.exec(data) } function defaultRead(src) { return fs.readFileSync(src, 'utf8')
- 2. Unify logic in one class to manage better the changes between async and sync resolution strategies
- 3. Interface the deeper class resolvers to be defined on a top level function, this will allow fully customization
- Allow transformRequire option with sync/async behaviour
- Create intermediate class for node environment
- Migrate glslResolve to NodeDepper
- MigratereadFile to NodeDepper
- Migrate transformRequire to NodeDepper
- Migrate getTransformForFile to NodeDepper
- Migrate this._cwd logic to NodeDepper
- Simplify module exports
Secondary goals
- 4. [Use ES6 classes to remove nodejs inherits function and keep JSDoc documentation inheritance between classes, (this is compatible with nodejs V6, for retro compatibility, I will implement babel transpilation)](Feature/migrate to es6 #12)
- Refactor sources and test to es6
- Lint javascript standard
- Add hooks to prevent un tested or unlinted code before publish or psuh to git
Each goal will be a PR to accomplish a good tracking of changes and approbation for the maintainer,
Each PR will be rebased with the previous, so its important to merge using the implementation order
