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

Improve interfacing deeper to allow more flexibility in custom resolvers #8

Open
25 tasks done
rubeniskov opened this issue Nov 14, 2020 · 1 comment
Open
25 tasks done

Comments

@rubeniskov
Copy link

rubeniskov commented Nov 14, 2020

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

glslify-deps/sync.js

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')

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

output

@rubeniskov
Copy link
Author

@hughsk can you give me feedback about that? thanks in advance

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