Path issues, can't require files while import via JavaScript tag partially works.

Hi, I can’t seem to require('awesome') a file called awesome.js at the root of my project.

My .unoproj looks like this

{
  "RootNamespace":"",
  "Packages": [
  	"Fuse",
  	"FuseJS",
  	"Fuse.BasicTheme"
  ],
  "Includes": [
    "*"
  ]
}

This works:

<JavaScript File="awesome.js" />

This preferred way does not

<JavaScript>
var awesome = require('awesome');
</JavaScript>

The error I get is

LOG: Error: JavaScript error in MainView.ux line 6: Name: Fuse.Scripting.Error
    Error message: require(): module not found: backend
    File name: MainView.ux
    Line number: 6
    Source line: 		var backend = require('awesome')
    JS stack trace: [Uno code]
      at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x1e1eda50 + 0x000db> in <filename unknown>:0 
      at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x1e1ed8a0 + 0x0007b> in <filename unknown>:0 
      at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x1e1ebc28 + 0x00059> in <filename unknown>:0 
    [JavaScript code]
    Error: require(): module not found: awesome
        at (Error Handler):1:49
        at null._tempMethod (MainView.ux:6:17)
     in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.39.3/$.uno:1444>

This does not work either

<JavaScript File="awesome.js" ux:Global="SuperAwesome" />
<JavaScript>
  var awesome = require('SuperAwesome');
</JavaScript>

There error is:

LOG: Error: JavaScript error in MainView.ux line 6: Name: System.Exception
    Error message: Exception of type 'System.Exception' was thrown.
    File name: MainView.ux
    Line number: 6
    Source line: var awesome = require('SuperAwesome')
    JS stack trace: [Uno code]
      at Fuse.Scripting.Context.FindRootTable (Uno.UX.NameTable names) <0x1f5895b8 + 0x00057> in <filename unknown>:0 
      at Fuse.Scripting.Context.GetClassInstance (Uno.UX.NameTable scope) <0x1f5894b0 + 0x00013> in <filename unknown>:0 
      at Fuse.Reactive.RootableScriptModule.EnsureClassInstanceRooted () <0x1f5893e8 + 0x00033> in <filename unknown>:0 
      at Fuse.Reactive.RootableScriptModule.Evaluate (Fuse.Scripting.Context c, Fuse.Scripting.ModuleResult result) <0x1f589308 + 0x00013> in <filename unknown>:0 
      at Fuse.Scripting.Module.Evaluate (Fuse.Scripting.Context c, System.String id) <0x1e1e9fe8 + 0x0019d> in <filename unknown>:0 
      at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x1e1eda50 + 0x000f7> in <filename unknown>:0 
      at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x1e1ed8a0 + 0x0007b> in <filename unknown>:0 
      at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x1e1ebc28 + 0x00059> in <filename unknown>:0 
    [JavaScript code]
    Error: Exception of type 'System.Exception' was thrown.
        at (Error Handler):1:49
        at null._tempMethod (MainView.ux:6:15)
     in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.39.3/$.uno:1444>

Furthermore, using the method that does work <JavaScript File="awesome.js"> from awesome.js I can’t require anything either.

Help much appreciated! Thanks.

In order to require it you must also bundle it in the project, as described here and here

Adding "**.js:Bundle" to your includes should do the trick :slight_smile: