consider about loading in nashorn or rhino? #40

Closed
taoqf opened this Issue Jan 25, 2016 · 4 comments

Projects

None yet

3 participants

@taoqf
taoqf commented Jan 25, 2016

i am using nashorn with dojo loader 1.10.4

@kitsonk kitsonk added the enhancement label Feb 18, 2016
@Tomdye Tomdye was assigned by kitsonk Feb 24, 2016
@kitsonk kitsonk added this to the beta.4 milestone Mar 11, 2016
@kitsonk
Member
kitsonk commented Mar 17, 2016

We should also investigate the state of play of Chakra/Node and see if there are any challenges/impacts to the loader working under that.

@Tomdye
Member
Tomdye commented Mar 18, 2016

@taoqf do you have an example of how you are using Nashorn and an amd module loader please?
I'm not very familiar with Nashorn. Did some research / experimenting yesterday and have seen that there are two ways to use it:

  1. via the jjs command line interface
  2. via ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn"); within standard java code.

It looks like requireJs operates the first way with r.js enabling rhino / nashorn AMD loading and has separate modules / code for each environment.

# Calling r.js to optimize a project using the build config in build.js
jjs -scripting path/to/r.js -- -o build.js
# Calling r.js to run AMD modules, where the main app program is main.js
jjs -scripting path/to/r.js -- main.js
@kitsonk kitsonk modified the milestone: 2016.04, beta.4 Apr 8, 2016
@kitsonk kitsonk added a commit that closed this issue Apr 8, 2016
@Tomdye @kitsonk Tomdye + kitsonk Add Nashorn support
Closes #40
d10e29f
@kitsonk kitsonk closed this in d10e29f Apr 8, 2016
@taoqf
taoqf commented Apr 15, 2016 edited

@Tomdye it is same between jjs and java code way.
besides, i do not want use amd in nashorn , and i do not think it a good way except the coding style is much like browser style, like dojo1.x and r.js.
i do not have a good example on github now.
it is just like the example dojo1.x use for nodejs except loading dojo.js using the global function load instead of require
xxx.js

// Configuration Object for Dojo Loader:
dojoConfig = {
    baseUrl: "src/", // Where we will put our packages
    async: 1, // We want to make sure we are using the "modern" loader
    hasCache: {
        "host-rhino": 1, // Ensure we "force" the loader into Node.js mode
        "dom": 0 // Ensure that none of the code assumes we have a DOM
    },
    // While it is possible to use config-tlmSiblingOfDojo to tell the
    // loader that your packages share the same root path as the loader,
    // this really isn't always a good idea and it is better to be
    // explicit about our package map.
    packages: [{
        name: "dojo",
        location: "dojo"
    },{
        name: "app",
        location: "app"
    },{
        name: "app-server",
        location: "app-server"
    }],
    deps: ['app-server/main']
};

// Now load the Dojo loader
load("./src/dojo/dojo.js");

using the jjs mode, just type
jjs load('xxx.js');

@Tomdye
Member
Tomdye commented Apr 15, 2016

@taoqf the PR that adds nashorn support has been merged into master, why don't you give it a try and see if it works for you. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment