Fix @import and @disable not seeing values from local env files#507
Merged
theoephraim merged 7 commits intomainfrom Mar 30, 2026
Merged
Fix @import and @disable not seeing values from local env files#507theoephraim merged 7 commits intomainfrom
theoephraim merged 7 commits intomainfrom
Conversation
…files Previously, import conditions (enabled=eq($VAR, ...)) and imported file @disable decorators were evaluated during .env.schema's initialization, before .env, .env.local, and env-specific files were loaded. Variables set in those files were invisible to early resolution. The fix separates finishInit() (parsing, @disable, config item registration, @currentEnv) from _processImports() (import processing). DirectoryDataSource now loads all auto-loaded files first, then processes imports in a second pass once all values are available. For non-directory usage (addChild, standalone root), both steps run immediately as before. Also adds early resolution of @disable decorator dependencies, which was previously only done for @import enabled conditions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 0bd0d4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
If a config item was already resolved during early initialization (for @currentEnv, @import enabled, or @disable conditions), a later data source redefining it would silently contradict the decision already made. Now this produces a schema error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only error when a later file sets a different value for an early-resolved item. No error when the file sets the same value, adds only decorators (no value), or defines unrelated items. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
philmillman
approved these changes
Mar 30, 2026
Member
philmillman
left a comment
There was a problem hiding this comment.
LGTM - test cases will be helpful
…deduplicate child setup - Fix bug where env-specific files loaded after a deferred import sets @currentEnv would never have their own imports processed - Extract shared child-setup logic into _initChild() to deduplicate addChild() and _addChildWithoutImports() - Fix misleading comment in setRootDataSource Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Loop over VALUE_SOURCE_FILES array to generate @import enabled and @disable tests for each file type (.env, .env.local, .env.dev, .env.dev.local) instead of repeating the test body 4 times. Always include @currentEnv setup to keep the schema helper simple. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
514d8b6 to
9955b17
Compare
Covers the case where @currentEnv is set by an imported file and the resulting env-specific file (.env.dev) itself has an @import that needs to be processed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
@import(enabled=eq($VAR, ...))and@disable(not(eq($VAR, ...)))on imported files could not see values from.env,.env.local,.env.ENV, or.env.ENV.local— only the.env.schemadefault was visible during early resolutionfinishInit()(parsing, config item registration,@currentEnv) from_processImports()(import processing).DirectoryDataSourcenow loads all auto-loaded files first, then processes imports in a second pass once all values are available@disabledecorator dependencies, which was previously only done for@importenabled conditionsTest plan
early-resolve-order.test.ts:@import(enabled=...)with values from.env,.env.local,.env.ENV,.env.ENV.local+ negative case@importin.env.ENVenabled by.env.ENV.local+ negative case@disable(...)with values from.env,.env.local,.env.ENV,.env.ENV.local+ negative case@currentEnvitem,@import enableddep, or@disabledep with a different value🤖 Generated with Claude Code