Can I use JavaScript libs with require on transaction processor of fabric composer? I'd like to use it with npm install.. at least I couldn't do this on playground now.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
No, we do not support that. We have tentative plans to move to native Node.js chain code container, which may allow this. It does raise some challenges around lifecycle management of the code however.
回答2:
I have tried to use momentjs and numeraljs in my project . Since i can use many logic js file in my model .
I have decided to add numeral.js and moment.js in the lib folder with my logic.js .
1/ Moment.js and numeral.js in lib file
later , i call them directly without using require or import and disable eslint undefined
// eslint-disable-next-line no-undef
2/ Example of using momentjs and numeraljs in user.js as my logic javascript file .
Here is the result in playground and composer-rest-server
3/ Result using playground
4/ Result using composer-rest-server