Several Javascript in the same module

Hello, is it possible to have two lines with ‘JavaScript File’ in the same module?

I’ve found that if I separate javascript associated with a .ux in two .js files:

<EdgeNavigator ux:Name="EdgeNavigator">

    <JavaScript File="literales.js"/>
    <JavaScript File="loadGames.js"/>

    <!-- Add a panel to the left edge -->
    <Sidebar Width="180" ux:Name="menu" EdgeNavigation.Edge="Left">

… both with sentences’ module.exports = … ", are visible only exported variables in the second js (visible in the .ux module). Interestingly, when I’m in ‘preview’ mode locally, in the time I make a change in a source file (CTRL + S and pulse) begin to be visible all the variables (those in the two Js).

I am doing something wrong? Is it possible to export different variables js files and include these files in the same file .ux?

Thanks in advance and excuse me my bad English.

Hi,

The hot reload feature of preview is doing some hacks, so some things will not work as documented there. That both JavaScripts are available after hot reload is a bug.

When using the JavaScript tag you make a new context for the current scope. I almost consider it a bug that you are able to do what you do in your example, as this will overwrite the first JavaScript, and since you are on the same level, the first JavaScript context will not be available anywhere.

This is how I would recommend do exactly what you are doing:

  <JavaScript File="literales.js" ux:Global="literales"/>
  <JavaScript File="loadGames.js"/>

And then in loadGames merge the result of require('literales') with your existing module.exports.

Better than that is probably to do something like:

  var literales = require('literales');
  module.exports = {
        exist ...
        ...
        literales: literales
  };

It is understood. If I declare the first global Javascript and included it in the second, it works correctly.

Thank you.