"Portable Modules" work with the src version, but not the pre-built version - dojo

In order to use dojo 1.8 in conjunction with 1.6, I set up portable modules as described in the tutorial Defining Modules, under the sub heading "Using portable modules".
I've been using it with the source version of dojo, "dojo-release-1.8.3-src.zip", and it works just fine, but when I switch to the pre-built version, "dojo-release-1.8.3.zip", it throws 404 errors looking for dependencies:
GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/parser.js 200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js 404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js"
GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/request.js 200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js 404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js"
From the console it's clear that it's looking in the wrong place for the dependency file (looking in 'dojo-build-1.6.1' instead of 'dojo-release-1.8.3'). What I want to know is why? All I did was swap the source version for the pre-built version.
Here is my configuration:
<script>
var map18 = {dojo: "dojo18", dijit: "dijit18", dojox: "dojo18"};
var dojoConfig = {
async: false,
parseOnLoad: true, // in 1.8 they suggest setting to false and manually parsing when needed, but we're not set up that way at the moment
packages: [
{name: "dgrid", location: "../../dgrid/dgrid", packageMap: map18},
{name: "xstyle", location: "../../dgrid/xstyle", packageMap: map18},
{name: "put-selector", location: "../../dgrid/put-selector", packageMap: map18},
{name: "modules", location: "../../modules", packageMap: map18},
{name: "page", location: "../../page"},
{name: "dojoc", location: "../../dojoc"},
{name: "dojo18", location: "../../dojo-release-1.8.3/dojo", packageMap: map18},
{name: "dijit18", location: "../../dojo-release-1.8.3/dijit", packageMap: map18},
{name: "dojox18", location: "../../dojo-release-1.8.3/dojox", packageMap: map18},
{name: "dojo", location: "../../dojo-build-1.6.1/dojo", main: "dojo"},
{name: "dijit", location: "../../dojo-build-1.6.1/dijit"},
{name: "dojox", location: "../../dojo-build-1.6.1/dojox"}
],
};
</script>

I tried something similar (using both 1.8 and 1.6 source) and got a different error. I know it's not an answer to the question, but I'll paste it here in case it helps you find an answer.
This is my test page:
<script>
var location18 = "/dojo18";
var location16 = "/dojo16";
var map16 = { dojo: "dojo16", dijit: "dijit16", dojox: "dojox16" },
dojoConfig = {
packages: [
{ name: "dojo16", location: location16 + "/dojo", packageMap: map16 },
{ name: "dijit16", location: location16 + "/dijit", packageMap: map16 },
{ name: "dojox16", location: location16 + "/dojox", packageMap: map16 },
{ name: "dojo", location: location18 + "/dojo" },
{ name: "dijit", location: location18 + "/dijit" },
{ name: "dojox", location: location18 + "/dojox" }
]
};
</script>
<script src="/dojo18/dojo/dojo.js"></script>
<script>
require(["dojo/date"], function (date) {
console.log("date18", date);
});
</script>
<script>
require(["dojo16/date"], function (date) {
console.log("date16", date);
});
</script>
And the error I get seems to be related to loading two date modules. Not sure if Dojo can treat them separately, but I've not managed to do this.

Related

Sanity.io field-level localisation

I need to have proper localisation for my Sanity CMS.
I found the official information here, but it doesn't get into details. I tried to apply the same approach for block type:
export default {
title: 'Localised block',
name: 'localeBlock',
type: 'object',
fieldsets: [
{
title: 'Translations',
name: 'translations',
options: {
collapsible: true,
},
},
],
fields: supportedLanguages.map(lang => ({
title: lang.title,
name: lang.id,
type: 'block',
fieldset: lang.isDefault ? null : 'translations',
})),
}
But I got the following error:
Object type "localeBlock"
localeBlock:object → fields → block:block
Found unknown properties for block declaration: "fieldset"
How do I implement block localisation? Is there a deeper documentation on localisation than the official one?

error - karate.mapWithKey is not a function

How do I handle below Karate error?
javascript evaluation failed: karate.mapWithKey(list, 'name'), TypeError: karate.mapWithKey is not a function in at line number 1
def list = [ 'Bob', 'Wild', 'Nyan' ]
def data = karate.mapWithKey(list, 'name')
match data == [{ name: 'Bob' }, { name: 'Wild' }, { name: 'Nyan' }]
You are probably on an old version of Karate. Upgrade.
If you are still stuck, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

How to perform dijit optimization with r.js?

How do we get around the "document is not defined" error when doing a r.js build via r.js -o against a dijit?
Specifically, I'm trying to build r-build.js:
define(["require", "exports", "dijit/layout/ContentPane"], function (require, exports, ContentPane) {
function simple() {
return ContentPane;
}
return simple;
});
Using r.js.cmd -o r-build.js and it reports:
ReferenceError: document is not defined
In module tree:
test/simple
dijit/layout/ContentPane
dijit/_Widget
dojo/query
dojo/selector/_loader
My r-build.js file looks like this:
({
appDir: "../",
baseUrl: "amd",
dir: "../../release",
optimize: "none",
modules: [
{
name: "test/simple",
exclude: ["jquery", "dojo"]
}
],
packages: [
{
name: 'cm',
location: 'http://localhost:93/CodeMirror'
},
{
name: 'jquery',
location: 'd:/code/jquery/src',
main: 'jquery'
},
{
name: 'jquery/ui',
location: 'http://localhost:93/jquery-ui/ui'
},
{
name: 'jquery/themes',
location: 'http://localhost:93/jquery-ui/themes'
},
{
name: 'sizzle',
location: 'http://localhost:93/jquery/external/sizzle/dist',
main: 'sizzle'
},
{
name: 'dojo',
location: 'd:/code/dojo'
},
{
name: 'dijit',
location: 'd:/code/dijit'
},
{
name: 'xstyle',
location: 'http://localhost:93/xstyle'
}
]
})
I'm fighting with the same issue. Building a r.js bundle with Dojo is a pain.
That one can be easy to fix... If you don't have problems with the supported browsers (post pre-ie9, for instance) override that file and change the lines that check the querySelectorAll to true and you will not need to do those checks. Like...
has.add("dom-qsa2.1", true);
has.add("dom-qsa3", true);
Hope it helps a bit...

shim specified file cannot load after optimized with r.js

i have a following requirejs configuration in my code:
require.config({
baseUrl: "js",
// urlArgs: 'cb=' + Math.random(),
deps:["config","app"],
paths: {
'jquery' : 'jquery/jquery',
'jquerymobile.config' : 'mobile/jquerymobile.config',
'jquerymobile': 'mobile/jquery.mobile-1.3.1.min' ,
'underscore': 'underscore-amd/underscore-min',
'backbone' : 'backbone-amd/backbone-min',
text: 'plugins/text'
},
shim: {
underscore: {
exports: "_"
},
'jquery' : 'jquery',
'jquerymobile.config' : ['jquery'],
jquerymobile : {
deps : ["jquery", 'jquerymobile.config']
},
backbone: {
deps: ['underscore', 'jquery', 'jquerymobile'],
exports: 'Backbone'
}
}
});
inside jquerymobile.config file i have console log statement, which cannot be seen after optimization with following build profile (build.js):
({
appDir: '../',
baseUrl: 'js',
dir: '../../dist',
name: 'config',
skipDirOptimize:true,
fileExclusionRegExp: /^(r|build)\.js$/,
excludeShallow: ['settings'],
mainConfigFile: '../js/config.js',
optimizeCss: 'standard',
removeCombined: true,
deps:["config","app"]
})
I have a feeling that r.js ignoring the shim, dependecies,\n
is there any workaround?
thanks for help
Please try the following way:
include your jquerymobile.config in main.js require dependencies list:
require(['app', 'jquerymobile.config', 'jquerymobile'], function(App) {
App.initialize();
});

dojo loader is appending 'main.js' to my packages

For my packages, dojo seems to be appending 'main.js' to end of each file resulting in a '404' has any one experienced this and or have a solution?
GET http://localhost:9000/scripts/prodLayers/main.js 404 (Not Found)
var dojoConfig = {
has: {
"dojo-firebug": true,
"dojo-debug-messages": true
},
tlmSiblingOfDojo: true,
async: true,
parseOnLoad: false,
packages: [
{ name: "prod", location: "/scripts/prodLayers"}
]
};
packages: [
{ name: "prodLayers", location: "/scripts/mylibs", main: "prodLayers"}
]
The "main" attribute is name of the file to be referenced using 'baseUrl' to define the package locations may also help to simplify the "location" params.