-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: environment api #16129
Merged
Merged
feat: environment api #16129
Changes from 9 commits
Commits
Show all changes
118 commits
Select commit
Hold shift + click to select a range
83068fe
feat: separate module graphs per environment
patak-dev 5f5e0ec
feat: abstract moduleGraph into ModuleExecutionEnvironment
patak-dev 281cf97
fix: call updateModules for each environmnet
patak-dev 4808b27
chore: rename server environment to node environment
patak-dev 95ae29b
refactor: move safeModulesPath set to server
patak-dev d8ff12a
chore: rename module and error back to ssrModule and ssrError
patak-dev e966ba0
feat: add `hot` property to environments
sheremet-va 1fe63b1
chore: run prettier on environment file
sheremet-va 5e60d8a
refactor: hooks get an environment object instead of a string
patak-dev 30be775
fix: HotContext only gets ModuleExecutionEnvironment
patak-dev e30b858
refactor: options and environment are required when calling container…
patak-dev 03d3889
refactor: rework resolveId in ModuleExecutionEnvironment constructor
patak-dev fcebb7d
feat: environment.transformRequest
patak-dev f927702
chore: lint
patak-dev 88fea3b
feat: configureDevEnvironments + configureBuildEnvironments
patak-dev 60f7f2b
feat: vite runtime renamed to module runner (#16137)
sheremet-va 81abf6e
wip: environment config overrides
patak-dev a99475e
chore: merge main
patak-dev 92eccf9
chore: lint
patak-dev f4789a3
feat: builder config, runBuildTasks option
patak-dev 7f94c03
feat: server.runHmrTasks
patak-dev 9a600fe
chore: update
patak-dev b9ad620
chore: merge main
patak-dev 5c6b6ff
fix: type error
patak-dev 3e6216c
refactor: hooks to config for creating environments
patak-dev 6e71b24
refactor: ModuleExecutionEnvironment -> DevEnvironment
patak-dev 29f1b7b
refactor: environment id,type -> name + fixes
patak-dev cef1091
feat: inject environment in build hooks
patak-dev e03bac8
refactor: node -> ssr for default environment
patak-dev f1d660c
refactor: environments as array instead of map (#16193)
patak-dev ccf3de4
refactor: clientEnvironment instead of browserEnvironment (#16194)
patak-dev 27e6488
chore: merge main
patak-dev a7a06fe
refactor: environments array to plain object
patak-dev 8000e8e
refactor: isolate back compat module graph in its own module
patak-dev fee54ea
refactor: configEnvironment hook + enviroment config resolving
patak-dev d9ed857
test: fix after merge
patak-dev dbcc375
feat: support transport options to communicate between the environmen…
sheremet-va 3806fe6
fix: optimizeDeps backward compatibility layer
patak-dev 85ada0d
fix: partial backward compat for config.ssr
patak-dev c4f4dfb
fix: use "register" event for remote environment transport
sheremet-va a5ef42e
test: add test for worker transport
sheremet-va f29e95a
refactor: remove default nodeModuleRunner because it's not used anywhere
sheremet-va c9abcfc
refactor: rename createSsrEnvironment to createNodeEnvironment
sheremet-va 6040ab3
chore: fix lint
sheremet-va b4e46fe
chore: fix lint
sheremet-va fbe6361
feat: environment in hooks, context vs param (#16261)
patak-dev 36463d2
chore: merge main
patak-dev 52edfc9
refactor: pass down name to the environment factory
sheremet-va 9005841
refactor: allow custom connections in node module runner
sheremet-va 8785f4f
chore: lint
sheremet-va 96e825a
feat: --environment in CLI
patak-dev 5477972
refactor: use ssr environment module graph in ssrFixStacktrace
sheremet-va a160a1b
fix: add auto complete to server.environments
sheremet-va 31e1d3a
fix: fine-grained hmr
sheremet-va 72fe84e
refactor: rename ssrInvalidates to invalidates
sheremet-va c7e4da2
refactor: base environment.config + environment.options
patak-dev 2ddf28e
chore: update environment.server.config
patak-dev 681ccd4
fix: injectEnvironmentToHooks
patak-dev a1d385c
fix: injectEnvironmentInContext
patak-dev c1fc111
refactor: buildEnvironments + hmrEnvironments
patak-dev 3d37ac1
feat(hmr): call `hotUpdate` hook with file create/delete (#16249)
sapphi-red 6f9467e
chore: merge main
patak-dev a5c7e4f
test(environment): add environment playground (#16299)
hi-ogawa ca0ecf9
test: skip hmt ssr test for now
sheremet-va a0b7edb
refactor: rename "hmrEnvironments" to "hotUpdateEnvironments"
sheremet-va 4986641
test: fix windows test
sheremet-va 41dcca1
chore: merge main
patak-dev fb9365c
fix: resolve.externalConditions
patak-dev beb40ef
fix: missing externalConditions back compat
patak-dev ef8c9b9
feat: build.ssrEmitAssets -> build.emitAssets
patak-dev a183a0f
refactor: remove environment name from the hmr context
sheremet-va 9cfa916
refactor: move transport to properties
sheremet-va dd6332e
feat: environment aware createResolver and resolvePlugin
patak-dev f1dcd2c
feat: environment aware createIdResolver
patak-dev 0bec1b9
feat: environment id resolver for css plugin
patak-dev a7e52aa
feat: environment aware depsOptimizer
patak-dev 5bd8e95
refactor: ssrConfig.optimizeDeps.include/exclude
patak-dev 1a7d290
feat: ssr.target -> environment.webCompatible
patak-dev 2a0b524
feat: ssr.external/noExternal -> resolve.external/noExternal
patak-dev f96f682
release: v6.0.0-alpha.0
patak-dev 3a27870
docs: fix capitalization typos (#16309)
jay-es 67a74f8
fix: csp nonce injection when no closing tag (#16281) (#16282)
gregtwallace b39a7ed
ci: run lint in node 20 (#16338)
sapphi-red 833dabf
chore: merge
sapphi-red a88d572
chore(deps): update tj-actions/changed-files action to v44 (#16326)
renovate[bot] c7efec4
chore(deps): update all non-major dependencies (#16325)
renovate[bot] 9699ba3
fix: fix sourcemap when using object as `define` value (#15805)
hi-ogawa 6c5536b
fix: do not access document in `/@vite/client` when not defined (#16318)
keyding dfce45b
chore: `pnpm audit --fix` (#16346)
sapphi-red bcac048
chore: merge
sapphi-red 8d08db4
ci: run publish in node 20 (#16348)
sapphi-red a9bf430
perf: reduce size of injected __vite__mapDeps code (#16184)
panstromek f61d8b1
perf(css): only replace empty chunk if imported (#16349)
bluwy 5f3c44f
chore: merge main
patak-dev 8621c3f
fix(environment): use `environments.client.build.outDir` for preview …
hi-ogawa 27371dc
chore: remove ssrConfig
patak-dev d91714b
refactor: isFileServingAllowed load fallback for SSR
patak-dev ea1c7eb
refactor: environment.dev.recoverable
patak-dev 0ea8be9
chore: remove ssr.target use
patak-dev 3ba9214
feat: dedupe/preserveSymlinks
patak-dev 70731ce
refactor: lib options
patak-dev d15a157
feat: async createEnvironment
patak-dev f10561b
chore: merge main
patak-dev bdf13bb
fix: package types
patak-dev 7254175
release: v6.0.0-alpha.1
patak-dev 1f644d0
feat: rework more ssr.target webworker branches
patak-dev 9f9a716
feat: environment aware define
patak-dev 4cd3183
chore: merge main
patak-dev 46c8910
chore: update
patak-dev 9c5321b
release: v6.0.0-alpha.2
patak-dev 84299f3
feat: environment.dev.warmup
patak-dev 59b995e
refactor: proxy environment logger, remove hardcoded `[vite]` from hm…
sheremet-va 52a71e6
refactor: environments have colors in the logger, update logger.info …
sheremet-va ae1798f
chore: rename runner to evaluator in serverModuleRunner
sheremet-va 5b57f63
feat: deprecate ssrLoadModule (#16431)
sheremet-va b4fdfaf
feat: keep url queries in ssr mode (#16400)
sheremet-va 319b8e0
feat: decouple DevEnvironment and server (#16460)
patak-dev 635e6d5
chore: merge main
patak-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// We are using command: 'serve' | 'build' to aling with the command flag passed to hooks. | ||
// It would be better if we would use 'dev' here but can tackle that if we managed to modify | ||
// command at the hooks level. There could also be Preview environments later on. | ||
|
||
export class Environment { | ||
id: string | ||
type: string | ||
constructor( | ||
id: string, | ||
options: { | ||
type: string | ||
}, | ||
) { | ||
this.id = id | ||
this.type = options.type | ||
} | ||
} | ||
|
||
export class BuildEnvironment extends Environment { | ||
command = 'build' as const | ||
constructor(id: string, options: { type: string }) { | ||
super(id, options) | ||
} | ||
} |
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 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 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 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 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 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 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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we guarantee it exists somehow? (non undefined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that during scan, we didn't pass the moduleGraph. See here
vite/packages/vite/src/node/optimizer/scan.ts
Line 212 in d2839bc
So I didn't pass the environment either. I thought that it may make the scan slower if we need to update info in a module graph that we are going to throw away. But I think it is wrong that we don't pass an environment, more once we will have environment specific config. I'll check what needs to be done here. I think we only need the plugins for
resolveId
that shouldn't mess with the moduleGraph, so maybe we can create a new temporal browser environment with a new module graph and pass that. I'll check this out, it would be a lot better if there is always an environment defined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if there isn't some internalish use cases of these hooks in the ecosystem, but for now, core works with
options
andenvironment
being required for hooks. See e30b858I fixed some issues were I missed passing the environment, so even if we revert, it was worth it. We currently have a design issue because an environment needs a
resolveId
function when it is created, that should be implemented ascontainer.resolveId(id, undefined, { environment })
. I'll rework this next so we can simplify the code. Edit: done in 03d3889There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we'll need to relax the types. See failing test for Vitest. We could leave them as is for a bit more if they help us work with this draft though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already moved back to optional
options
andenvironment
. If not, we were forced to have a newGlobalEnvironment
that would be used when we don't have a server available (in the plugin containers created during config resolution for example).Still, this was quite helpful to identify issues. And things looks better after fcebb7d