Bower install javascript lib but not include in config.js

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Herby Vojčík


Norbert Hartl wrote:
> Well, the javascript files are in the same repository as the amber project. So it isn't that easy to check them out. And those are not modules more kind of a configuration for angular/ionic. Basically I want to use amber for ionic (mostly angular) wiring. I need to load ionic/angular base first, the n amber and finally a few javascript files

Why not in parallel? Amber does not start anything anyway until you call amber.initialize yourself. So just put all app-level dependencies in deploy.js, along with amber/deploy itself.

> making the wires between angular and amber.

Those you can load in the callback itself, by issuing the nested require call, like `require(["glue_module_1", "glue_module2"], function (glue1, glue2) { glue1.doSomething(); glue2.doSomething(); amber.initialize(...`


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Hannes Hirzel
In reply to this post by NorbertHartl
On 4/13/15, Norbert Hartl <[hidden email]> wrote:
> I do not want to hijack this thread but I have a similar question right
> now.

Thats OK. This is a topic people on this list have been struggling
with the last 18 months ...

> I have three javascript files that I need to have loaded with require.js
> (along with other modules). So
>
> - having an amd.json file is it only possible to declare a single file in
> one amd.json (having one key to depend on). I can define more entries in an
> amd json but then I have also three new keys I need to depend on elsewhere.
> Or do I define three things and add dependencies between them in the same
> amd.json file?
> - Having an amd.json file that is not bower module (because it is already in
> my git repo) is somewhat difficult. There is code in the amd processing that
> assumes at least there is a directory in bower_components with the same
> name. Creating a directory helps but is no solution.
> - The assumption that everything in an amd.json file is a bower_module makes
> use ../../dir/[basename of js file] a lot
>
> So I struggle that much that I have the feeling I doing something wrong.


> What would be the best way to integrate javascript files into the require.js
> process that are no bower components?

May I ask you to do an attempt at answering this yourself in the
upcoming days here.

https://github.com/amber-smalltalk/amber/wiki/FAQ

You may just put the question there and a few keywords for the answer
as a start.


> thanks,
>
> Norbert
>
>> Am 13.04.2015 um 15:00 schrieb H. Hirzel <[hidden email]>:
>>
>> OK done
>>
>> https://github.com/hhzl/benevoles/blob/amd.json.fix/papaparse.amd.json
>>
>>
>> The same as
>>
>> the processing.amd.json library mapping file
>>
>> {
>> "paths": {
>>            "processing" : "processing"
>>         }
>> }
>>
>> (from:
>> http://stackoverflow.com/questions/27374889/how-to-add-a-non-amber-library-with-bower-for-example-processing-js
>> )
>>
>>
>>
>>
>>
>> On 4/13/15, Herby Vojčík <[hidden email]> wrote:
>>>
>>>
>>> H. Hirzel wrote:
>>>> So something like here
>>>>
>>>> https://github.com/hhzl/benevoles/blob/amd.json.fix/papaparse.amd.json
>>>>
>>>> {
>>>>     "paths": {
>>>>                      "papaparse": "papaparse.js"
>>>
>>> No ".js"!
>>>
>>>>                 }
>>>> }
>>>>
>>>>
>>>>
>>>> On 4/12/15, Herby Vojčík<[hidden email]>  wrote:
>>>>>
>>>>> H. Hirzel wrote:
>>>>>> /benevoles/bower_components/papaparse $ ls -1
>>>>>> bower.json
>>>>>> Gruntfile.js
>>>>>> LICENSE
>>>>>> package.json
>>>>>> papaparse.js
>>>>>> papaparse.min.js
>>>>>> README.md
>>>>> Yeah, so typical one-file lib. It should have the file mapped directly
>>>>> and
>>>>> "papaparse" should be the full module name.
>>>>>
>>>>>> On 4/12/15, Vicnet<[hidden email]>   wrote:
>>>>>>>> Did you map "." consciously?
>>>>>>> No, just try different values until ok.
>>>>>>>
>>>>>>>
>>>>>>>> IOW, is papaparse set of many files and so
>>>>>>>> you need to map the path and use it as a prefix? Mostly, libraries
>>>>>>>> consist of just one usable file and then that one should be mapped
>>>>>>>> to
>>>>>>>> use the name directly to load the modu
>>> le.
>>>>>>>>
>>>>>>>   Ok, thanks for the explanation.
>>>>>>> I will correct my code nearly.
>>>>>>>
>>>>>>> a+
>>>>>>> Vicnet
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups
>>>>>>> "amber-lang" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send
>>>>>>> an
>>>>>>> email to [hidden email]
>>>>> om.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups
>>>>> "amber-lang" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an
>>>>> email to [hidden email].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "amber-lang" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> email to [hidden email].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

