Skip to content

Commit 77bc544

Browse files
committed
less awaited imports
1 parent 388b3cf commit 77bc544

File tree

9 files changed

+78
-75
lines changed

9 files changed

+78
-75
lines changed

src/cta/lib/engine-handling/add-to-app-wrapper.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { resolve } from 'node:path'
2+
import {
3+
CONFIG_FILE,
4+
createDefaultEnvironment,
5+
createSerializedOptionsFromPersisted,
6+
readConfigFile,
7+
writeConfigFileToEnvironment,
8+
} from '@tanstack/cta-engine'
9+
210
import { TMP_TARGET_DIR } from '../constants'
311
import { cleanUpFileArray, cleanUpFiles } from './file-helpers'
412
import { getProjectPath } from './server-environment'
@@ -17,17 +25,9 @@ export async function addToAppWrapper(
1725
environmentFactory?: () => any
1826
}
1927
) {
20-
// Dynamically import CTA engine to prevent client bundling
21-
const {
22-
CONFIG_FILE,
23-
addToApp,
24-
createAppOptionsFromPersisted,
25-
createDefaultEnvironment,
26-
createSerializedOptionsFromPersisted,
27-
readConfigFile,
28-
recursivelyGatherFiles,
29-
writeConfigFileToEnvironment,
30-
} = await import('@tanstack/cta-engine')
28+
// Dynamically import only the heavy file operation stuff
29+
const { addToApp, createAppOptionsFromPersisted, recursivelyGatherFiles } =
30+
await import('@tanstack/cta-engine')
3131

3232
const projectPath = getProjectPath()
3333

src/cta/lib/engine-handling/create-app-wrapper.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import { resolve } from 'node:path'
2+
import {
3+
createDefaultEnvironment,
4+
finalizeAddOns,
5+
getFrameworkById,
6+
loadStarter,
7+
} from '@tanstack/cta-engine'
28

39
import { TMP_TARGET_DIR } from '../constants'
410

@@ -17,14 +23,8 @@ export async function createAppWrapper(
1723
environmentFactory?: () => any
1824
}
1925
) {
20-
// Dynamically import CTA engine to prevent client bundling
21-
const {
22-
createApp,
23-
createDefaultEnvironment,
24-
finalizeAddOns,
25-
getFrameworkById,
26-
loadStarter,
27-
} = await import('@tanstack/cta-engine')
26+
// Dynamically import only the heavy file operation stuff
27+
const { createApp } = await import('@tanstack/cta-engine')
2828

2929
// Ensure framework is registered
3030
ensureFrameworkRegistered()

src/cta/lib/engine-handling/generate-initial-payload.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { basename, resolve } from 'node:path'
2+
import {
3+
createSerializedOptionsFromPersisted,
4+
getAllAddOns,
5+
getFrameworkById,
6+
getRawRegistry,
7+
getRegistryAddOns,
8+
readConfigFile,
9+
} from '@tanstack/cta-engine'
210

311
import { ensureFrameworkRegistered } from './framework-registry'
412
import { cleanUpFiles } from './file-helpers'
@@ -29,16 +37,8 @@ function convertAddOnToAddOnInfo(addOn: any): AddOnInfo {
2937
}
3038

3139
export async function generateInitialPayload() {
32-
// Dynamically import CTA engine modules to prevent client bundling
33-
const {
34-
createSerializedOptionsFromPersisted,
35-
getAllAddOns,
36-
getFrameworkById,
37-
getRawRegistry,
38-
getRegistryAddOns,
39-
readConfigFile,
40-
recursivelyGatherFiles,
41-
} = await import('@tanstack/cta-engine')
40+
// Dynamically import only the heavy file operation stuff
41+
const { recursivelyGatherFiles } = await import('@tanstack/cta-engine')
4242

4343
// Ensure framework is registered
4444
ensureFrameworkRegistered()

src/forge/engine-handling/add-to-app-wrapper.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { resolve } from 'node:path'
2+
import {
3+
CONFIG_FILE,
4+
createDefaultEnvironment,
5+
createSerializedOptionsFromPersisted,
6+
readConfigFile,
7+
writeConfigFileToEnvironment,
8+
} from '@tanstack/cta-engine'
9+
210
import { TMP_TARGET_DIR } from '~/forge/constants'
311
import type { DryRunOutput } from '~/forge/types'
412
import { cleanUpFileArray, cleanUpFiles } from './file-helpers'
@@ -13,17 +21,12 @@ export async function addToAppWrapper(
1321
environmentFactory?: () => any
1422
}
1523
) {
16-
// Dynamically import CTA engine to prevent client bundling
24+
// Dynamically import only the heavy file operation stuff
1725
const {
18-
CONFIG_FILE,
1926
addToApp,
2027
createAppOptionsFromPersisted,
21-
createDefaultEnvironment,
2228
createMemoryEnvironment,
23-
createSerializedOptionsFromPersisted,
24-
readConfigFile,
2529
recursivelyGatherFiles,
26-
writeConfigFileToEnvironment,
2730
} = await import('@tanstack/cta-engine')
2831

2932
const projectPath = getProjectPath()

src/forge/engine-handling/create-app-wrapper.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { resolve } from 'node:path'
2+
import {
3+
createDefaultEnvironment,
4+
createMemoryEnvironment,
5+
finalizeAddOns,
6+
getFrameworkById,
7+
loadStarter,
8+
} from '@tanstack/cta-engine'
9+
210
import { TMP_TARGET_DIR } from '~/forge/constants'
311
import { ensureFrameworkRegistered } from './framework-registry'
412
import { cleanUpFileArray, cleanUpFiles } from './file-helpers'
@@ -12,15 +20,8 @@ export async function createAppWrapper(
1220
environmentFactory?: () => any
1321
}
1422
) {
15-
// Dynamically import CTA engine to prevent client bundling
16-
const {
17-
createApp,
18-
createDefaultEnvironment,
19-
createMemoryEnvironment,
20-
finalizeAddOns,
21-
getFrameworkById,
22-
loadStarter,
23-
} = await import('@tanstack/cta-engine')
23+
// Dynamically import only the heavy file operation stuff
24+
const { createApp } = await import('@tanstack/cta-engine')
2425

2526
// Ensure framework is registered
2627
ensureFrameworkRegistered()

src/forge/engine-handling/generate-initial-payload.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
import { basename, resolve } from 'node:path'
2+
import {
3+
createSerializedOptionsFromPersisted,
4+
getAllAddOns,
5+
getFrameworkById,
6+
getRawRegistry,
7+
getRegistryAddOns,
8+
readConfigFile,
9+
} from '@tanstack/cta-engine'
10+
211
import type { AddOnInfo } from '~/forge/types'
312
import { ensureFrameworkRegistered } from './framework-registry'
413
import { cleanUpFiles } from './file-helpers'
@@ -27,16 +36,8 @@ function convertAddOnToAddOnInfo(addOn: any): AddOnInfo {
2736
}
2837

2938
export async function generateInitialPayload() {
30-
// Dynamically import CTA engine modules to prevent client bundling
31-
const {
32-
createSerializedOptionsFromPersisted,
33-
getAllAddOns,
34-
getFrameworkById,
35-
getRawRegistry,
36-
getRegistryAddOns,
37-
readConfigFile,
38-
recursivelyGatherFiles,
39-
} = await import('@tanstack/cta-engine')
39+
// Dynamically import only the heavy file operation stuff
40+
const { recursivelyGatherFiles } = await import('@tanstack/cta-engine')
4041

4142
// Ensure framework is registered
4243
ensureFrameworkRegistered()

src/forge/tools.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import { dirname } from 'path'
77
import { api } from 'convex/_generated/api'
88
import type { Id } from 'convex/_generated/dataModel'
99

10+
import {
11+
createSerializedOptionsFromPersisted,
12+
getFrameworkById,
13+
getAllAddOns,
14+
createDefaultEnvironment,
15+
} from '@tanstack/cta-engine'
16+
1017
import { generateFileTree } from '~/forge/file-tree-generator'
1118
import type { DryRunOutput } from '~/forge/types'
1219
import { ensureFrameworkRegistered } from '~/forge/engine-handling/framework-registry'
@@ -35,14 +42,6 @@ function enforceStoredPath(path: string) {
3542
}
3643

3744
export const getTools = async (convex: ConvexHttpClient, projectId: string) => {
38-
// Dynamically import CTA engine modules to prevent client bundling
39-
const {
40-
createSerializedOptionsFromPersisted,
41-
getFrameworkById,
42-
getAllAddOns,
43-
createDefaultEnvironment,
44-
} = await import('@tanstack/cta-engine')
45-
4645
// Ensure framework is registered
4746
ensureFrameworkRegistered()
4847

src/routes/api/dry-run-create-app.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { z } from 'zod'
3+
import {
4+
finalizeAddOns,
5+
getFrameworkById,
6+
loadStarter,
7+
} from '@tanstack/cta-engine'
8+
39
import { ensureFrameworkRegistered } from '~/cta/lib/engine-handling/framework-registry'
410

511
const requestOptionsSchema = z.object({
@@ -16,14 +22,8 @@ export const Route = createFileRoute('/api/dry-run-create-app')({
1622
server: {
1723
handlers: {
1824
POST: async ({ request }) => {
19-
// Import server-only modules inside the handler to prevent client bundling
20-
const {
21-
createApp,
22-
finalizeAddOns,
23-
getFrameworkById,
24-
loadStarter,
25-
Starter,
26-
} = await import('@tanstack/cta-engine')
25+
// Dynamically import only the heavy file operation stuff
26+
const { createApp } = await import('@tanstack/cta-engine')
2727
const { createMemoryEnvironment } = await import(
2828
'~/cta/lib/engine-handling/memory-environment'
2929
)
@@ -56,7 +56,7 @@ export const Route = createFileRoute('/api/dry-run-create-app')({
5656
{ framework }
5757
)
5858

59-
let starter: Starter | undefined
59+
let starter: any | undefined
6060
const addOns: Array<string> = [...createAppOptions.chosenAddOns]
6161
if (createAppOptions.starter) {
6262
starter = await loadStarter(createAppOptions.starter)

src/routes/api/forge.new-project.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { ConvexHttpClient } from 'convex/browser'
3+
import { getFrameworkById, getAllAddOns } from '@tanstack/cta-engine'
4+
35
import { api } from 'convex/_generated/api'
46
import { ensureFrameworkRegistered } from '~/forge/engine-handling/framework-registry'
57

@@ -9,13 +11,10 @@ export const Route = createFileRoute('/api/forge/new-project')({
911
server: {
1012
handlers: {
1113
POST: async (ctx) => {
12-
// Import server-only modules inside the handler to prevent client bundling
14+
// Dynamically import only the heavy AI and file operation stuff
1315
const { anthropic } = await import('@ai-sdk/anthropic')
1416
const { openai } = await import('@ai-sdk/openai')
1517
const { generateText } = await import('ai')
16-
const { getFrameworkById, getAllAddOns } = await import(
17-
'@tanstack/cta-engine'
18-
)
1918
const { initialize } = await import(
2019
'~/forge/engine-handling/initialize'
2120
)

0 commit comments

Comments
 (0)