-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
feat: eject #1912
Comments
The EthPM Types PackageManifest is supposed to be like an "ejected" project in that we pushing for adoption across tools and the manifest should contain all the compiler info and dependency info necessary to compile a project; no structure is needed. The sources are included in the manifest. You can compile a manifest by using the source data to compile and populate parts the contract types. Right now I am working on a refactor that is going to make this part even easier, so compiling a manifest (turning source data into contract type data and populating different fields in the manifest). Doing may indeed render the .cache folder unnecessary! |
The manifest is a JSON file yeah? Do you expect the compilers to directly ingest the manifest or would it still need to be laid out like with the standard input JSON files?
Look forward to seeing this 👍 |
I sometimes get a little confused as well, I don't think this is really talking about the Right now, what's happening is that a "package" is built for a dependency by downloading some source of a project (github, npm, etc), and it's bundled into a manifest and built all together, then loaded under What we could do instead is basically better utilize the definition of a dependency to deduplicate a lot of this work:
Using this, we can remove the need for the |
So you're saying copy user sources into the global package dir? And the package dir is the compile Couple things that jump to mind:
Could work though. |
Just dependency sources, not user projects. Calling the compiler for the user project would reference the paths of these dependencies via the source remapping feature of solc/vyper using the dependency's name (which is currently happening twice)
Yes, it should "clean" itself only down to the file set of source files, and not the whole directory. Essentially, glob it by all the registered compiler extensions, which may actually resolve another issue with it not recompiling when you first forget to install a compiler plugin a dependency might need (say |
Yeah, using absolute paths in remappings would not be portable. As the input JSON would have to have the full FS path in the file if it's not relative to the base path. So compiling on one machine is likely going to be different than another. That's where this idea came from. That all relevant sources are assembled into one reproducible file structure with a common base path.
By clean I mean only the necessary files would be in the resulting file structure, not just filtering by lang. So, |
Could it be not under
Oh, I think that's entirely too low level, but in theory we are pre-fetching the local project's imports and can do some level of analysis to reduce the fileset saved on disk, but this would likely be very complicated |
We're already doing import analysis for remappings. |
Fixed by the project 0.8 refactor. You can do extract a project with all its deps by doing:
|
Overview
Loosely inspired by create-react-app's eject feature.
Basically, running a command like
ape eject
would essentially export your project into an ape-less structure. I think at a minimum it would only include your contracts and all of their imported dependencies. It's essentially a mechanism to "step out" of the ape framework.This might be useful for a handful of specific reasons:
The final bullet point is what brought me here (see #1335). The
contracts/.cache
folder makes things tricky, and moving it has unexpected behavior, like altering the compiler's output bytecode due to the metadata hash changing. This would be less of a concern if we just recreated the contract structure including the needed dependencies in a temporary directory as a step in the build process. In this way, the directory structure the compiler sees never changes.The underlying mechanism of
ape eject
would be a (behind the scenes) required step before theape compile
build process.Specification
Command
ape eject BUILD_DIR
Where
BUILD_DIR
is the optional path to a directory to eject the project to.Mechanism
Consider a project that looks something like this:
ape-config.yaml
has configuration for OpenZeppelin dependencies andape.sol
is a simple ERC20 token contract. Runningape eject /tmp/build
would create something that looks like this:In a normal build process a
CompilerAPI
plugin would be handed/tmp/build
as thebase_path
andape.sol
as contract path. I don't expect much changes to compiler plugins.Caveats
This may or may not make import remapping unnecessary. Or it may require patching to contracts, which probably wouldn't be ideal. This may require updates to compiler plugins as well, if remapping behavior needs to change. Though it might simplify compiler plugins for the better.
Would need to investigate a bit more and maybe test the eject output out with raw compilers and see how they react.
The text was updated successfully, but these errors were encountered: