06-08-2021 11:48
06-08-2021 11:48
In all my apps and watch faces when accessing file system I've always used import * as fs from 'fs' and it worked fine. However during the current development I encountered an error "App: Unhandled exception: TypeError: Expected a function". I pinpointed it to FS module. Turns out FS module returns an object named 'default' and now to access any method I need to specify it as fs.default (eg. fs.default.writeFileSync). I don't understand why it's happening. To be on a safe side I created a fail-safe to switch to the 'fs.default' object if fs is unavailable. I installed the watch face on my Ionic and it sure enough does select fs.default instead of good old fs. I'm really confused as in other apps it still works as API documentation specifies (all methods are directly on fs).
Has anyone seen this issue before?
06-08-2021 14:52
06-08-2021 14:52
I don't know what I'm talking about, but I think there might have been a recent change in the build process that is more stringent in the way that things are imported. It's possible that reverting to a previous SDK version might avoid the issue.
06-08-2021 14:59
06-08-2021 14:59
I'm actually using SDK 4.2.0... I did check the SDK 5 and it seems like that one supports both: 'fs' and 'fs.default'. Really strange behavior.