节点browserifyify节点核心库 [英] node browserify for node core libraries

查看:80
本文介绍了节点browserifyify节点核心库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是一个问题,目的是确认我对节点browserify的理解。

This is a question just to confirm my understanding of node browserify.

substack / node-browserify 说:


兼容性:许多不做IO的npm模块在
被浏览后才可以使用。其他人则需要更多工作。许多节点内置模块
已被包装为可在浏览器中工作,但仅当您显式地
require()或使用其功能时才能使用。

compatibility: Many npm modules that don't do IO will just work after being browserified. Others take more work. Many node built-in modules have been wrapped to work in the browser, but only when you explicitly require() or use their functionality.

-


获取节点核心库事件,流,路径,$ b $的浏览器版本b url,assert,buffer,util,querystring,http,vm和crypto,当您
require()时

get browser versions of the node core libraries events, stream, path, url, assert, buffer, util, querystring, http, vm, and crypto when you require() them

节点browserify是否获取节点内置模块的源代码,并构造捆绑文件;通过正确选择当前可用的NVM版本?

Does node browserify takes the source-code of the node build-in modules, and construct a bundled file; by selecting the current working NVM version properly?

实际上,我是第一次使用browserify与 maxogden / websocket-stream ,效果惊人。

Actually, I used browserify first time with maxogden/websocket-stream, and works amazingly.

推荐答案

不,它确实不要使用初始形式的节点核心模块。某些功能在浏览器中根本没有意义,或者至少必须经过修改才能变得有意义。

No, it does not use node core modules in their initial form. Certain functions don't make sense in the browser at all or at least have to be adapted to make sense.

相反,browserify使用名为浏览器内置,以便提供有意义的替代方案。

Instead browserify uses a module called browser-builtins in order to provide meaningful alternatives.

检查 package.json文件此模块,您可以看到外部软件包提供了哪些核心模块。

Inspecting the package.json file of this module you can see which core modules are provided by external packages.

其余模块来自从这里开始

如您所见,某些模块例如 fs 在浏览器中没有意义(至少没有意义)

As you can see, some modules like fs don't make sense in the browser (at least not at this point).

其他,但是可以很容易适应在浏览器中工作。

Others however can easily be adapted to work in the browser.

以上内容不再完全正确。本着模块化的精神,最新的browserify不再依赖于浏览器内置的组件,而是每个模块shim都单独发布。

The above is not entirely true anymore. In the spirit of modularity the latest browserify no longer depends on browser-builtins, but instead each module shim is published separately.

有关更多信息,请查看 builtins.js package.json

For more information please review builtins.js and package.json

这篇关于节点browserifyify节点核心库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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