These are chat archives for canjs/canjs

22nd
Dec 2017
DaveO
@DaveO-Home
Dec 22 2017 01:20
@phillipskevin - All of the bundlers do the job - I'm partial to Steal because of development from src and simplicity. Fusebox is fast! Actually everyone says how complex webpack is, I did'nt have too many problems with it. Pulled my hair out for some time on Fusebox until I figured out to transpile everthing to typescript. Oh, the issue with Canjs is that one has to develop strip dev block code for bundlers other than steal, maybe an enhancement?
DaveO
@DaveO-Home
Dec 22 2017 01:36
Also, Canjs/Steal shines with dynamic loaded modules. Fusebox I think might handle them, but not easy. All of the other bundlers just parse the code looking for modules, thus all module name have to me hard coded, require("something") etc.
Kevin Phillips
@phillipskevin
Dec 22 2017 04:06
@DaveO-Home having built, production versions of everything is something other people have asked for too. It's definitely something we'll keep considering.
Frank Lemanschik
@frank-dspeed
Dec 22 2017 08:56
@DaveO-Home about the strip in other bundlers you need to code addons for them that simply strip the steal remove comments
but the steal project could offer a codemod for that maybe create a issue in stealjs/steal-tools about that
if you want that this happens
Nico R.
@nriesco
Dec 22 2017 13:25
Is it ok form the syntax standpoint to use {{#if (someCondition)}} instead of {{#if(someCondition)}} (a space between if and the opening parenthesis)
my code formatter is getting crazy otherwise
I tested in my code and it works, but I wanted to know if it could eventually cause trouble
Frank Lemanschik
@frank-dspeed
Dec 22 2017 14:00
i think
as long as it works simply consider it is intended to do so :)
would be my way of thinking else this is fast search replaced
Viktor Busko
@Lighttree
Dec 22 2017 14:21

@DaveO-Home about the strip in other bundlers you need to code addons for them that simply strip the steal remove comments

@frank-dspeed maybe you know the place in stealjs srcs where I can find how steal detects this comment blocks (I guess there is some regex)? I was going to add webpack loader to my prod build for this, but postponed this.

Oh I found it. It's in steal-tools
Nico R.
@nriesco
Dec 22 2017 14:44
I have a button like this: <button type="button" on:click="saveAndClose(this)">Save changes</button>
is within a component’s stache
Frank Lemanschik
@frank-dspeed
Dec 22 2017 14:44
i have such buttons also
they rock
:D
Nico R.
@nriesco
Dec 22 2017 14:44
and the saveAndClose function receives the correct object so everything is ok
But I have a modal that I want to close after saving
Frank Lemanschik
@frank-dspeed
Dec 22 2017 14:45
yes thats cool i agree total
then fire save
Nico R.
@nriesco
Dec 22 2017 14:45
So how can I send the current element information without setting an inserted event?
Frank Lemanschik
@frank-dspeed
Dec 22 2017 14:45
like this.dispatch('save')
Nico R.
@nriesco
Dec 22 2017 14:45
where?
Frank Lemanschik
@frank-dspeed
Dec 22 2017 14:45
and then do listeh this.on('save')
don't know your code
Viktor Busko
@Lighttree
Dec 22 2017 15:48

Guys, I'm working with can.js + webpack and currently trying to create analogs of donejs cli. I already created generators for canjs + webpack stack, but there is something that as far as I can see webpack can't reproduce:

I have plugin with component and there is file like:
entity-details-component.html - purpose of this file is demo it's functionality. And in donejs it uses can-autorender to render component in html without any...entry point.

<script type="text/stache" can-autorender>
  <can-import from="<%= module %>/" />
  <<%= tag %>></<%= tag %>>
</script>
<script src="<%= root %>node_modules/steal/steal.js"
        main="can-view-autorender"></script>

I can't use something like this, because can-autorender works in steal builds. (same issue valid for test.html)
Only way that I can see for now is create..some kind of renderer.js file and include it to development build:

import stache from 'can-stache';
import './award-details-component';

document.body.appendChild(stache('<entity-details-component entity:from="data"></entity-details-component>')({data}));

and then:

 <script src="main.bundle.js"></script>

This works...but this "renderer" file annoys me :) Maybe you can see more elegant way to do this ?

