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

纵然是瞬间 提交于 2019-12-12 02:39:59

问题


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 i.e. not browserify file.min.js again ?

I've a package that has a browserified and minified file.min.js and its node version

file.node

it is used (as in modName = require("file.node") ) by many files.

but file.node cannot be browserified. don't ask why.

Many files depend upon modName module.

The file.min.js also contains modName such that

<script src='file,min.js' > exposes modName (umd for those who know);

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 ;

Found this answer somewhat helpful


回答1:


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.



来源:https://stackoverflow.com/questions/34681058/how-to-browserify-a-file-that-includes-a-node-module-with-an-equivalent-client-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!