-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Avoid importing vite in db utils #10946
Conversation
🦋 Changeset detectedLatest commit: 477c330 The changes in this PR will be included in the next version bump. 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 |
@@ -1,8 +1,12 @@ | |||
export { defineDbIntegration } from './core/utils.js'; | |||
import type { AstroIntegration } from 'astro'; | |||
import { tableSchema } from './core/schemas.js'; |
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.
This is still importing from core/schemas.js
which imports core/utils.js
which imports vite.
The rule is that runtime
should not import inside in core
. I don't know if this problem is solvable in this way.
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.
core/schemas
no longer imports Vite — I removed/refactored that.
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.
Yeah, I see that now, but this could easily be broken by a new PR that does need something else from utils. We try to stick with the rule that runtime code only imports runtime code and not core, to prevent mistakes.
@@ -4,7 +4,6 @@ import { type ZodTypeDef, z } from 'zod'; | |||
import { SERIALIZED_SQL_KEY, type SerializedSQL } from '../runtime/types.js'; | |||
import { errorMap } from './integration/error-map.js'; | |||
import type { NumberColumn, TextColumn } from './types.js'; | |||
import { mapObject } from './utils.js'; |
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.
core/utils
imports Vite so we want to avoid importing it — moved mapObject
inline into this file as it is only used here
export function defineDbIntegration(integration: AstroDbIntegration): AstroIntegration { | ||
return integration; | ||
} |
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.
Moved this straight to the user-facing utils library to avoid importing it from here where Vite is also imported
Changes
@astrojs/db/utils
Testing
Docs
n/a — bug fix