These are chat archives for canjs/canjs

12th
Jul 2017
Viktor Busko
@Lighttree
Jul 12 2017 12:09

Hi :)

I'm trying to run compiled app on one of the pages of another app that knows nothing about can.js or steal or webpack, so just rendering app in some div.

And I have following issue when add bundle to the page:
"Uncaught TypeError: Cannot define property _instanceDefinitions, object is not extensible" at this line:
https://github.com/canjs/can-define/blob/master/define-helpers/define-helpers.js#L17

After short research I found out that my bundle contains these lines:
https://github.com/canjs/can-define/blob/master/can-define.js#L809

// only seal in dev mode for performance reasons.
//!steal-remove-start
    this._data;
    this._computed;
    if(sealed !== false) {
        Object.seal(this);
    }
//!steal-remove-end

And as I got this seals object, so later it can't be extended by define-helpers.

Since I'm building app by Webpack it leaves this sections because obviously !steal-remove-start something that only Steal understands.
I think I can add logic to remove these blocks, but is it safe ? Or is there any other ways to get version without these blocks.

Viktor Busko
@Lighttree
Jul 12 2017 12:22
Something that I don't understand that everything is ok when I open this app on separate page. (Just index.html from server), but when I add this bundle to another page this issue appears.
Kevin Phillips
@phillipskevin
Jul 12 2017 13:14
even with DefineMaps sealed, this error should not be happening
can you find out what object that error is being thrown for @Lighttree ?
Viktor Busko
@Lighttree
Jul 12 2017 13:15
let me check
Viktor Busko
@Lighttree
Jul 12 2017 13:21
for AppViewModel
const AppViewModel = DefineMap.extend('AppViewModel', {
    appName: {
        type: 'string',
        serialize: false
    },
    filter: 'string'
});

const appVM = new AppViewModel({
    appName: 'Name'
});

route.data = appVM;
route('{filter}');
route.ready();

document.body.appendChild(view(appVM));
Hmmm this works fine if I remove
route.data = appVM;
route('{filter}');
route.ready();
Kevin Phillips
@phillipskevin
Jul 12 2017 13:25
are you calling route.attr(...) somewhere?
Viktor Busko
@Lighttree
Jul 12 2017 13:27
No there is no code in this app. This is kinda empty app. But I think maybe the reason is that there is already URL on page where I "insert" this app ?
https://localhost/something/t/home?param1=value&param2=value
and can.route doing something that cause this issue
I just put this bundle to Apache and using this url everything works fine: https://localhost/something/
Kevin Phillips
@phillipskevin
Jul 12 2017 13:30
ah, so it's trying to set param1 and param2 on your AppViewModel
Viktor Busko
@Lighttree
Jul 12 2017 13:30
thats fine to me .. I think, but why it can't ?
I must list them in VM ?
just checked - didn't helped
Kevin Phillips
@phillipskevin
Jul 12 2017 13:34
can you set a breakpoint in that defineExpando function?
Viktor Busko
@Lighttree
Jul 12 2017 13:34
wait I described my params in a wrong place, maybe If I put them in route function correctly it will work.
Viktor Busko
@Lighttree
Jul 12 2017 13:52
@phillipskevin Hmmm I think that the issue was due to can-route-pushstate. I used it during development...but If I wan't to open the same app in some popup it is better to use normal can-route by #! in this case application URL will work fine.
The goal is to be able open the same app as separate or in lightbox :)
and this lighbox can be opened in another application :)
sounds like case for iframe besides
Kevin Phillips
@phillipskevin
Jul 12 2017 15:01
@Lighttree is this the issue in your app? canjs/can-route#98
I saw the same thing in another app, so want to make sure it's the same thing that is happening to you