These are chat archives for canjs/canjs

22nd
Nov 2016
Szabolcs Schmidt
@sszabolcs
Nov 22 2016 08:03

@frank-dspeed @phillipskevin @justinbmeyer thanks for the info about the steal AMD support.

Now I have a build.js file that would export CanJS in AMD format, but it exports the project in CJS form.
The build.js file:

var stealTools = require("steal-tools");

stealTools.export({
    steal: {
        main: "can/legacy",
        config: __dirname + "/package.json!npm"
    },
    options: {
        verbose: true
    },
    outputs: {
        "amd": {
          graphs: ["can/legacy"],
          format: "amd",
          dest: function (modName) {
            return __dirname + "/dist/amd/" + modName + ".js";
          }
        }
    }
}).catch(function(e){

    setTimeout(function(){
        throw e;
    },1);

});

The exported file names and directory names contain version information, in this form they are unusable. For example:
can-component@3.0.2#can-component.js
can-route@3.0.4#can-route.js
or a directory named can-legacy-view-helpers@0.5.0#src

The exported files are in CJS form (can-connect@1.0.12#can-connect.js):

/*can-connect@1.0.12#can-connect*/
define(function (require, exports, module) {
    var connect = require('can-connect@1.0.12#connect');
    var base = require('can-connect@1.0.12#base/base');
    var ns = require('can-util@3.0.12#namespace');
    connect.base = base;
    module.exports = ns.connect = connect;
});

Could you please help to format the file names and directory names that they don't contain @ and #?
Thank you in advance!

Another piece of information: I'm now using steal-tools 1.0.0-rc.9 with steal-1.0.0-rc.11
Jeroen Cornelissen
@jeroencornelissen
Nov 22 2016 09:22

@jeroencornelissen you can use a $.ajaxSetup if you are using supermap ... or if you built your own connection and set .ajax on it to $.ajax

@justinbmeyer , we are not using supermap but basemap, bc we don’t want the caching. Basemap doesn’t use the $.ajaxsetup ?

Nico R.
@nriesco
Nov 22 2016 11:23
@jeroencornelissen i think you can define the strategies you'll use
Jeroen Cornelissen
@jeroencornelissen
Nov 22 2016 12:35
@nriesco what do you mean? Can you give an example?
I’m not sure if the same applies to superMap but it looks like you can define what to enable or not
Nico R.
@nriesco
Nov 22 2016 15:07
anyway, if you figure it out please post it.. I’m interested in disabling cache in some particular cases but haven’t tried it yet (low priority)
Jeroen Cornelissen
@jeroencornelissen
Nov 22 2016 16:03
@nriesco Our problem is not the caching (we use baseMap instead of superMap to prevent caching). Our problem is that we want to set extra headers for every ajax request.
With can.Model in 2.3 we could set $.ajaxSetup({...}) but canjs 3.0 doesn’t seem to listen to $.ajaxSetup… (or I’m missing something).
Nico R.
@nriesco
Nov 22 2016 16:08
I did that manually with 2.3 I could send (later) to the code to see if it helps
Not with ajaxsetup
Kevin Phillips
@phillipskevin
Nov 22 2016 16:11
@jeroencornelissen I think what @justinbmeyer was saying is you can provide $.ajax as ajax in the options you pass to baseMap
var myConnection baseMap({
  …,
  ajax: $.ajax
});
Michael Price
@web-mech
Nov 22 2016 23:25
I’d like to safely set deep objects within a can.Map in which the paths are auto-created if they don’t exist. Any tips or ideas on how i should accomplish this?
Kevin Phillips
@phillipskevin
Nov 22 2016 23:31
you mean you want to doo something like myMap.attr(‘a.b.c’, ‘d’)
Michael Price
@web-mech
Nov 22 2016 23:31
yeah
without b existing necessarily
Kevin Phillips
@phillipskevin
Nov 22 2016 23:31
right
it works if you pass it as an object
var myMap = new can.Map({ a: { foo: 'bar' } });
myMap.attr({
  a: {
    b: {
      c: 'd'
    }
  }
});
Michael Price
@web-mech
Nov 22 2016 23:34
gotcha
Kevin Phillips
@phillipskevin
Nov 22 2016 23:34
myMap.serialze();
{
  "a": {
    "foo": "bar",
    "b": {
      "c": "d"
    }
  }
}
Michael Price
@web-mech
Nov 22 2016 23:35
LazyMap was what i was looking for though
i just tried it and it will set any value at any given path
thanks though!
Kevin Phillips
@phillipskevin
Nov 22 2016 23:35
ok
I don’t think that plugin is around in 3.0
so it might not be supported in the future
Michael Price
@web-mech
Nov 22 2016 23:36
why drop it?
Kevin Phillips
@phillipskevin
Nov 22 2016 23:38
I actually don’t really know anything about it
Michael Price
@web-mech
Nov 22 2016 23:39
i take that back, it sets the attribute without complaining but its treating the entire path as one property rather than setting the nested property itself