DaveO
@DaveO-Home
Dec 22 2017 16:24

@frank-dspeed @Lighttree One solution at least for Webpack and Browserify could be
//!steal-remove-start
/ develblock:start /
//removeIf(production)

...dev code

//endRemoveIf(production)
/ develblock:end /
//!steal-remove-end

and uglify could strip remaining comments.

Viktor Busko
@Lighttree
Dec 22 2017 16:28
This will work only if you use strip-block-loader for webpack, so I doubt that something like this will be added to can.js source :)
Or maybe I miss something, anyway modifying canjs source code not really good option.
DaveO
@DaveO-Home
Dec 22 2017 16:30
No, I wouldn't the code myself
How do I edit a typeo -- I meant No, I wouldn't change the code myself
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 16:32
"Edit" is in the kebab menu that shows up when you hover your pointer over the message you sent.
Justin Meyer
@justinbmeyer
Dec 22 2017 16:33
Viktor Busko
@Lighttree
Dec 22 2017 16:33
@DaveO-Home If you interested in how to remove this //!steal-remove-start with web-pack. I think its possible to write simple loader like this one: https://github.com/jballant/webpack-strip-block/blob/master/index.js (maybe fork) and replace regex with the same sued here: https://github.com/stealjs/steal-tools/blob/master/lib/build/clean.js
DaveO
@DaveO-Home
Dec 22 2017 16:35
@Lighttree No problem, I've done that but you would think that canjs could be used seamlessly.
Viktor Busko
@Lighttree
Dec 22 2017 16:37
Yeah sure
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 16:39
@Lighttree for the component generation, you'd probably want to just create a done-cli generator for components that uses a Webpack compatible script in the .html (most of the code from donejs-generator/component can be reused). So then you could just do, e.g., donejs add webpack-component and go through the same steps.
Nico R.
@nriesco
Dec 22 2017 17:03
when using a model to store data in the database, I see that when .save() is used a PUT request is sent with all the information. How can I force it not to do a PUT but a PATCH and send only changes instead of the whole object? Is this part of can-connect. I define my models using superMap + can-connect-feathers
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 17:58
If you want to do every PUT as a PATCH, it's easier to set up the feathers service to do this instead of the client.
So your before hooks would include this:
      update: [
        context => {
          return context.service.patch(context.id, context.data, context.params)
            .then(result => {
              context.result = result
              return context
            })
        }
      ],
Nico R.
@nriesco
Dec 22 2017 18:13
but it will still send all the data, even if it has not been modified
I’m just being lazy, I thought forcing .save to try first to do a sort of .update only on thinks that change
it would be great and save a lot of data traffic
But it works right now so its just for optimizing
it could be usefull for mobile devices though
@bmomberger-bitovi do you know who is responsible for doing that update? Can-connect? Can-connect-feathers?
Supermap?
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 18:18
Supermap and can-connect-feathers are really just collections of can-connect behaviors.
If you want to pare down your update set to just what changed, you can implement your own behavior for that.
Nico R.
@nriesco
Dec 22 2017 18:20
so who decides that .save should result in a PUT/UPDATE? or in a CREATE?
because a new element will be created when using .save
and updated if it exists
so I guess it would be the same place to decide to patch instead of update
just wondering
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 18:22
That comes from the constructor behavior.
So your patch diffing would have to go somewhere up the proto chain from constructor in your connection.
The order of the built-in behaviors for can-connect is defined here (earlier in the list is later in execution during the request phase): https://github.com/canjs/can-connect/blob/master/connect.js#L54
Brad Momberger
@bmomberger-bitovi
Dec 22 2017 18:30
Probably what you'd want to do is make a custom serializeInstance() for your behavior. construct uses the original instance, not the serialized form, to determine whether it's a create or update operation, so you can serialize down to just a patch from the original
In that case, you'd want to put your behavior after can/map in the list of behaviors for your connection. At the end is fine.
Nico R.
@nriesco
Dec 22 2017 19:00
Thanks @bmomberger-bitovi it looks much more complex than what I thought, and not so high priority, so I guess I’ll have to postpone it. Thanks anyway