glslify / glslify/glslify-deps
Improve interfacing deeper to allow more flexibility in custom resolvers
- Dominant language
- JavaScript
- Stars
- 6
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
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](https://www.npmjs.com/package/@choojs/findup) and [resolver](https://www.npmjs.com/package/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](https://nodejs.org/api/modules.html).
https://github.com/glslify/glslify-deps/blob/268322385c07be0a2578251e16b940e2ec7b4f09/index.js#L2
https://github.com/glslify/glslify-deps/blob/268322385c07be0a2578251e16b940e2ec7b4f09/index.js#L10
https://github.com/glslify/glslify-deps/blob/268322385c07be0a2578251e16b940e2ec7b4f09/index.js#L294
## Main goals of this proposal
- [X] 1. [Reduce the file size as much as possible using atomized logics to improve legibility](https://github.com/glslify/glslify-deps/pull/9)
- [x] [Refactor common utils into separated files](https://github.com/glslify/glslify-deps/pull/9/commits/359efb6f260f220194b2c6eddf5ff6813d5f4b1d)
> There are functions with the same functionality duplicate in both files [sync](https://github.com/glslify/glslify-deps/blob/master/sync.js/sync.js) and [async](https://github.com/glslify/glslify-deps/blob/master/sync.js/index.js)
https://github.com/glslify/glslify-deps/blob/268322385c07be0a2578251e16b940e2ec7b4f09/sync.js#L296-L309
- [x] 2. [Unify logic in one class to manage better the changes between async and sync resolution strategies](https://github.com/glslify/glslify-deps/pull/10)
- [x] [Unify inlineSource and inlineName](https://github.com/glslify/glslify-deps/pull/10/commits/47c49f46257face79ee5a6a86e946161c46b6b94)
- [x] [Unify inline method](https://github.com/glslify/glslify-deps/pull/10/commits/8b5f7a9a669daed7a38f245f1fdd46369044b03d)
- [x] [Unify transform method](https://github.com/glslify/glslify-deps/pull/10/commits/eff149a0c26852b5f0db4230ffb7faa71d593837)
- [x] [Unify resolveTransform method](https://github.com/glslify/glslify-deps/pull/10/commits/e082a4d87b220b26bb1837712a7afb1454b1742e)
- [x] [Unify applyTransforms method](https://github.com/glslify/glslify-deps/pull/10/commits/1bd31d6f0db47352b5c44b5c02463c5c0e938f4e)
- [x] [Unify getTransformsForFile method](https://github.com/glslify/glslify-deps/pull/10/commits/707f3ad40d45a5bd3a75c490da99e326d673801c)
- [x] [Migrate extractPreprocessors](https://github.com/glslify/glslify-deps/pull/10/commits/bfadac0eb578e44c8b99e0f34ad641636cb169cb)
- [x] [Migrate `_resolveImports` into internal method](https://github.com/glslify/glslify-deps/pull/10/commits/d71c4ba1b9ffacfc49c6859782b2207b940b8388)
- [x] [Create internal method `_addDep`](https://github.com/glslify/glslify-deps/pull/10/commits/cd1256c888f4afe426c6300bff684a73fba019af)
- [x] 3. [Interface the deeper class resolvers to be defined on a top level function](https://github.com/glslify/glslify-deps/pull/11), this will allow fully customization
- [x] [Allow transformRequire option with sync/async behaviour](https://github.com/glslify/glslify-deps/pull/11/commits/856838be4fc41342fa592f5b9a35f57cb757789b)
- [x] [Create intermediate class for node environment](https://github.com/glslify/glslify-deps/pull/11/commits/29fe2764168c159d0f0549107815356112a1eb6d)
- [x] [Migrate glslResolve to NodeDepper](https://github.com/glslify/glslify-deps/pull/11/commits/208d6ee2b6ae292ab11794d60dfebb100b144db1)
- [x] [MigratereadFile to NodeDepper](https://github.com/glslify/glslify-deps/pull/11/commits/00e0641a37e53aed80da5a68030104bbaf4a8857)
- [x] [Migrate transformRequire to NodeDepper](https://github.com/glslify/glslify-deps/pull/11/commits/79d2c89d4d72f95d2465dfecaea9d4e1d36d6333)
- [x] [Migrate getTransformForFile to NodeDepper](https://github.com/glslify/glslify-deps/pull/11/commits/49ea8ad78959164992c41317d7687ab267f54074)
- [x] [Migrate this._cwd logic to NodeDepper](https://github.com/glslify/glslify-deps/pull/11/commits/5b67503251767e57c89ae191d4f703b3236b536f)
- [x] [Simplify module exports](https://github.com/glslify/glslify-deps/pull/11/commits/26ea3565f4228fb087dc9f7465bbf34a8ff35040)
## Secondary goals
- [x] 4. [Use [ES6](https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions) classes to remove nodejs [inherits](https://nodejs.org/docs/latest/api/util.html#util_util_inherits_constructor_superconstructor) function and keep JSDoc documentation inheritance between classes, (this is compatible with [nodejs V6](https://node.green/), for retro compatibility, I will implement babel transpilation)](https://github.com/glslify/glslify-deps/pull/12)
- [x] Refactor sources and test to es6
- [x] Lint javascript standard
- [x] [Add hooks to prevent un tested or unlinted code before publish or psuh to git](https://github.com/glslify/glslify-deps/pull/12/commits/bc599cc7cb9361bbcd4253a957bfc975085041f5)
>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
## Playground
http://rubeniskov.com/blog/en/shader-sandbox-glslify

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.