有浏览器替代的替代方法吗? [英] Is there an alternative to Browserify?

查看:70
本文介绍了有浏览器替代的替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Node.js生成客户端JavaScript.我找到了Browserify,但是Browserify还有其他替代方法吗?

解决方案

如果我写错了,请纠正我.据我了解,browserify用于将JavaScript预处理为浏览器可以理解的格式.它获取Node中所有必需"的代码,并将其全部打包到一个文件中.不知道它是否还要进行其他预处理.

这是模块化JavaScript的预处理方法.

动态模块化是通过RequireJ或SystemJ实现的.SystemJs是使新的ES6模块化方法现在可用的新方法.我认为这太棒了.有人可能会认为它是一种保鲜纸?

请注意,SystemJs都是由babel(EcmaScript 6to5预处理器(用于确定性)和Angular2(我相信))促进的.

动态模块化v预处理的好处是,无论是否使用预处理,预处理都会加载所有代码.动态模块化仅在需要时加载代码-例如在按钮上单击.因此,您不必预先加载所有代码.这样可以减轻页面重量并释放资源.动态模块化的问题在于,您必须在加载"代码时进行编码.进行初始联播也可能很痛苦.使用预处理时,您无需担心所有这些问题.

希望有帮助

I want to generate client side JavaScript from Node.js. I found Browserify, but is there any other alternative to Browserify ?

解决方案

Correct me if I'm wrong. As I understand it browserify is used to pre-process JavaScript into a format in which the browser can understand it. It grabs all the code which is "require'd" in Node and bungs it all in one file. Not sure if it does any other pre-processing.

This is a pre-processing approach to modular JavaScript.

Dynamic modularisation is achieved via RequireJs or SystemJs. SystemJs is the new approach that makes the new ES6 modularisation approach available now. It is awesome in my opinion. One might consider it a polyfill???

Note that SystemJs is both promoted by babel - the EcmaScript 6to5 pre-processor (for definite) - and Angular2 (I believe)

The benefit of dynamic modularisation v pre-processing is that pre-processing loads all your code whether you use it or not. Dynamic modularisation only loads code when needed - e.g. on a button click. Thus you do not load all your code up front. This reduces page weight and frees up resources. The problem with dynamic modularisation is that you have to code "when" code is loaded. It can also be a pain doing the initial hookup. When using pre-processing you don't have all these concerns.

Hope that helps

这篇关于有浏览器替代的替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