Add virtual path abstraction layer#9245
Merged
kubouch merged 24 commits intonushell:mainfrom May 23, 2023
Merged
Conversation
It was a dead code and there is a risk they wouldn't work with the new virtual file system.
Does not require NU_STD_VIRTUAL_PATH in the .nu files anymore.
Member
|
i have a drastic improvement with the startup time 😱 👀
|
Contributor
Author
|
Wow, that's a lot. I'll try to finish it so we can merge it. |
Contributor
Author
|
Startup times on my machine (Linux):
|
Member
|
after more attempts
and now the real meat 😏
very nice 👌 |
amtoine
added a commit
to amtoine/nushell
that referenced
this pull request
May 24, 2023
This should solve the merge conflicts in nushell#9253 introduced by nushell#9245.
amtoine
added a commit
to amtoine/nu-git-manager
that referenced
this pull request
May 26, 2023
related to nushell/nushell#9245
amtoine
added a commit
to amtoine/nupm
that referenced
this pull request
May 26, 2023
related to nushell/nushell#9245
Contributor
|
I've just added the ability to cross.stream to append Nushell modules to the stream. As you do, the modules are registered in the base Nushell engine's vfs. Then any handler etc running on cross.stream can Thanks @kubouch for adding this feature, which made that possible 🙏 |
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.
Description
Adds the possibility to embed "virtual" files and directories into Nushell so that loading them does not require real physical paths on the file system.
The primary use case is loading the standard library. First, all the stdlib files are loaded as virtual files in a made-up
NU_STDLIB_VIRTUAL_DIRdirectory:NU_STDLIB_VIRTUAL_DIR/std/mod.nu,NU_STDLIB_VIRTUAL_DIR/std/dirs.nu, etc. Then, when loading the stdlib, the parser's current working directory is set to the virtual directory. When parsing statements such asuse dirs.nu, the parser looks into the virtual directories and finds the path there without it being present in the file system.The virtual paths can be used in the future for other Nu code we might want to ship with Nushell, such as package manager.
One future use case for this could be "compiling" Nushell projects so that they can run on other machines without having to install their dependencies and requiring all source files to be on the file system. You could think of it as static linking.
Seems like loading stdlib from virtual paths improves the startup times by ~50 ms, too.
Limitations
sourceandsource-envcurrently load the virtual paths in the parser but they fail during evaluation. We'd need to add the support for virtual files to the engine innushell/crates/nu-engine/src/env.rs
Line 247 in db4b26c
User-Facing Changes
Faster stdlib loading
Tests + Formatting
After Submitting