NorbertHartl
In reply to this post by Herby Vojčík

Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:

- The assumption that everything in an amd.json file is a bower_module makes use ../../dir/[basename of js file] a lot

NOT TRUE.

I mean if I create io-local.amd.json file with the following content

{
    "paths": {
        "io-local" : "../../js/deps"
    }
}

then the amdconfig:app fails. As long as I can see it expects a directory under bower_components. Doing a 

$ mkdir bower_components/io-local

makes grunt devel finish.

Norbert


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Herby Vojčík
Of course you must have directory foo if you have foo.amd.json. That what it's about. Read herby/amd-config-builder README.

But no one ever said it must in bower_components. It's recommended to bring external dependencies via bower, though.

Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl <[hidden email]> napísal:

Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:

- The assumption that everything in an amd.json file is a bower_module makes use ../../dir/[basename of js file] a lot

NOT TRUE.

I mean if I create io-local.amd.json file with the following content

{
    "paths": {
        "io-local" : "../../js/deps"
    }
}

then the amdconfig:app fails. As long as I can see it expects a directory under bower_components. Doing a 

$ mkdir bower_components/io-local

makes grunt devel finish.

Norbert


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Herby Vojčík
In reply to this post by NorbertHartl


Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl <[hidden email]> napísal:

>
> > Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:
> >
> >> - The assumption that everything in an amd.json file is a
> bower_module makes use ../../dir/[basename of js file] a lot
> >
> > NOT TRUE.
>
> I mean if I create io-local.amd.json file with the following content
>
> {
>     "paths": {
>         "io-local" : "../../js/deps"

You don't get what foo.amd.json is about. It's not about consumer-of-dependencies foo, it's about provider-of-dependency foo. In no case you should use .. in paths mapping, it means you do something wrong.

>     }
> }
>
> then the amdconfig:app fails. As long as I can see it expects a
> directory under bower_components. Doing a
>
> $ mkdir bower_components/io-local
>
> makes grunt devel finish.
>
> Norbert

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

NorbertHartl
In reply to this post by Herby Vojčík

Am 13.04.2015 um 18:56 schrieb Herby Vojčík <[hidden email]>:

Of course you must have directory foo if you have foo.amd.json. That what it's about. Read herby/amd-config-builder README.

But no one ever said it must in bower_components. It's recommended to bring external dependencies via bower, though.

It is not an external dependency. It is part of the app that depends on other things. Noone said it must be in bower_components but the code only works if it is there. Well, it could be a misconfiguration from my side but I cannot see it.

Norbert


Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl <[hidden email]> napísal:

Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:

- The assumption that everything in an amd.json file is a bower_module makes use ../../dir/[basename of js file] a lot

NOT TRUE.

I mean if I create io-local.amd.json file with the following content

{
    "paths": {
        "io-local" : "../../js/deps"
    }
}

then the amdconfig:app fails. As long as I can see it expects a directory under bower_components. Doing a 

$ mkdir bower_components/io-local

makes grunt devel finish.

Norbert




--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

NorbertHartl
In reply to this post by Herby Vojčík

Am 13.04.2015 um 19:01 schrieb Herby Vojčík <[hidden email]>:



Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl <[hidden email]> napísal:

Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:

- The assumption that everything in an amd.json file is a
bower_module makes use ../../dir/[basename of js file] a lot

NOT TRUE.

I mean if I create io-local.amd.json file with the following content

{
   "paths": {
       "io-local" : "../../js/deps"

You don't get what foo.amd.json is about. It's not about consumer-of-dependencies foo, it's about provider-of-dependency foo. In no case you should use .. in paths mapping, it means you do something wrong.

I know that I don't get it. Otherwise I wouldn't write that much mails. To me foo.amd.json is supposed to define a symbol foo and associate it with an location = base path of the resource where relative resources are looked up.
I try to build an ionic app with amber inside. So my directory layout is

project root/
    amber/
        io-local.amd.json
        js -> symlink to ../../www/js
    ionic/
        www/
            js/
                deps.json
                app.js
                controllers.js
                services.js

The reason for this is that I have to shells for the web app. One is amber and one is ionic. The www folder of ionic gets deployed in the native app. As I don't want to have every file doubled there are symlinks.

Now I want to load app.js, controllers.js and services.js as late as possible. Minimum requirement is that it loads ionic before. ionic is a module in bower_components. deps.json defines a module for the three js files. But there seems to be no way (that I see) to load it that way and treat as dependency target.

So what I'm doing wrong?

Norbert



   }
}

then the amdconfig:app fails. As long as I can see it expects a
directory under bower_components. Doing a 

$ mkdir bower_components/io-local

makes grunt devel finish.

Norbert

-- 
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Herby Vojčík


