New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider about loading in nashorn or rhino? #40

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

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

@kitsonk kitsonk added this to the beta.4 milestone Mar 11, 2016

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Mar 17, 2016

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@tomdye

tomdye Mar 18, 2016

Member

@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
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 milestones: 2016.04, beta.4 Apr 8, 2016

@kitsonk kitsonk closed this in d10e29f Apr 8, 2016

@taoqf

This comment has been minimized.

Show comment
Hide comment
@taoqf

taoqf Apr 15, 2016

@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');

taoqf commented Apr 15, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@tomdye

tomdye Apr 15, 2016

Member

@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

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