Repository navigation
feat: modular (ddd) implementation - #4
Open
protibimbok wants to merge 5 commits into
Open
protibimbok wants to merge 5 commits into
protibimbok wants to merge 5 commits into
Conversation
vite:inputs gains "modules": [{name, path, entries, aliases}], every
path
relative to the project root, so goravel-vite-plugin can build module
entries, add the @<name> aliases and watch module directories. Without a
registry (legacy Boot) the list is empty.
- Entries come from ProvidesViteEntries; a module without any is still
listed, the plugin needs its path.
- Aliases come from ProvidesViteAlias. A key must look like @<name> and
its
target must stay inside the module (ModularViteAliasInvalid); a key
used
by two modules, or equal to another module's implicit @<name>, fails
with
ModularViteAliasDuplicate. A module may redefine its own @<name>.
- A third-party module whose published copy is missing, differs from the
linked version or is not owned by modular:publish fails the command
(ModularModuleNotPublished, ModularModulePublishStale,
ModularPublishTargetNotOwned), so Vite never builds without its
sources
or with old ones.
NewInputsCommand takes the module registry as a fourth argument.
Entries and assets may be written through a Vite alias, in templates and
in
Go: {{ vite "@/app.js" }}, {{ vite "@blog/app.js" }},
{{ viteAsset "@blog/../assets/logo.svg" }}.
goravel-vite-plugin owns the alias table and hands it over in the two
files
the framework already reads: the manifest, under the reserved key
"goravel:aliases", and the hot file, which becomes
{"url": "...", "aliases": {...}}. A hot file holding a bare URL still
works,
without aliases.
Tags, Asset and Content strip the leading slash, replace the longest
alias
matching at a path boundary (ViteAliasNotFound when none does), then
clean
the path and refuse one that leaves the project
(ViteEntryOutsideProject).
Leaving the alias directory while staying inside the project is allowed.
This was referenced Nov 13, 2026
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
Implements goravel/goravel#1030
This is the Vite side of goravel/framework#1613. The plugin builds the application's modules and passes its
@alias table to the framework, so templates can name entries through an alias:{{ vite "@/app.js" }} <!-- resources/js/app.js --> {{ vite "@blog/app.js" }} <!-- modules/blog/resources/js/app.js --> {{ viteAsset "@/../images/logo.svg" }} <!-- resources/images/logo.svg -->Modules
artisan vite:inputsnow reports the application's modules:For each module, the plugin:
entries(ViteEntries()), even if no view references them;@<name>to<path>/resources/jswhen that directory exists;ViteAliases()). A module can replace its own@<name>this way;refresh: true, also watches<path>/resources/views,<path>/routesand<path>/langwhen they exist. Ifrefreshis set to anything else, it is used as given.An alias with the same name in the user's
resolve.aliastakes precedence over a module's.validateInputsaccepts the new optionalmoduleskey, and output without it (from a framework that has no modules) works as before.Alias table handed to the framework (
src/aliases.ts)collectAliasescollects everyresolve.aliaswhose name is a string starting with@and whose replacement is a directory inside the project. That includes the plugin's own@and the user's. Patterns,node_modulesand directories outside the project are left out. When two aliases share a name, the first one wins, as in Vite.writeBundleadds the table to the manifest under the reserved key"goravel:aliases". No chunk can use that key because it contains a colon. SSR builds and builds withmanifest: falseare skipped.{"url": "http://localhost:5173", "aliases": {"@": "resources/js"}}, instead of the bare URL.resolveEntryresolves discovered inputs and assets the same way the framework does. It strips the leading slash, replaces the longest alias that matches at a path boundary (so@never captures@blog/…), and cleans.and... That way, an entry written two different ways is built only once, and the manifest keys match what the framework looks up. If no alias matches an@entry, or a path leaves the project, the build fails with a clear error.collectAliases,resolveAliasandresolveEntryare exported for tools that build thediscoveredoption themselves.Other
packageManageris pinned topnpm@12.18.0exactly, andpnpm-lock.yamlis updated to match.The hot file format changed from a bare URL to JSON. A framework release that includes goravel/framework#1613 reads both formats. An older framework would treat the JSON line as a URL, so this plugin version requires that framework release.
✅ Checks