Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #14

Closed
wants to merge 24 commits into from
Closed

Develop #14

wants to merge 24 commits into from

Conversation

takemiyamakoto
Copy link
Contributor

No description provided.

@yves-pkstd
Copy link

yves-pkstd commented Apr 19, 2017

Today i took a look at the implementation and code wise it looks good to me. However once I build the project, create a test npm package with npm pack and install that npm package in a demo nodejs application I am running into many webpack related problems.

Now of course it could be a problem on my end, and I hope it is :), with setup and config problems but I am curious to hear if anybody else is encountering the same problems as I am.

So what is going wrong:

  • if I import the project in js or ts like var Iroha = require("irohajs"); an error is thrown when I run my node script.
    "Type error: i is not a function" for webpack -p
    "Type error: existsSync is not a function" for webpack. existsSync being a fs module function.

Obviously this means that something is going wrong during the packaging.

I know that the following setting should cover that problem but for some reason it is not in my case.

node: { fs: "empty", net: "empty", tls: "empty" },

The way I fixed it is by using the externals webpack config setting. By passing an array of node module paths to the externals setting, webpack leaves require() tags that import from node_modules alone. This results in a code bundle that does not bundle node modules, for example js-sha3, but just leaves the require('js-sha3) tag in place. After doing this I could use the iroha api in my node script.

problem and solution is decribed in great detail here: http:https://jlongster.com/Backend-Apps-with-Webpack--Part-I

Which brings me to the question: as this is a package for nodejs usage, do we include everything in the irohajs.bundle or just the iroha code? Personally, I don't feel the need for a bundle that even includes vendor code.

As the web javascript client will differ greatly, grpc-web (alpha stage) or http rest by grpc-gateway is used, maybe it seems ok to just focus on node when it comes to the webpack settings or later use webpacks target setting and create a config for 'node' and one for 'web'. Currently the target setting is missing so it defaults to web.

Would love to hear all your thoughts on this.

@theofilis
Copy link
Contributor

theofilis commented Apr 22, 2017

Hi, Yves

Your observation are very helpful.

You are right, it is wrong to include vendors library with irohajs and it would be great to have to different webpack configuration one for web and other for nodejs.

So, I write down those two issues/recommendation for webpack configuration.

  • Do not include vendor libraries at irohajs bundle.
  • Distinct configuration for web & nodejs client.

@theofilis
Copy link
Contributor

For a parametrized webpack builds I follow that guide.

@stinger112
Copy link
Contributor

stinger112 commented Mar 28, 2018

PR outdated.

New versions of official Iroha library called iroha-lib and hosted inside main Iroha's repo and on NPM.

@stinger112 stinger112 closed this Mar 28, 2018
@stinger112 stinger112 deleted the develop branch March 28, 2018 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants