-
Notifications
You must be signed in to change notification settings - Fork 116
experiment: --override
flag to support multiple package versions
#5124
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
base: master
Are you sure you want to change the base?
Conversation
…resolve-transitive-import-1
--override
flag to support multiple package versions
…resolve-transitive-import-1
Is this still something that is being evaluated? |
Work in progress!
In order to release the new Motoko base library under the same package name, it's important that we provide a way for Mops and other package managers to be able to use more than one version of a package within a project.
This PR implements a command-line flag (currently
--override
, subject to change) which makes it possible to redirect imports within a specific directory. This way, package managers can use previous base library (or other package) versions of transitive dependencies with breaking changes that would otherwise result in compilation errors inside of imported packages.Due to of a large number of tradeoffs for different approaches (e.g. npm-style dependency solving, Deno- and Go-style explicit imports, PureScript-style package sets), this design makes it so that Motoko package managers can fully decide how to resolve dependencies rather than building an opinionated solution into the compiler.
Here is an example using Mops:
Because the new base library includes breaking changes, importing
mo:vector
would normally cause unfixable compiler errors in this situation. This PR makes it so that Mops can pass a compiler flag via themops sources
command to rewrite themo:base
imports within thevector
package:Another benefit of this approach is that it becomes possible to protect packages from accessing dependencies which are not specified in the corresponding
mops.toml
file. For example:When importing a package which isn't specified in the project's
mops.toml
file, this convention would produce a "package not defined" compilation error to prevent accidentally importing a transitive dependency.Note that package names containing the
/
character are inaccessible using Motoko's import syntax. We can choose whether it's possible to directly access the package versions using the@
symbol instead of/
as a convention. This gives package managers more flexibility around whether explicit package versions are globally available.Below is a hypothetical example for Go-style imports, configuring defaults with
--override
:The idea is that
--override
can support all of the above patterns in an unopinionated way depending on how Mops and other package managers choose to pass the flags in thesources
command.Progress:
.
)--override
moc.js
configuration logic