These are chat archives for canjs/canjs

2nd
Feb 2017
alice61
@alice61
Feb 02 2017 21:23

Hi, I'm running into some trouble with my can control below. When I tried to initialize it, I get an error. However, in production mode it works. I'm using babel as my transpiler.

export default can.Control.extend({}, {
    init: function(element, options) {
        ....
    },
    '.tabNav-row a click': function(el, ev) {
        ...
    }
});
this.control = new TabNav('#control', {});

Please let me know what the issue with my controller could be

Kevin Phillips
@phillipskevin
Feb 02 2017 21:24
what is the error?
alice61
@alice61
Feb 02 2017 21:26
TabNav is not a constructor
Gira Minus
@gKreator
Feb 02 2017 21:35
Are you importing it correctly?
alice61
@alice61
Feb 02 2017 21:41
I'm using steal in another file since it's part of an older project
steal(
        "tabnav.js",
        function(TabNav) {
Gira Minus
@gKreator
Feb 02 2017 21:42
can you get a screenshot of
console.log( TabNav );
alice61
@alice61
Feb 02 2017 21:44
blob
Gira Minus
@gKreator
Feb 02 2017 21:49
Show the actual console log output of the object
not the line it breaks on
and open the default >
Also try removing .extend
alice61
@alice61
Feb 02 2017 21:55
I tried removing the extend and still running into an error
blob
Kevin Phillips
@phillipskevin
Feb 02 2017 21:59
It’s just an issue with importing an ES6 module using steal(…) syntax
you’re getting the Module itself (with a default property) instead of the default export
if you do this.control = new TabNav.default('#control', {}); does it work?
alice61
@alice61
Feb 02 2017 22:01
yeah, it does for dev mode
but once I run it in production mode, I get an error
Kevin Phillips
@phillipskevin
Feb 02 2017 22:02
what version of Steal are you using?
alice61
@alice61
Feb 02 2017 22:04
0.16.0
0.16.43 to be exact
Matthew Phillips
@matthewp
Feb 02 2017 22:07
You need to get the .default i believe
oh, see that you tried that
There was a bug in the babel version in 0.16
so you have to do something like TabNav = TabNav.default || TabNav
to make it work in both dev and prod :(
fixed in steal 1.0 though
Gira Minus
@gKreator
Feb 02 2017 22:16
ok... do child components inherit parent helpers?
i did not know this lol
Kevin Phillips
@phillipskevin
Feb 02 2017 22:17
depends on leakScope
Gira Minus
@gKreator
Feb 02 2017 22:17
canjs3 default is false?
Kevin Phillips
@phillipskevin
Feb 02 2017 22:17
yes
Gira Minus
@gKreator
Feb 02 2017 22:18
ok... something might not be working correctly there then
i set it to false manually and it still does it
Kevin Phillips
@phillipskevin
Feb 02 2017 22:19
this is a helper you’re defining on the component?
Gira Minus
@gKreator
Feb 02 2017 22:19
yes
Kevin Phillips
@phillipskevin
Feb 02 2017 22:20
and you set the child component’s leakScope to false?
Gira Minus
@gKreator
Feb 02 2017 22:20
blob
blob
blob
parent imports the child and the child has the parents helper functions
l1169117
@l1169117
Feb 02 2017 22:21
hello
run into an issue while using canjs module "can-ejs"
it throws an error:
Error: Cannot find module 'can-legacy-view-helpers'
has anyone come across this and is there a workaround?
Gira Minus
@gKreator
Feb 02 2017 22:22
did you install it via npm?
is it in your package.json?
Kevin Phillips
@phillipskevin
Feb 02 2017 22:22
can-ejs depends on can-legacy-view-helpers so something must not have installed correctly
@gKreator it would have to be the child that has leakScope: false
Gira Minus
@gKreator
Feb 02 2017 22:23
@phillipskevin ohh i thought it worked backwards lol
l1169117
@l1169117
Feb 02 2017 22:23
Thanks Kevin ... created a small repo of the issue here https://github.com/l1169117/can-ejs-issue/blob/master/README.md
Gira Minus
@gKreator
Feb 02 2017 22:24
i manually set it to false and it still is getting the helper function
Kevin Phillips
@phillipskevin
Feb 02 2017 22:24
@l1169117 you’re trying to use can-ejs in node?
l1169117
@l1169117
Feb 02 2017 22:25
uh oh?
Kevin Phillips
@phillipskevin
Feb 02 2017 22:25
just asking
l1169117
@l1169117
Feb 02 2017 22:26
just trying to gather a response... its for the browser.
The goal here is to precompile the .ejs files into functions, its a legacy project which used can-compile to scan all the files...
Kevin Phillips
@phillipskevin
Feb 02 2017 22:28
ok, so you are trying to use it in node
l1169117
@l1169117
Feb 02 2017 22:28
came across this when we tried to use canjs3.4 with webpack.
Kevin Phillips
@phillipskevin
Feb 02 2017 22:28
it doesn’t seem to work
although it works in the browser with steal
l1169117
@l1169117
Feb 02 2017 22:28
node was just to get a sample working...
is there a guide on using it with webpack as thats preselected by the client.
the legacy project works well when updated to 3.4 when the views are replaced with stash templates, unfortunately there is no bandwidth to convert the ejs to stash.
Kevin Phillips
@phillipskevin
Feb 02 2017 22:32
I think it’s just a bug in can-ejs
well, maybe...
I don’t know of a guide for using can-ejs with webpack
l1169117
@l1169117
Feb 02 2017 22:37
time to do a little more digging around... thanks for the insight, will not try to prototype it with node .
Kevin Phillips
@phillipskevin
Feb 02 2017 22:41
you can submit an issue if that’s something you want supported
Is this a bug? Helper functions get passed from parent to child
should I open an issue on canjs?
Gira Minus
@gKreator
Feb 02 2017 23:41
canjs/canjs#2996
Kevin Phillips
@phillipskevin
Feb 02 2017 23:41
:thumbsup: