This repository has been archived by the owner on Aug 6, 2020. It is now read-only.
Fix install on Windows and network/react import #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR focuses on fixing #27 (issues related to build on Windows).
Problems
First there is an issue regarding the preinstall script: it assumes lib directory is present, however, it is not if the project has never been built. Which prevents it from being built at the first place. At a first attempt, I moved this to an install script (=post install) but ended up removing the symlink of the react subfolder all together.
In fact, the ln command makes it complicated to install on Windows, one replacement could be to consider using a package like shx though, I went for another solution for now.
Even if the symlink creation works, at the end it is going to fail because (at least on Windows) paths from the symlink folder are resolved at the path of the symlink itself.
For example, lib/react/useWeb3Hook.js attempts to require ../context/providers, which works well from lib/react but not from the actual symlink location.
Solutions
To keep it consistent and allow to import the react implementation using this nice path: "@openzeppelin/network/react"
Other
Wondering if there is another solution to solve the import problem... but for now this has been working on my side. This has been tested on Win with cmd and also a bash shell.