Azarox
Azarox2w ago

Multiple main in bundle relative path for preview

Hello, I tried using the beta feature bundle relative paths for preview. I looked at the code that was bundled in the preview, and if multiple functions/variables have the same name, it changes them to function1, function2, etc. The same applies to the main functions. But I think the main function of the script we want to execute might become main1/main2, and therefore the parameters are no longer correct. The main() function should always be the main function of the current script ?
5 Replies
Azarox
Azarox2w ago
I have this "bug" when i import other scripts contains main() function
rubenf
rubenf2w ago
we're talking about the vscode preview right ?
Azarox
Azarox2w ago
yes
rubenf
rubenf7d ago
Ok if you have a minimal reproduction that would be helpful if you can just share 2 scripts at precise path that would be sufficient we are using esbuild under the hood I wasn't able to reproduce with a minimal example
Azarox
Azarox7d ago
Sorry for the response time @rubenf , i have try with a minimal example: i can reproduce the bug in this case: script1.ts:
import * as wmill from 'windmill-client'
import { main as script2 } from './script2.ts'
import z from 'zod'

export function main(data) {
console.log(data)
console.log('script1')
}
import * as wmill from 'windmill-client'
import { main as script2 } from './script2.ts'
import z from 'zod'

export function main(data) {
console.log(data)
console.log('script1')
}
script2.ts:
import * as wmill from 'windmill-client'
import z from 'zod'

export async function main(data) {
console.log('script2', data)
}
import * as wmill from 'windmill-client'
import z from 'zod'

export async function main(data) {
console.log('script2', data)
}
i want to execute script1.ts, if i execute it with any data the console.log(data) result will be undefined, but if i comment this line: import { main as script2 } from './script2.ts' the console.log(data) will work correctly