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.
|
var findup = require('@choojs/findup') |
|
var nodeResolve = require('resolve') |
|
transform = require(transform) |
Main goals of this proposal
There are functions with the same functionality duplicate in both files sync and async
|
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') |
Secondary goals
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

Motivation
In order to allow more flexibility for
dependencies,transformsandreadFileresolution, I suggest to create a minimalist interface with the logic ofglslify-depsavoiding 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 withoutfilesystemornode_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_packagesdirectory. Also transform are retrieved usingnodejscommonjs require.glslify-deps/index.js
Line 2 in 2683223
glslify-deps/index.js
Line 10 in 2683223
glslify-deps/index.js
Line 294 in 2683223
Main goals of this proposal
_resolveImportsinto internal method_addDepSecondary goals
Playground
http://rubeniskov.com/blog/en/shader-sandbox-glslify