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

option for renderer no-op #236

Closed
yomed opened this issue Feb 25, 2016 · 3 comments
Closed

option for renderer no-op #236

yomed opened this issue Feb 25, 2016 · 3 comments

Comments

@yomed
Copy link
Contributor

yomed commented Feb 25, 2016

For custom dynamic tags, I have a function using the try-require module that works as follows:

function loadRenderer(path) {
    var renderer = rendererCache[path];
    if (!renderer) {
        renderer = rendererCache[path] = tryRequire(path) || 'not-found';
    }
    return renderer;
}

I then use this to determine whether to require a renderer or a template:

    if (!isWidget && !widgetId) {
        module.type = 'renderer';
        module.renderer = loadRenderer(path.join(modulePath, 'renderer.js'));
        if (module.renderer === 'not-found') {
            module.template = loadRenderer(path.join(modulePath, 'template.marko'));
            module.type = 'template';
        }
    }

This works fine normally, but in functional tests through karma, it looks like the runtime is attempting to resolve not-found to a module. This results in the following error:

Cannot find module "not-found" from "/$/marko/runtime"
    require@.../.test/static/node_modules/lasso/node_modules/raptor-modules/client/lib/raptor-modules-client.js:568:52
    instanceRequire@.../.test/static/node_modules/lasso/node_modules/raptor-modules/client/lib/raptor-modules-client.js:113:75
    load@.../.test/static/node_modules/marko/runtime/loader_browser.js:21:19
    load@.../.test/static/node_modules/marko/runtime/marko-runtime.js:295:39
    l@.../.test/static/node_modules/marko/runtime/helpers.js:197:36

I tried setting renderer to a handful of other types based on the relevant marko code, but ran into different issues each time. Do you know how I could effectively make this a no-op? Or if there is a better way to achieve the same thing?

@patrick-steele-idem
Copy link
Contributor

I realize I am slow to reply to this, but it's a little hard to say with the issue is. From what I can tell, maybe both the renderer.js and template.marko are not being found? I think I might need to take a closer a look at your code when you get a chance.

@yomed
Copy link
Contributor Author

yomed commented Mar 18, 2016

I think you're right - and I think it's because of marko-js-archive/marko-widgets#130
Looks like I might need to artificially require everything that goes through dynamic-tag

@mlrawlings
Copy link
Member

@yomed I'm closing this, re-open it if it still needs to be addressed

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

3 participants