Dňa 13. apríla 2015 20:33:42 CEST používateľ Norbert Hartl <[hidden email]> napísal:

>
> > Am 13.04.2015 um 19:01 schrieb Herby Vojčík <[hidden email]>:
> >
> >
> >
> > Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl
> <[hidden email] <mailto:[hidden email]>> napísal:
> >>
> >>> Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:
> >>>
> >>>> - The assumption that everything in an amd.json file is a
> >> bower_module makes use ../../dir/[basename of js file] a lot
> >>>
> >>> NOT TRUE.
> >>
> >> I mean if I create io-local.amd.json file with the following
> content
> >>
> >> {
> >>    "paths": {
> >>        "io-local" : "../../js/deps"
> >
> > You don't get what foo.amd.json is about. It's not about
> consumer-of-dependencies foo, it's about provider-of-dependency foo.
> In no case you should use .. in paths mapping, it means you do
> something wrong.
>
> I know that I don't get it. Otherwise I wouldn't write that much
> mails. To me foo.amd.json is supposed to define a symbol foo and

No. Look the README mentioned below. The symbol it defines xan be any. Look in helios, for example. There is lots of .amd.json files there.

> associate it with an location = base path of the resource where
> relative resources are looked up.
> I try to build an ionic app with amber inside. So my directory layout
> is
>
> project root/
>     amber/
>         io-local.amd.json

Why are you creating file named io-local.amd.json at all if you don't have ditectoru io-local in project? As I said, read the README in github repo herby/amd-config-builder and understand the purpose of .amd.json files.

>         js -> symlink to ../../www/js
>     ionic/
>         www/
>             js/
>                 deps.json
>                 app.js
>                 controllers.js
>                 services.js
>
> The reason for this is that I have to shells for the web app. One is
> amber and one is ionic. The www folder of ionic gets deployed in the
> native app. As I don't want to have every file doubled there are
> symlinks.
>
> Now I want to load app.js, controllers.js and services.js as late as
> possible. Minimum requirement is that it loads ionic before. ionic is
> a module in bower_components. deps.json defines a module for the three

Json? It is just data. It does nothing.

> js files. But there seems to be no way (that I see) to load it that
> way and treat as dependency target.

Everything can be loaded, it just must have a mapping and if it is legacy, not amd module, it must list of dependencies and global that is exported shimmed.

>
> So what I'm doing wrong?

Probably lots of details. You must endure the pain for a while umtil it all clicks, I presume.

>
> Norbert

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

NorbertHartl
Herby,

thanks for your info. If my previous mails sounded a bit harsh I like to apologize. But after a few hours getting more and more confused I was (let's say) slightly frustrated.

> Am 13.04.2015 um 21:14 schrieb Herby Vojčík <[hidden email]>:
>
>
>
> Dňa 13. apríla 2015 20:33:42 CEST používateľ Norbert Hartl <[hidden email]> napísal:
>>
>>> Am 13.04.2015 um 19:01 schrieb Herby Vojčík <[hidden email]>:
>>>
>>>
>>>
>>> Dňa 13. apríla 2015 17:17:57 CEST používateľ Norbert Hartl
>> <[hidden email] <mailto:[hidden email]>> napísal:
>>>>
>>>>> Am 13.04.2015 um 15:36 schrieb Herby Vojčík <[hidden email]>:
>>>>>
>>>>>> - The assumption that everything in an amd.json file is a
>>>> bower_module makes use ../../dir/[basename of js file] a lot
>>>>>
>>>>> NOT TRUE.
>>>>
>>>> I mean if I create io-local.amd.json file with the following
>> content
>>>>
>>>> {
>>>>   "paths": {
>>>>       "io-local" : "../../js/deps"
>>>
>>> You don't get what foo.amd.json is about. It's not about
>> consumer-of-dependencies foo, it's about provider-of-dependency foo.
>> In no case you should use .. in paths mapping, it means you do
>> something wrong.
>>
>> I know that I don't get it. Otherwise I wouldn't write that much
>> mails. To me foo.amd.json is supposed to define a symbol foo and
>
> No. Look the README mentioned below. The symbol it defines xan be any. Look in helios, for example. There is lots of .amd.json files there.
>
>> associate it with an location = base path of the resource where
>> relative resources are looked up.
>> I try to build an ionic app with amber inside. So my directory layout
>> is
>>
>> project root/
>>    amber/
>>        io-local.amd.json
>
> Why are you creating file named io-local.amd.json at all if you don't have ditectoru io-local in project? As I said, read the README in github repo herby/amd-config-builder and understand the purpose of .amd.json files.
>
>>        js -> symlink to ../../www/js
>>    ionic/
>>        www/
>>            js/
>>                deps.json
>>                app.js
>>                controllers.js
>>                services.js
>>
>> The reason for this is that I have to shells for the web app. One is
>> amber and one is ionic. The www folder of ionic gets deployed in the
>> native app. As I don't want to have every file doubled there are
>> symlinks.
>>
>> Now I want to load app.js, controllers.js and services.js as late as
>> possible. Minimum requirement is that it loads ionic before. ionic is
>> a module in bower_components. deps.json defines a module for the three
>
> Json? It is just data. It does nothing.
>
That was a typo. I meant deps.js

>> js files. But there seems to be no way (that I see) to load it that
>> way and treat as dependency target.
>
> Everything can be loaded, it just must have a mapping and if it is legacy, not amd module, it must list of dependencies and global that is exported shimmed.
>
>>
>> So what I'm doing wrong?
>
> Probably lots of details. You must endure the pain for a while umtil it all clicks, I presume.

I had module definitions that had at the same time directories with the same name in bower_components. Whatever I did it tried loading it from bower_components making me think it was always looking for names of an amd.json file. To me the directory scanning is completely counter intuitive and while being useful has all sorts of gotchas.
Now I defined most single sources just in local.amd.json and added shim depends for them. That worked out well so I could even remove the nested require statements in the index.html.
Taking my filesystem into account using ".." looks indeed feasible because of my special case. I changed that to look being part of the project but those are just symlinks pointing to a ../../… resource directory. I can't see a better way doing it.

One of the gotchas of the directory scanning turned out to be a bug. You can check that by installing the bower component googlemaps-amd. They have a directory named hasOwnProperty under a test hierarchie. The semantics of remembering directory names does not work if the property is already present. For that it would be needed to exclude the properties of Object when building the map. I can provide a fix for it and I hope I find some time this week.

Norbert

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bower install javascript lib but not include in config.js

Herby Vojčík


Norbert Hartl wrote:
> Herby,
>
> thanks for your info. If my previous mails sounded a bit harsh I like
> to apologize. But after a few hours getting more and more confused I
> was (let's say) slightly frustrated.

No need to apologize, my communication is also not salonfahig. ;-)

>
> I had module definitions that had at the same time directories with
the same name in bower_components. Whatever I did it tried loading it
from bower_components making me think it was always looking for names of
an amd.json file. To me the directory scanning is completely counter
intuitive and while being useful has all sorts of gotchas.

Sure, but it was the simplest at the time that is not hardcoded to any
"place to search" like bower_components, which was the primary goal from
the beginning (that's why I get angry when people tell it is bound to
that dir). I did not thought of use case where same directories are
there at the same level of deepness often. When they happen, bad luck,
but simple things are simple are hard things are hard. If you must have
same directories try to make it so that the ones that are needed to be
found are less deep than those others instances of them.

> Now I defined most single sources just in local.amd.json and added
shim depends for them. That worked out well so I could even remove the
nested require statements in the index.html.

Sure, that's what I wanted to suggest, as well - once you have
dependencies set up, you can just require(["app"], ...) and just have
all needed things listed in deploy.js (later you can even take it away
from there and put it locally where they belong using packages'
`imports:` if they are needed specifically by a few Amber packages (if
they are needed by app as a whole, deploy.js is a good place)).

> Taking my filesystem into account using ".." looks indeed feasible
because of my special case. I changed that to look being part of the
project but those are just symlinks pointing to a ../../… resource
directory. I can't see a better way doing it.

All amd.json files specify what is _inside_ a module filetree, not
outside of it. Since the search goes over the whole project tree, you
can have those modules in different places all over the tree, but
amd-config-builder which is used in grunt devel and grunt deploy finds
them and generates proper config.js for you.

../ is tight coupling of separate pieces. Not the right thing to do.

If it is all local to your project, you can put it in local.amd.json;
but if you treat any part of it external, even just a bit (like, it is
taken from different source, may be updated, maybe moved to other
location etc.; IOW it is external even if installed by hand), that's
what libdir.amd.json files are there for, as you probably understood
from the README.

IOW, it is all about keeping mapping local to the resource it maps, so
the pieces are loosely coupled. You can also get a big picture by
reading "Lego pieces metaphor" page from the amber wiki.

> One of the gotchas of the directory scanning turned out to be a bug.
> You can check that by installing the bower component googlemaps-amd.
> They have a directory named hasOwnProperty under a test hierarchie.
> The semantics of remembering directory names does not work if the
> property is already present. For that it would be needed to exclude
> the properties of Object when building the map. I can provide a fix
> for it and I hope I find some time this week.

Oh. Sure, I just use plain object-as-a-map. It must blow if a dir is
named like an existing property (which idiot would name a directory
hasOwnProperty, including the spelling?!)

> Norbert

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
12