Skip to content
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

next/vite branch: Conditional module require fails #219

Open
jonasfunk opened this issue May 17, 2023 · 1 comment
Open

next/vite branch: Conditional module require fails #219

jonasfunk opened this issue May 17, 2023 · 1 comment
Labels

Comments

@jonasfunk
Copy link

On android we're fetching EXIF information via the module "fh.imagefactory"

if(OS_ANDROID){
   const fhImageFactory = require('fh.imagefactory');
 ...
}

This will on iOS result in
[vite] Internal server error: Failed to resolve require "fh.imagefactory" from "app/lib/utils.ts". Does the file exist?

@jonasfunk jonasfunk changed the title Conditional module require fails next/vite branch: Conditional module require fails May 17, 2023
@AhmedMSayed
Copy link

I have same issue with lib/crypto-js/crypto-js.js it works with old liveview

[INFO] Reachability Flag Status: -R ------- networkStatusForFlags
[INFO] [vite] connecting...
[INFO] Application started
[WARN] WebSocket option "perMessageDeflate" is currently not supported in Titanium.
3:06:31 PM [vite] Internal server error: Failed to resolve import "crypto-js" from "app/lib/utilitiesNew.js". Does the file exist?
Plugin: vite:import-analysis
File: /Users/Projects/myapp/app/lib/utilities.js:1:23
1 | import CryptoJS from 'crypto-js';
| ^
2 |
3 | class utilities {
at formatError (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44062:46)
at TransformContext.error (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44058:19)
at normalizeUrl (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41844:33)
at async file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41998:47
at async Promise.all (index 0)
at async TransformContext.transform (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:41914:13)
at async Object.transform (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44352:30)
at async loadAndTransform (file:///usr/local/lib/node_modules/liveview/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55026:29)
Failed to resolve import "crypto-js" from "app/lib/utilitiesNew.js". Does the file exist?
[ERROR] /ti.kernel.js:792
[ERROR] throw new Error(Requested module not found: ${request}); // TODO Set 'code' property to 'MODULE_NOT_FOUND' to match Node?
[ERROR] ^
[ERROR] : Requested module not found: /lib/utilitiesNew.js
[ERROR] at require (/ti.kernel.js:792:24)
[ERROR] at liveViewRequire (/_liveview.bootstrap.js:3300:40)
[ERROR] at (/app:21:45)
[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 0x0000000110c6715c _NSDescriptionWithLocaleFunc + 76
[ERROR] CoreFoundation 0x000000010d38c380 __CFStringAppendFormatCore + 10680
[ERROR] CoreFoundation 0x000000010d38d0e4 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 180
[ERROR] CoreFoundation 0x000000010d38d024 _CFStringCreateWithFormatAndArgumentsAux2 + 40
[ERROR] TitaniumKit 0x0000000106c066e4 TiLogMessage + 52
[ERROR] TitaniumKit 0x0000000106c35de8 -[TiExceptionHandler reportScriptError:] + 60
[ERROR] JavaScriptCore 0x0000000109bf6120 -[JSContext(Internal) valueFromNotifyException:] + 20
[ERROR] JavaScriptCore 0x0000000109bfc5d4 -[JSValue callWithArguments:] + 456
[ERROR] TitaniumKit 0x0000000106c060dc -[KrollTimerTarget timerFired:] + 44
[ERROR] Foundation 0x0000000110c74f30 __NSFireTimer + 56
[ERROR] CoreFoundation 0x000000010d365d9c CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28
[ERROR] CoreFoundation 0x000000010d365a58 __CFRunLoopDoTimer + 948
[ERROR] CoreFoundation 0x000000010d3650f4 __CFRunLoopDoTimers + 284
[ERROR] CoreFoundation 0x000000010d35f840 __CFRunLoopRun + 1796
[ERROR] CoreFoundation 0x000000010d35ed28 CFRunLoopRunSpecific + 572
[ERROR] GraphicsServices 0x000000011b7fbbc0 GSEventRunModal + 160
[ERROR] UIKitCore 0x0000000123193fdc -[UIApplication _run] + 868
[ERROR] UIKitCore 0x0000000123197c54 UIApplicationMain + 124
[ERROR] Onsite 2.0 0x00000001045bfc0c main + 856
[ERROR] dyld 0x00000001053cd558 start_sim + 20
[INFO] [vite] connected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants