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

marko-widgets by default pulling in marko runtime #99

Open
senthilp opened this issue Oct 15, 2015 · 5 comments
Open

marko-widgets by default pulling in marko runtime #99

senthilp opened this issue Oct 15, 2015 · 5 comments

Comments

@senthilp
Copy link

marko-widgets by default is pulling in marko runtime due to this reference to ./defineRenderer. The first line in defineRenderer.js is
require('marko').

Is this needed?
If needed why is the package.json not having dependency on marko? There is only a devDependency

@philidem
Copy link
Contributor

marko-widgets definitely requires the marko runtime (it would never be used without it). I think the reason that marko was not declared as a production dependency was so that the top-level project can declare the specific version of marko and it was assumed that that would satisfy the dependency.

However, I think it would be safe to move marko to the normal dependencies of the marko-widdgets module for clarity. The npm install command should only install marko once even if the top-level project and marko-widgets module both require it. The only time that you might see it installed twice is if you run npm install marko-widgets and then npm install marko for your project.

Anyways, I would say move marko to dependencies in the package.json.

@senthilp
Copy link
Author

Thanks @philidem. Based on my conversation with @patrick-steele-idem the marko-runtime is only be needed when there is client side rendering. Which makes sense, as the marko dependency is only there in the defineRenderer.js file. In our (eBay) pages, most of them are server side rendered. If that is the case why should we include the marko-runtime in the JS that is sent to the browser? Is there any other use of the marko-runtime to be needed in the browser?

Is it possible to have the client side rendering JS packaged separately in marko-widgets?

@patrick-steele-idem
Copy link
Contributor

Hey @senthilp, defineRenderer() is for rendering so it will have a hard dependency on marko since marko is used for the view. Marko Widgets lets you split the renderer and widget into separate files. If you go the split renderer/widget route and you are only rendering on the server then you would only send down the widget to the browser (not the renderer) and the renderer would be used on the server. The renderer would be defined using the defineRenderer() method and the widget would defined using the defineWidget() method. The defineWidget() method does not bring in the marko runtime.

@patrick-steele-idem
Copy link
Contributor

@senthilp
Copy link
Author

But @patrick-steele-idem having this line in the main marko-widget file, will make the lasso optimizer bundle the 'marko-runtime' too along with the widget library. Even if I split the renderer and widget it would not make a difference in the final generated JS file.

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