These are chat archives for canjs/canjs

28th
Jun 2017
Frank Lemanschik
@frank-dspeed
Jun 28 2017 09:39
@roemhildtg @phillipskevin npm install can and import can-define/map/map will not work as steal reads the package.json
there will be only can: "x"
if you want to load a component via this you need to save it to package.json or supply additional config to steal
Matthew Phillips
@matthewp
Jun 28 2017 13:18
Viktor Busko
@Lighttree
Jun 28 2017 13:20

Guys, maybe someone have an idea where I should look if I have this kind of issue:

ERROR in ./node_modules/can-connect/data/url/url.js
Module not found: Error: Can't resolve 'can-make-rest' in 'C:\Development\Projects\conversations\node_modules\can-connect\data\url'
 @ ./node_modules/can-connect/data/url/url.js 105:15-39
 @ ./node_modules/can-connect/can/base-map/base-map.js
 @ ./src/app/models/todo.js
 @ ./src/app/app.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/app/app.js

All modules work fine, but when I try to import base-map:

import connectBaseMap from 'can-connect/can/base-map/base-map';

it fails.

I understand that it can't resolve url, but I don't understand why. There is just normal require in url.js :
var makeRest = require("can-make-rest");
And can-make-rest presented in node_modules
Viktor Busko
@Lighttree
Jun 28 2017 15:07

this solves only if I change the line above to:

var makeRest = require("can-make-rest/can-make-rest");

hmmm...

Brad Momberger
@bmomberger-bitovi
Jun 28 2017 15:08
@Lighttree check the version numbers. Steal rejects npm module imports that are out of date.
Latest can-connect requires can-make-rest 0.1.1 which is the latest release
Viktor Busko
@Lighttree
Jun 28 2017 15:09
This isn't steal :D I was thinking that this might be webpack issue.
Brad Momberger
@bmomberger-bitovi
Jun 28 2017 15:09
That could be the case. I haven't worked with webpack.
Frank Lemanschik
@frank-dspeed
Jun 28 2017 15:10
Really never webpacked something hmm sounds like you know now what you want to do on weekend :D
It will be a great adventure
Viktor Busko
@Lighttree
Jun 28 2017 15:13
well everything works fine actually. Other modules works fine, so I'm not sure that this is webpack issue.
Frank Lemanschik
@frank-dspeed
Jun 28 2017 15:13
its not a webpack issue
Viktor Busko
@Lighttree
Jun 28 2017 15:14
image.png
besides even my IDE can highlight other packages but not can-make-rest
:)
Frank Lemanschik
@frank-dspeed
Jun 28 2017 15:14
dont worry
it looks like your using microsoft software
so all bugs belong to them
Viktor Busko
@Lighttree
Jun 28 2017 15:15
hah
Kevin Phillips
@phillipskevin
Jun 28 2017 15:19
it should be loading can-make-rest/dist/cjs/can-make-rest.js
that is what the main in can-make-rest points to
looks like it's an issue with the package on npm
I opened an issue to fix this canjs/can-make-rest#11
Viktor Busko
@Lighttree
Jun 28 2017 15:22
@phillipskevin Thanks.
Kevin Phillips
@phillipskevin
Jun 28 2017 15:22
you can probably configure webpack to point to can-make-rest/can-make-rest
until we fix it
Viktor Busko
@Lighttree
Jun 28 2017 15:25
Yes I already added an alias for this
Dovid Bleier
@dbleier
Jun 28 2017 17:42
hi, just finished initial upgrade of an app to can3, and now an event handler in a component is not firing
export default Component.extend({
  tag: 'presentation-workspace',
  viewModel: ViewModel,
  view: view,
  leakScope: true,
  events: {
    'a[data-toggle="tab"] show.bs.tab': function(c, e) {
          var tab = e.target.hash.substr(1);
          this.viewModel.attr('currentTab', tab);
    }
  }

});
this is for bootstrap tabs, I want the event to fire when the displayed tab changes
did event syntax change?
Dovid Bleier
@dbleier
Jun 28 2017 18:05
when added via console this fires
      $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
        var tab = e.target.hash.substr(1);
        viewModel.attr('currentTab', tab);
      });
but when I add it to the inserted event, even though the inserted event does fire upon load, the listener does not
    'inserted': () => {
      var viewModel = this.viewModel;
      $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
        var tab = e.target.hash.substr(1);
        viewModel.attr('currentTab', tab);
      });
    }
btw, this code DID work in can 2.x
Kevin Phillips
@phillipskevin
Jun 28 2017 18:22
try '{element} a[data-toggle="tab"] show.bs.tab': function...
Frank Lemanschik
@frank-dspeed
Jun 28 2017 18:22
@dbleier did you install can-jquery
?
Dovid Bleier
@dbleier
Jun 28 2017 18:23
@phillipskevin ok will try that
Kevin Phillips
@phillipskevin
Jun 28 2017 18:23
I think it should work either way, but just want to check
Dovid Bleier
@dbleier
Jun 28 2017 18:23
@frank-dspeed I did import $ from 'jquery';
Frank Lemanschik
@frank-dspeed
Jun 28 2017 18:23
maybe you need can-jquery
for event cross bindings
you can simply replace jquery with can-jquery
Dovid Bleier
@dbleier
Jun 28 2017 18:24
ok {element} did not work
will try can-jquery now
yes can-jquery did the trick and no {element} required after that
thanks guys!
Frank Lemanschik
@frank-dspeed
Jun 28 2017 18:27
ok fine no problem your welcome
Juan Orozco
@Macrofig
Jun 28 2017 21:05
Hello all! Question on can-fixture. Is this signature expected to return a stringified object? https://canjs.com/doc/can-fixture.html#fixture_methodAndUrl_url_data_requestHandler_
Juan Orozco
@Macrofig
Jun 28 2017 21:12
I thought this signature used to return an object. http://jsbin.com/lisawew/edit?js,console Am I missing something?
Justin Meyer
@justinbmeyer
Jun 28 2017 21:17
yeah, it might have in 2.3, but that's not what jQuery would actually give you
you have to tell jQuery to parse json
with the dataType: "json"
can.fixture('GET /test', () => {
  return {
    hello: "ima lego"
  }
});

$.ajax({url: '/test', dataType: "json"}).then(resp => {
  console.log('response');
  console.log(resp);
  console.assert(typeof resp === 'object', 'This used to be an object?')
});
that works
3.0 gets it right, 2.3 had it wrong
Juan Orozco
@Macrofig
Jun 28 2017 21:19
Ohhhh that's right
dataType... forgot about that