The default was chosen before MarkLogic supported SJS; as such, there was no 
motivation to worry about it. I don't remember what triggered us to use true as 
the default, but SJS does change the situation. I think changing the default 
makes sense. Probably worth testing on some reasonable set of UI JavaScript 
before committing.

--
Dave Cassel<http://davidcassel.net>, @dmcassel<https://twitter.com/dmcassel>
Technical Community Manager
MarkLogic Corporation<http://www.marklogic.com/>
http://developer.marklogic.com/


From: <[email protected]<mailto:[email protected]>> on behalf of Florent 
Georges <[email protected]<mailto:[email protected]>>
Date: Friday, July 15, 2016 at 7:04 AM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Cc: Dave Cassel <[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Roxy uploads *js files as binary docs

Hi Geert,

Thank you, I've just validated it solves my problem (at least in the repro I 
sent, I am about to test it on the real project now).  Sad I did not see the 
question passing on the mailing list.

I am wondering why the default is true.  I can only think of corner cases with 
encoding for JS files served as content for the client UI.  Since we all tend 
to be UTF-8 (especially in the context of JavaScript and web UI), I am not 
quite sure why the default is true, as it prevents to use *.js files on the 
server (esp. annoying for dependencies retrieved from, say, NPM).

But well, changing a default value is always, well, changing a default value...

Thanks for your help!  Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 15 July 2016 at 12:53, Geert Josten wrote:
Hi Florent,

You’re the 3rd to mention this in a short time. There is a `load-js-as-binary` 
property that defaults to true.

@Dave, maybe we should start thinking about changing that default?

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Florent Georges <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Friday, July 15, 2016 at 12:40 PM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Roxy uploads *js files as binary docs

Hi,

We are facing a problem with using JavaScript files using the *.js extension
(that is, not the *.sjs extension), using Roxy.  In that case, Roxy does not
upload them as text documents, but rather as binaries.  Which makes them
usuitable to be "require()"d by other SJS files.

Is there any way to ask Roxy to upload *js files as text on "deploy modules"?

Complete repro:

1) clone Roxy: "git clone 
git://github.com/marklogic/roxy.git<http://github.com/marklogic/roxy.git>"

2) init Roxy: "./ml init app-name --server-version=8 --app-type=bare"

3) edit deploy/build.properties, what I've done:
    - app-name=test-js-vs-sjs
    - app-port=6640
    - xcc-port=6641
    - local-server=my.vm.name<http://my.vm.name>

4) bootstrap it: "./ml local bootstrap"

5) create the following 5 files in Roxy's src dir:

== src/lib/lib.sjs AND src/lib/lib.js ==
module.exports = {
    hello: function(who) {
return 'Hello, ' + who + '!';
    }
};

== src/lib/one.js ==
module.exports = {
    classic: function() {
return require('lib.sjs').hello('world');
    }
};

== src/lib/two.js AND src/lib/two.sjs ==
module.exports = {
    classic: function() {
return require('lib.js').hello('world');
    }
};

6) upload them: "./ml local deploy modules"

7) in QConsole, against "test-js-vs-sjs-content" database, run the following
   queries:

require('one.sjs').classic();
  => 'Hello, world!'

require('two.js').classic();
  => Error: two.js is not a text document

require('two.sjs').classic();
  => Error: lib.js is not a text document

* The first one, using SJS for the top lib and the one it imports, works.

* The second one, using JS for the top lib and the one it imports, fails.

* The second one, using SJS for the top lib and JS for the one it imports,
fails as well, showing it is not about the way QConsole reolves the query it
evaluates, but also how require()'s parameter is resolved for 2 modules
sitting in the modules database.

Looking at the files in the modules database, using "explore" on QConsole,
shows indeed that JS files are binary files.

Is there any way to ask Roxy to upload *js files as text on "deploy modules"?

Regards,


--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/



_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general





_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to