简体   繁体   English

如何对包含具有等效客户端版本的节点模块的文件进行浏览器化?

[英]How to browserify a file that includes a node module with an equivalent client version?

Found a package that does replace, going to test with that. 找到了一个可以替换的软件包 ,将对其进行测试。 Now if file.node gets replaced with file.min.js my question would be, how to not browserify this dependency ie not browserify file.min.js again ? 现在,如果用file.node替换file.min.js我的问题是,如何不浏览器这种依赖关系,即不再次file.min.js呢?

I've a package that has a browserified and minified file.min.js and its node version 我有一个包含浏览器和缩小的file.min.js及其节点版本的软件包

file.node file.node

it is used (as in modName = require("file.node") ) by many files. 许多文件都使用它(如modName = require("file.node") )。

but file.node cannot be browserified. 但是file.node无法浏览。 don't ask why. 不要问为什么。

Many files depend upon modName module. 许多文件取决于modName模块。

The file.min.js also contains modName such that file.min.js还包含modName这样

<script src='file,min.js' > exposes modName (umd for those who know); <script src='file,min.js' >公开modName(对于那些知道的人为umd);

Is there a way to browserify my pacakges main file main.js (which contains files that depend upon modName) such that I can replace the module file.node with file.min.js ; 有没有办法来browserify我pacakges主文件main.js (其中包含依赖的modname文件),这样我可以更换模块file.nodefile.min.js ;

Found this answer somewhat helpful 发现这个答案有些帮助

Thanks to this guy's solution here 感谢这家伙在这里解决方案

which might be a problem to others looking for an answer, this got solved. 这对于寻求答案的其他人可能是个问题,此问题已解决。

Just doing 只是做

globalShim = require('browserify-global-shim').configure({ nodeModuleName: clientModuleName }),

replaces, nodeModule = require('nodeModuleName') with clientModuleName in browser which is window.clientModuleName actually. 在实际上是window.clientModuleName浏览器中,用clientModuleName替换nodeModule = require('nodeModuleName')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM