-
Notifications
You must be signed in to change notification settings - Fork 1
Develop #101
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
Develop #101
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "node": { | ||
| "nodeVersion": "24" | ||
| "nodeVersion": "20" | ||
| }, | ||
| "$schema": "./node_modules/convex/schemas/convex.schema.json" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| import { mastraStorage } from '@mastra/convex/server' | ||
| import { mastraStorage } from '@mastra/convex/server'; | ||
|
|
||
| export const handle = mastraStorage | ||
| export const handle = mastraStorage; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import createMDX from '@next/mdx' | ||
| import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin' | ||
| import type { NextConfig } from 'next' | ||
| import type { Configuration } from 'webpack' | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'], | ||
|
|
@@ -38,7 +39,7 @@ const nextConfig: NextConfig = { | |
| typedRoutes: false, | ||
| reactStrictMode: true, | ||
| distDir: '.next', | ||
| webpack: (config, { isServer }) => { | ||
| webpack: (config: Configuration, { isServer }) => { | ||
| if (!isServer) { | ||
| config.plugins = config.plugins ?? [] | ||
| config.plugins.push( | ||
|
|
@@ -52,10 +53,55 @@ const nextConfig: NextConfig = { | |
| ], | ||
| }) | ||
| ) | ||
|
|
||
| // Sanitize resolve.alias so values are serializable for Turbopack/worker cloning | ||
| // Ensure resolve exists and normalize alias values to strings/arrays of strings | ||
| const existingResolve = config.resolve ?? {} | ||
| const aliasObj = (existingResolve as unknown as Record<string, unknown>).alias ?? {} | ||
| if (typeof aliasObj === 'object' && aliasObj !== null) { | ||
| const normalized: Record<string, string | string[]> = {} | ||
| for (const [k, v] of Object.entries(aliasObj as Record<string, unknown>)) { | ||
| if (Array.isArray(v)) { | ||
| normalized[k] = v.map((x) => String(x)) | ||
| } else if (typeof v === 'object' && v !== null) { | ||
| // For objects, stringify to avoid '[object Object]' implicit string coercion | ||
| try { | ||
| normalized[k] = JSON.stringify(v) | ||
| } catch { | ||
| normalized[k] = '' | ||
| } | ||
| } else if (typeof v === 'function') { | ||
| // For functions, prefer the function name to avoid serializing the entire function | ||
| // Narrow to an object with an optional name property to avoid using the broad Function type | ||
| const fnName = (v as { name?: string })?.name ?? '' | ||
| normalized[k] = fnName | ||
| } else if (v === null || v === undefined) { | ||
| // Keep null/undefined normalized to an empty string | ||
| normalized[k] = '' | ||
| } else { | ||
| // At this point, expect primitives (string/number/boolean/symbol/bigint). | ||
| // Guard against objects to avoid default Object stringification '[object Object]'. | ||
| const t = typeof v | ||
| if (t === 'string' || t === 'number' || t === 'boolean' || t === 'symbol' || t === 'bigint') { | ||
| // Narrow the type for the linter to avoid base-to-string coercion warnings | ||
| normalized[k] = String(v as string | number | boolean | symbol | bigint) | ||
| } else { | ||
| // Fallback for unexpected non-serializable values | ||
| try { | ||
| normalized[k] = JSON.stringify(v) | ||
| } catch { | ||
| normalized[k] = '' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| config.resolve = { ...existingResolve, alias: normalized } as Configuration['resolve'] | ||
| } | ||
|
Comment on lines
+56
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alias normalization may break legitimate webpack alias functionality. The sanitization logic converts all alias values to strings, but this approach has several issues:
Consider a more targeted approach that only removes truly non-serializable values while preserving valid string/path aliases: 💡 Suggested safer approach if (typeof aliasObj === 'object' && aliasObj !== null) {
- const normalized: Record<string, string | string[]> = {}
+ const normalized: Record<string, string | string[] | false> = {}
for (const [k, v] of Object.entries(aliasObj as Record<string, unknown>)) {
if (Array.isArray(v)) {
- normalized[k] = v.map((x) => String(x))
+ // Only include if all elements are strings
+ if (v.every((x) => typeof x === 'string')) {
+ normalized[k] = v as string[]
+ }
+ // Skip non-string arrays (non-serializable)
- } else if (typeof v === 'object' && v !== null) {
- // For objects, stringify to avoid '[object Object]' implicit string coercion
- try {
- normalized[k] = JSON.stringify(v)
- } catch {
- normalized[k] = ''
- }
- } else if (typeof v === 'function') {
- // For functions, prefer the function name to avoid serializing the entire function
- // Narrow to an object with an optional name property to avoid using the broad Function type
- const fnName = (v as { name?: string })?.name ?? ''
- normalized[k] = fnName
- } else if (v === null || v === undefined) {
- // Keep null/undefined normalized to an empty string
- normalized[k] = ''
- } else {
- // At this point, expect primitives (string/number/boolean/symbol/bigint).
- // Guard against objects to avoid default Object stringification '[object Object]'.
- const t = typeof v
- if (t === 'string' || t === 'number' || t === 'boolean' || t === 'symbol' || t === 'bigint') {
- // Narrow the type for the linter to avoid base-to-string coercion warnings
- normalized[k] = String(v as string | number | boolean | symbol | bigint)
- } else {
- // Fallback for unexpected non-serializable values
- try {
- normalized[k] = JSON.stringify(v)
- } catch {
- normalized[k] = ''
- }
- }
+ } else if (typeof v === 'string') {
+ normalized[k] = v
+ } else if (v === false) {
+ // `false` is valid in webpack to ignore a module
+ normalized[k] = false
}
+ // Skip functions, objects, and other non-serializable values
+ // Log warning for skipped aliases in development
}
config.resolve = { ...existingResolve, alias: normalized } as Configuration['resolve']
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| return config | ||
| }, | ||
|
|
||
| typescript: { | ||
| ignoreBuildErrors: true, | ||
| tsconfigPath: './tsconfig.json', | ||
|
|
@@ -92,7 +138,7 @@ const nextConfig: NextConfig = { | |
| // optimizeCss: true, | ||
| esmExternals: true, | ||
| scrollRestoration: true, | ||
| // cpus: 16, | ||
| // cpus: 16, | ||
| // cssChunking: true, | ||
| // craCompat: true, | ||
| // validateRSCRequestHeaders: true, | ||
|
|
||
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.
Normalizing function aliases to their function name string may break webpack resolution. Function values in webpack aliases typically need special handling, and converting them to strings (especially empty strings when name is unavailable) could cause module resolution failures.