Skip to content

Commit 18390d1

Browse files
committed
fix: loader fix attempt
1 parent 3841631 commit 18390d1

File tree

2 files changed

+45
-64
lines changed

2 files changed

+45
-64
lines changed

src/build/loader.ts

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,14 @@ async function cacheJSXLoad(url, cacheDir = "") {
4747
}
4848

4949
export async function JSXLoad(url) {
50-
const filePath = fileURLToPath(url)
51-
const isTsxOrJsx = filePath.endsWith('.tsx') || filePath.endsWith('.jsx')
52-
5350
const result = await build({
54-
entryPoints: [filePath],
51+
entryPoints: [fileURLToPath(url)],
5552
bundle: true,
5653
platform: "node",
5754
format: "esm",
5855
packages: "external",
5956
charset: "utf8",
6057
write: false,
61-
loader: isTsxOrJsx ? {
62-
'.tsx': 'tsx',
63-
'.jsx': 'jsx'
64-
} : undefined,
6558
tsconfigRaw: {
6659
compilerOptions: {
6760
target: "esnext",
@@ -74,6 +67,7 @@ export async function JSXLoad(url) {
7467
allowSyntheticDefaultImports: true,
7568
skipLibCheck: true,
7669
sourceMap: true,
70+
// TODO: Load jsx files?
7771
jsx: "react-jsx",
7872
},
7973
},
@@ -96,27 +90,14 @@ export async function NoLoad(url) {
9690

9791
export async function load(url, context, defaultLoad) {
9892
const isTerminal = process.env?.KIT_TARGET === "terminal"
99-
100-
// Handle .tsx and .jsx files
10193
const urlPath = url.split('?')[0]
102-
if (urlPath.endsWith('.tsx') || urlPath.endsWith('.jsx')) {
103-
// Remove the .kit suffix and timestamp query
104-
const cleanUrl = url.replace(/\?.*\.kit$/, '')
105-
let cacheDir = ""
106-
if (!isTerminal) {
107-
cacheDir = resolve(
108-
dirname(fileURLToPath(cleanUrl)),
109-
".cache"
110-
)
111-
await ensureDir(cacheDir)
112-
}
113-
const transform = await cacheJSXLoad(cleanUrl, cacheDir)
114-
return transform
115-
}
11694

95+
// Handle TypeScript and TSX/JSX files
11796
if (
118-
url.endsWith(".kit") &&
119-
(url.includes(".ts?") || isTerminal)
97+
urlPath.endsWith('.ts') ||
98+
urlPath.endsWith('.tsx') ||
99+
urlPath.endsWith('.jsx') ||
100+
(url.endsWith(".kit") && isTerminal)
120101
) {
121102
let cacheDir = ""
122103
if (!isTerminal) {

src/target/terminal.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ global.kitPrompt = async (config: any) => {
8383
message: config.placeholder
8484
}
8585
let { prompt }: Enquirer = enquirer
86-
// TODO: Strip out enquirer autocomplete
87-
;(prompt as any).on('cancel', () => process.exit())
86+
// TODO: Strip out enquirer autocomplete
87+
; (prompt as any).on('cancel', () => process.exit())
8888

8989
let result = (await prompt(promptConfig)) as any
9090

@@ -97,13 +97,13 @@ global.arg = async (messageOrConfig = 'Input', choices) => {
9797
}
9898

9999
let firstArg = global.args.length ? global.args.shift() : null
100-
101-
// // Check if the argument is the special "__undefined__" marker
102-
// if (firstArg === "__undefined__") {
103-
// // Treat it as if no argument was provided - show the prompt
104-
// firstArg = null
105-
// }
106-
100+
101+
// Check if the argument is the special "__undefined__" marker
102+
if (firstArg === "__undefined__") {
103+
// Treat it as if no argument was provided - show the prompt
104+
firstArg = null
105+
}
106+
107107
if (firstArg) {
108108
let valid = true
109109
if (typeof messageOrConfig !== 'string' && (messageOrConfig as PromptConfig)?.validate) {
@@ -264,7 +264,7 @@ global.edit = async (filePath) => {
264264
if (global?.env?.KIT_TERMINAL_EDITOR === 'kit') {
265265
try {
266266
await exec(`~/.kit/kar ~/.kit/cli/edit.js '${filePath}'`)
267-
} catch (error) {}
267+
} catch (error) { }
268268
} else {
269269
await spawn(global.env.KIT_TERMINAL_EDITOR, [filePath], {
270270
stdio: 'inherit'
@@ -302,17 +302,17 @@ global.drop = async () => {
302302
global.exit()
303303
}
304304

305-
global.setChoices = async () => {}
306-
global.clearTabs = async () => {}
305+
global.setChoices = async () => { }
306+
global.clearTabs = async () => { }
307307

308-
global.setPanel = async (html, containerClasses = '') => {}
309-
global.setPreview = async (html, containerClasses = '') => {}
310-
global.setPanelContainer = async (html, containerClasses = '') => {}
308+
global.setPanel = async (html, containerClasses = '') => { }
309+
global.setPreview = async (html, containerClasses = '') => { }
310+
global.setPanelContainer = async (html, containerClasses = '') => { }
311311

312-
global.setIgnoreBlur = async (ignore) => {}
313-
global.setResize = async (resize) => {}
312+
global.setIgnoreBlur = async (ignore) => { }
313+
global.setResize = async (resize) => { }
314314

315-
global.setBounds = async (bounds: Partial<Rectangle>) => {}
315+
global.setBounds = async (bounds: Partial<Rectangle>) => { }
316316

317317
global.setDescription = (description: string) => {
318318
// console.log({ description })
@@ -321,7 +321,7 @@ global.setName = (name: string) => {
321321
// console.log({ name })
322322
}
323323

324-
global.setPauseResize = (pause: boolean) => {}
324+
global.setPauseResize = (pause: boolean) => { }
325325

326326
global.getScriptsState = () => {
327327
notSupported('getScriptsState')
@@ -344,8 +344,8 @@ global.submit = async (value: any) => {
344344
notSupported('submit')
345345
}
346346

347-
global.setLoading = (loading: boolean) => {}
348-
global.setRunning = (running: boolean) => {}
347+
global.setLoading = (loading: boolean) => { }
348+
global.setRunning = (running: boolean) => { }
349349

350350
global.copy = async (text) => {
351351
let c = await npm('clipboardy')
@@ -378,26 +378,26 @@ global.revealFile = async () => {
378378
notSupported('revealFile')
379379
return ''
380380
}
381-
;(global as any).clipboard = new Proxy(
382-
{},
383-
{
384-
get: (target, k: string) => {
385-
return () => {
386-
notSupported(`clipboard.${k}`)
381+
; (global as any).clipboard = new Proxy(
382+
{},
383+
{
384+
get: (target, k: string) => {
385+
return () => {
386+
notSupported(`clipboard.${k}`)
387+
}
387388
}
388389
}
389-
}
390-
)
391-
;(global as any).keyboard = new Proxy(
392-
{},
393-
{
394-
get: (target, k: string) => {
395-
return () => {
396-
notSupported(`keyboard.${k}`)
390+
)
391+
; (global as any).keyboard = new Proxy(
392+
{},
393+
{
394+
get: (target, k: string) => {
395+
return () => {
396+
notSupported(`keyboard.${k}`)
397+
}
397398
}
398399
}
399-
}
400-
)
400+
)
401401

402402
global.term = async (commandOrConfig) => {
403403
let defaultConfig = {
@@ -419,7 +419,7 @@ global.term = async (commandOrConfig) => {
419419
return result?.stdout || result?.stderr || ''
420420
}
421421

422-
global.mainScript = async () => {}
422+
global.mainScript = async () => { }
423423
global.sendWait = async () => {
424424
notSupportedDebug('sendWait')
425425
}

0 commit comments

Comments
 (0)