fuse-open / fuselibs

Fuselibs is the Uno-libraries that provide the UI framework used in Fuse apps
https://npmjs.com/package/@fuse-open/fuselibs
MIT License
176 stars 72 forks source link

Models (in preview): Setting Model="App()" at the wrong time causes error #709

Open kristianhasselknippe opened 7 years ago

kristianhasselknippe commented 7 years ago

Tested on windows

App.zip

Steps to reproduce: 0: Add "**.js:FuseJS" to include in unoproj 1: Add the following to MainView.ux

<App>
    <Text Value="{foo}"/>
</App>

2: Add new file "App.js" 3: Add the following to App.js

export default class App {
    constructor() {
        this.foo = "Bar";
    }
}

4: Add the following to the App tag in MainView.ux

Model="App()"

5: Save, and observe the following error message

[Viewport]: Error: : Error message: Uncaught require(): module not found: App
File name: (model-script)
Line number: 4
Source line: var modelClass = require('App');
 in Fuse.Scripting.DiagnosticSubject<(model-script):4>

Rebuilding fixes the error, and also adding things in a different order (haven't found exactly which is correct yet) also makes it run fine.

Besides this causing an error, there are several things that could confuse users. We did not write var modelClass = require("App") ourselves, We are also using ES6, meaning we wouldn't have used require directly in our own code anyway. This is not something the user knows anything about: Fuse.Scripting.DiagnosticSubject<(model-script):4 (model-script) is not a file...

kristianhasselknippe commented 7 years ago

@sebbert when is the transpiler actually started (or what kind of event causes it to start)?