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

Marko v3: Improve taglib discovery #224

Closed
patrick-steele-idem opened this Issue Feb 12, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@patrick-steele-idem
Copy link
Contributor

patrick-steele-idem commented Feb 12, 2016

Searching for every node_modules/*/marko-taglib.json file (starting from the directory of the template and moving up the tree) was probably not the best choice since it can be problematic (especially with npm switching to a flattened node_modules directory). The new strategy will be to only load taglibs associated with dependencies explicitly declared in the package's package.json at the root of the package. The set of dependencies that will be searched will be a superset of the dependencies, devDependencies and peerDependencies. The algorithm will be similar to the following:

var resolveFrom = require('resolve-from');
var packageRootDir = getPackageRootDir();

var foundTaglibs = [];

var pkg = readPackageJson(packageRootDir);

var allDependencyNames = 
    concatKeys(pkg.dependencies, pkg.devDependencies, pkg.peerDependencies);

allDependencyNames.forEach((name) => {
        try {
            var taglibPath = resolveFrom(packageRootDir, name + '/marko.json');
            foundTaglibs.push(taglibPath);
        } catch(e) {
            // The package doens't export a Marko taglib... skip it
        }
    });

In addition, when looking for marko.json (previously marko-taglib.json) files outside of installed packages we will only search up to the root of the current package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment