-
Notifications
You must be signed in to change notification settings - Fork 538
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
refactor: structure overhaul #2473
Merged
Merged
Conversation
This file contains 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
(this PR is likely making unsen regrssions as mentioned above and merge is intended to identify them end-to-end and fix in nightly channel progressively) |
This was referenced Jun 7, 2024
Closed
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.
This PR splits the Nitro codebase into logical scopes separated by subpath exports.
nitropack/cli
: Nitro CLI. Will be used for standalone zero dep CLI package in the futurenitropack/core
: Main utilities exposed for programmatic usage, dev and build + app (same asnitropack
for now)nitropack/runtime
: Core server runtime logic (see notes below)nitropack/types
: All types unified in a single place (see notes below)nitropack/config
: Config type helper (loader, defaults, and normalizers live in core)nitropack/kit
: Possibly reusable utilities for module and preset authoring as well as external integrationsnitropack/presets
: deployment presets (runtime, config, types) (refactor: overhaul presets structure #2446)nitropack/meta
: exposing current version (alternative topackage.json
imports - ca2282b)Note
This PR introduces lots of changes to the current 2.x codebase in order to make sure we can keep supporting Nitro 2.x for a longer term in parallel to Nitro 3.x. A lot of thoughts have been put in to make sure we don't intentionally break any common or documented usage. There is still a chance that some changes introduce regressions. We will keep investigating to find and resolve them as much as possible via Nitro nightly channel. If you spotted any, please feel free to open an issue and describe the case 🙏🏼
What happened to types?
Currently, types are split in several places from core, bundler, and runtime and exported from several places. Now they are unified and accessible from (type-only)
nitropack/types
subpath.Note
This change is likely break-in usages augmenting Nitro types from
"nitropack"
subpath. This will be addressed in a subsequent PR after better testing via a backward-compatible polyfill.What happened to the core?
Externally, almost nothing. Exactly the same exports are preserved for compatibility. Internally, some important major refactors happened:
core/config
nitro.ts
) split into scan utils and config resolversWhat happened to runtime?
One of the messy parts of the current code structure was runtime. It was:
#internal/nitro
or#internal/nitro/*
for importTo add to the complexity, the virtual files were ALSO exposed in the same
#internal/nitro/virtual
namespace.The new structure makes it much cleaner:
nitropack/runtime
: Exposing userland utils (same as auto imports)nitropack/runtime/internal/*
: Exposing internal utils. Users and frameworks should NEVER EVER use them they will be soon protected as well to prevent wrongly importing from this namespace this is because we need to improve nitro internal implementation without imposing breaking changes#nitro-internal-pollyfills
#nitro-internal-virtual/*
Since this PR is landing for Nitro 2.x, to avoid breaking changes in projects and frameworks that for any reason had to use
#internal/nitro
, there is a compatibility layer with minimal known usages (mainly from Nuxt codebase), they are maintained insrc/runtime/_compat
.What is the new kit?
The new
nitropack/kit
exports common but shared utils + define helpers. More will be added in the next stepsdefineNitroPreset
anddefineNitroModule
writeFile
,isDirectory
,prettyPath
,resolveNitroPath