These are chat archives for canjs/canjs

21st
Dec 2015
Andrei Balmus
@abalmush
Dec 21 2015 14:14
Hi guys, I’m seeing this worning when I run gulp build, it’s something that I can fix?
WARNING in ./~/can/dist/cjs/view/view.js
Critical dependencies:
50:12-19 require function is used in a way in which dependencies cannot be statically extracted
51:18-25 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/can/dist/cjs/view/view.js 50:12-19 51:18-25
Justin Meyer
@justinbmeyer
Dec 21 2015 17:30
@abalmush can you share that line?
is that code actually being run?
it's so can.view can use requirejs to dynamically import templates
your app should probably not be doing that
if it is
but it probably is not
and can probably be ignored
Guido Smeets
@gsmeets
Dec 21 2015 18:13
actually, there are some use cases for that
I use it in dev mode, during build mode those dependencies are added to build layers
and I'm thinking of using it for dynamically generated views on the server
Andrei Balmus
@abalmush
Dec 21 2015 18:24
Thank you Justing, I’m ignoring it for now, I think it’s because Node version is to old (1.2), but I can’t update it on our CI environment, this is the line that cause the Warning:
if (require.toUrl) {
            url = require.toUrl(url);
        }
Justin Meyer
@justinbmeyer
Dec 21 2015 18:35
gsmeets imo, requirejs/your module loader should be directly used for that
not can.view's API
we progressively load views all the time
but always via a System.import() or <can-import> which works through the module loader / build system
cc @gsmeets
@phillipskevin their isn't a great way ... but you could have a setAttending method or even do
actually, I take it back ...
well
<input type='radio' value='yes' ($change)="setAttending(%element.checked, %element.value)"/>
Justin Meyer
@justinbmeyer
Dec 21 2015 18:41
setAttending: function(set, value){
  if(set) 
    this.attr("attending", value);
}
not as pretty as it used to be
@phillipskevin let me know if that works
Kevin Phillips
@phillipskevin
Dec 21 2015 18:47
@justinbmeyer ok I’ll try it out and let you know
Justin Meyer
@justinbmeyer
Dec 21 2015 18:49
This is a tricky one b/c you only want to set if the radio is selected
I wonder if (in 2.3.7), you can have helper macros
{{radio-set "attending"}}
actually, that you could do already
can.stache.registerHelper("radio-set", function(attr, options){
  return function(el){
    $(el).bind("change", .... )
  }
})
but yeah ... it would be nice if 2.3 CanJS had something for this common use case
oh, the above would also need
<input type='radio' value='yes' ($change)="setAttending(%element.checked, %element.value)" {{#eq 'yes' attending}}checked{{/}}/>
Justin Meyer
@justinbmeyer
Dec 21 2015 18:54
uggg
I'd use can-value :-(
Kevin Phillips
@phillipskevin
Dec 21 2015 18:55
ok
would it be possible to special case {($value)} to work with radio buttons as can-value did?
Justin Meyer
@justinbmeyer
Dec 21 2015 18:56
I would prefer not to
it's possible
but it doesn't make sense
b/c you aren't actually binding to the radio's value
that element's value doesn't actually change
Kevin Phillips
@phillipskevin
Dec 21 2015 18:56
yeah, I get that it’s not the value of the button
right
Justin Meyer
@justinbmeyer
Dec 21 2015 18:56
you are changing with it's checked
that is the getter/setter
compute
for radios
that can-value creates
Kevin Phillips
@phillipskevin
Dec 21 2015 18:57
ok
Justin Meyer
@justinbmeyer
Dec 21 2015 18:57
in some ways ... we need a way to create that
{($checked)}="isValue(attending)"
A way to wrap the attending value with another getter/setter compute
the compute's READ is tied to if attending == %element.value
Guido Smeets
@gsmeets
Dec 21 2015 19:00
@justinbmeyer I think it's just so double that I'd have to use a can-import first, before I'd be able to use a partial
now I can just use {{>foo/bar.stache}} without thinking
and my buid process just adds that dependency to the build layer
Justin Meyer
@justinbmeyer
Dec 21 2015 19:01
the compute is written with the value of CHECKED
@gsmeets yeah, but <can-import> can pull in everything for that template
btw ... if you wanted to remove the need for <can-import> it's possible to improve the parser
it could see >THING
and add that to the list of imports

can pull in everything for that template

meaning that we us it to pull in custom elements, styles, helpers, etc for a template. For us, using <can-import> to make sure a template has access to something is pretty routine.

Guido Smeets
@gsmeets
Dec 21 2015 19:04
I already built that ;)
for requirejs, that is
Justin Meyer
@justinbmeyer
Dec 21 2015 19:05
nice, is it shared?
still requires docs and a few small things
but it works
yay for 50% understaffing
Justin Meyer
@justinbmeyer
Dec 21 2015 19:05
very cool
Guido Smeets
@gsmeets
Dec 21 2015 19:06
the thing that's missing is that it doesn't work when I have a partial within a partial
Justin Meyer
@justinbmeyer
Dec 21 2015 19:06
ah, it's even using buildRequire( "lib/can/view/intermediate_and_imports" ),
Guido Smeets
@gsmeets
Dec 21 2015 19:06
still have to look into that
Justin Meyer
@justinbmeyer
Dec 21 2015 19:06
so this supports <can-import>?
Guido Smeets
@gsmeets
Dec 21 2015 19:07
yep
Justin Meyer
@justinbmeyer
Dec 21 2015 19:07
sweet
Guido Smeets
@gsmeets
Dec 21 2015 19:07
although I think you guys added some features since the first <can-import> version
Justin Meyer
@justinbmeyer
Dec 21 2015 19:07
you could write out the tokenized form
Guido Smeets
@gsmeets
Dec 21 2015 19:07
so I might be lacking some features
yeah, that wasn't working yet when I wrote this
I think I created this in 2.1 or 2.2
2.1 probably
the JSON form is a bit larger
but if you have a LOT of templates
(as we usually do)
the total initialization time is faster
Guido Smeets
@gsmeets
Dec 21 2015 19:09
heh, that works?
nice
Justin Meyer
@justinbmeyer
Dec 21 2015 19:09
b/c you don't have to parse
you move right to the template construction phase
Guido Smeets
@gsmeets
Dec 21 2015 19:09
very nice indeed
Justin Meyer
@justinbmeyer
Dec 21 2015 19:12
btw, for 3.0, I was thinking about changing AMD module names to match all the other module names. So it would be can/component/component. How terrible would this be for you?
or is it something you think a good regexp could fix?
Guido Smeets
@gsmeets
Dec 21 2015 19:12
doesn't really matter to me
I'm loading all my canjs deps upfront, and just importing can everywhere
Justin Meyer
@justinbmeyer
Dec 21 2015 19:13
ah
Guido Smeets
@gsmeets
Dec 21 2015 19:13
unless I write some very specific canjs extension
I'll take the overhead of 5 extra unused canjs files over having to explain all those separate dependencies to my juniors ;)
about that can-import support
what I think you guys added afterwards is the ability to rename a tag basically with some markup on the can-import
I don't support that right now, I just import it with the original tag, so you'd have to know that
will probably update that in some later version
Marshall Thompson
@marshallswain
Dec 21 2015 22:20
@justinbmeyer Re: can-connect. I want to send an entire array in one fell swoop to the backend service. Shouldn't I be able to do TransactionModel.createData(txnsArray)
I'm using a DoneJS generated supermodel.