add config to solcLoader to allow resolution of missing imports#9
Open
mikec wants to merge 1 commit intoSilentCicero:masterfrom
Open
add config to solcLoader to allow resolution of missing imports#9mikec wants to merge 1 commit intoSilentCicero:masterfrom
mikec wants to merge 1 commit intoSilentCicero:masterfrom
Conversation
adds `findImports` and `importResolves` options to solcLoader config `findImports` can be used to define a callback function that will be executed when solc compiler encounters a missing import path `importResolves` can be used to define an array of fallback paths for missing imports
Owner
|
Thanks! And nice, I will review tomorrow
…Sent from my iPhone
On Nov 27, 2017, at 5:41 AM, Mike Calvanese ***@***.***> wrote:
@SilentCicero, love the ethdeploy project!
I ran into an issue porting an existing project over to ethdeploy from truffle. I had some import paths in my .sol files referencing zeppelin-solidity/contracts/... where zeppelin-solidity is a project dependency and exists in node_modules. Truffle was somehow handling the resolution to node_modules automatically.
I added some additional config options to solcLoader to support the same path resolution for ethdeploy:
findImports can be used to define a callback function that will be executed when solc compiler encounters a missing import path
for example:
{
test: /\.(sol)$/,
loader: 'ethdeploy-solc-loader',
optimize: 1,
filterFilenames: true,
filterWarnings: true,
findImports: (path) => {
const contents = fs.readFileSync(`node_modules/${path}`).toString()
if (contents) {
return { contents }
} else {
return { error: 'File not found' }
}
}
}
importResolves can be used to define an array of fallback paths for missing imports
for example:
{
test: /\.(sol)$/,
loader: 'ethdeploy-solc-loader',
optimize: 1,
filterFilenames: true,
filterWarnings: true,
importResolves: ['node_modules']
}
You can view, comment on, or merge this pull request online at:
#9
Commit Summary
add config to solcLoader to allow resolution of missing imports
File Changes
M src/loaders/solc/index.js (22)
Patch Links:
https://github.com/SilentCicero/ethdeploy/pull/9.patch
https://github.com/SilentCicero/ethdeploy/pull/9.diff
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Owner
|
@mikec so I think I would make this another loader or can this be browserified somehow? My only worry is keeping the solc loader as something that can be eventually used in browser also. Any thoughts on this? I'm thinking this could be solc-complex, a slightly separate more advanced loader. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@SilentCicero, love the ethdeploy project!
I ran into an issue porting an existing project over to ethdeploy from truffle. I had some import paths in my .sol files referencing
zeppelin-solidity/contracts/...wherezeppelin-solidityis a project dependency and exists innode_modules. Truffle was somehow handling the resolution tonode_modulesautomatically.I added some additional config options to solcLoader to support the same path resolution for ethdeploy:
findImportscan be used to define a callback function that will be executed when solc compiler encounters a missing import pathfor example:
importResolvescan be used to define an array of fallback paths for missing importsfor example: