Open jonasfunk opened 9 months ago
Thanks for reporting this issue. I was able to reproduce this and already found the issue. A fix will be included the next alpha release.
@jonasfunk This should be fixed in the latest 2.0.0-alpha.10.
Updated to the latest version.
I have a simple ts alloy app, that opens a window. This worked with 2.0.0-alpha.9
, but with 2.0.0-alpha.10
I get this error:
[ERROR] /@fs/usr/local/lib/node_modules/alloy/Alloy/template/lib/alloy.js:284
[ERROR] (null)
[ERROR] ^
[ERROR] TypeError: Object is not a constructor (evaluating 'new (require(__vite__injectQuery("/alloy/controllers/" + name, "import")))(args)')
[ERROR] at (/@fs/usr/local/lib/node_modules/alloy/Alloy/template/lib/alloy.js:284:84)
[ERROR] at (/app:27:40)
[ERROR] at load (/ti.kernel.js:634:24)
[ERROR] at liveViewRequire (/_liveview.bootstrap.js:3292:20)
[ERROR] at (/ti.main.js:12919:10)
[ERROR] at doLoad (/ti.main.js:12885:15)
[ERROR]
[ERROR] Foundation 0x0000000180dca15c _NSDescriptionWithLocaleFunc + 76
[ERROR] CoreFoundation 0x00000001803ed380 __CFStringAppendFormatCore + 10680
[ERROR] CoreFoundation 0x00000001803ee0e4 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 180
[ERROR] CoreFoundation 0x00000001803ee024 _CFStringCreateWithFormatAndArgumentsAux2 + 40
[ERROR] TitaniumKit 0x0000000104d422a4 TiLogMessage + 52
[ERROR] TitaniumKit 0x0000000104d719ac -[TiExceptionHandler reportScriptError:] + 60
[ERROR] JavaScriptCore 0x0000000109b06120 -[JSContext(Internal) valueFromNotifyException:] + 20
[ERROR] JavaScriptCore 0x0000000109b0c5d4 -[JSValue callWithArguments:] + 456
[ERROR] TitaniumKit 0x0000000104d41c9c -[KrollTimerTarget timerFired:] + 44
[ERROR] Foundation 0x0000000180dd7f30 __NSFireTimer + 56
[ERROR] CoreFoundation 0x00000001803c6d9c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
[ERROR] CoreFoundation 0x00000001803c6a58 __CFRunLoopDoTimer + 948
[ERROR] CoreFoundation 0x00000001803c60f4 __CFRunLoopDoTimers + 284
[ERROR] CoreFoundation 0x00000001803c0840 __CFRunLoopRun + 1796
[ERROR] CoreFoundation 0x00000001803bfd28 CFRunLoopRunSpecific + 572
[ERROR] GraphicsServices 0x000000018986ebc0 GSEventRunModal + 160
[ERROR] UIKitCore 0x0000000119d9ffdc -[UIApplication _run] + 868
[ERROR] UIKitCore 0x0000000119da3c54 UIApplicationMain + 124
[ERROR] tsliveview-alpha 0x0000000104780ec0 main + 848
[ERROR] dyld 0x0000000104cad558 start_sim + 20
@jonasfunk I'm currently working on a fix for this and i'm testing some examples. Do you have all your exports as ES module exports? Or can it happen that you have a CJS module.exports
or exports
mixed within? Or some files use ES export
and others CJS module.exports
? Because right now it would be pretty complex to support that. In the current liveview and Alloy build we use Babel to be able to transform such mixed cases. But Vite assumes valid ES modules and uses esbuild, so things break with combinations like that.
So it can either be have everything as ES exports, or everything as CJS exports. This could be configurable per project.
@janvennemann I've attached the project I'm testing with.
Noticed this is displayed when building:
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
Don't know if that has any impact on anything, but would just mention it :)
tsliveview-alpha.zip
Noticed this is displayed when building:
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
Don't know if that has any impact on anything, but would just mention it :)
Yeah that comes from the recent upgrade to Vite 5 but it doens't impact anything build related. We need to change the way we load Vite in Liveview for it to go away, which will likely happen in one of the next updates ;)
@janvennemann Noticed that you uploaded a new release. Is esm support fixed with that? 🙂
@janvennemann Noticed that you uploaded a new release. Is esm support fixed with that? 🙂
Unfortunately no, not yet. That release contained some fixes for stuff that i broke while trying to make ES Module exports work. I have an idea how to solve it, but i need a way to control the desired export Synatx per project i think. I'll keep you updated until i have this sorted out.
Any progress on this issue (not pushy, just curious 🙂) ?
@janvennemann Can you please schedule this for May? Thank you!
@janvennemann Can you please schedule this for May? Thank you!
Is this one in progress 🙂?
I'm trying to export a function from a
controller.ts
, but using ES Module style doesn't work:Works with lib files.