This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
Provide package.json fields so we can defer requiring packages' main modules - #9687
Merged
Merged
Conversation
Contributor
|
Great. We've needed this for a very long time. Some thoughts on the key names.
|
maxbrunsfeld
force-pushed
the
mb-deprecate-load-time-package-code
branch
from
November 19, 2015 22:12
8c3b782 to
a0a402c
Compare
Contributor
Author
😭 D'oh; of course. Updated. @nathansobo How do you think the view providers should work? I was thinking we could have a simple array of view providers functions that will always be called, but should return |
Closed
maxbrunsfeld
force-pushed
the
mb-deprecate-load-time-package-code
branch
from
November 23, 2015 23:53
e09b3fb to
5f1947e
Compare
Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Nathan Sobo <[email protected]>
Signed-off-by: Nathan Sobo <[email protected]>
…ime-package-code Conflicts: package.json
maxbrunsfeld
pushed a commit
that referenced
this pull request
Nov 30, 2015
Provide package.json fields so we can defer requiring packages' main modules
This was referenced Feb 10, 2016
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The Problem
In order to interoperate with the deserialization of the Atom workspace, there are some APIs that packages have to call as soon as they are loaded (as opposed to inside of their
activatemethod):atom.views.addViewProvideratom.deserializers.addThis forces Atom to load all packages' main modules at an early point in startup, even though many packages can be activated lazily. This allows packages to affect the app even if they are disabled, and may reduce our ability to optimize startup time.
The Proposed API Change
This PR will add 3 new optional fields to packages'
package.jsonfiles:configSchema- an object specifying the package's config schemadeserializers- an object whose keys are deserializer names, and whose values are paths to files that export deserialization functionsviewProviders- an array whose values are paths to files that export view-providing functions. These will need to work a little bit differently than normal view providers, because they can't be specified in relation to a particular model constructor. Maybe they will just be functions that returnnullif they do not apply to the given model.It will also add a deprecation warning when packages accesses the
atomglobal at load time.Changes to Package Loading
When packages use the new
package.jsonfields, we can defer loading any of their code until it is used, because we can know that there is no reason for them to run code at load time.deserializeis called with one of the specified deserializer names.Once the deprecation period is over, we can use this approach for all packages.
Todo
configSchema,viewProviders, ordeserializers, don't load its main module until it is activated./cc @nathansobo