Can I use JavaScript libs with require on transact

2019-01-28 18:29发布

问题:

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