On 2/1/15, Herby Vojčík <[hidden email]> wrote:
.... > In 0.14.4, finally import feature works in compiler as well, not just in > the core. In Helios, you can see this line in any package template: > > imports: {} > > The '{}' is just a plain dynamic array. Here you specify, which external > modules your package depends upon. Let's say you need snap.svg and > bootstrap and they are known via names 'snag.svg' and 'bootstrap' in > *.amd.json files. You put there > > imports: {'snapSvg' -> 'snap.svg'. 'bootstrap'} > > You then must commit the package _and reload to take effect_. > > When you put just strings in imports (like 'bootstrap'), the module is > just loaded as a package dependency. How would I then use bootstrap? --Hannes -- 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. |
H. Hirzel wrote: > On 2/1/15, Herby Vojčík<[hidden email]> wrote: > .... >> In 0.14.4, finally import feature works in compiler as well, not just in >> the core. In Helios, you can see this line in any package template: >> >> imports: {} >> >> The '{}' is just a plain dynamic array. Here you specify, which external >> modules your package depends upon. Let's say you need snap.svg and >> bootstrap and they are known via names 'snag.svg' and 'bootstrap' in >> *.amd.json files. You put there >> >> imports: {'snapSvg' -> 'snap.svg'. 'bootstrap'} >> >> You then must commit the package _and reload to take effect_. >> >> When you put just strings in imports (like 'bootstrap'), the module is >> just loaded as a package dependency. > > How would I then use bootstrap? Meta question: What is hard here? To get it that even without mapping variable a module is a dependency is guaranteed to be executed before the amber package itself; or the problem is how to get to bootst rap without a variable? I answer the latter: Just as if you just load it with <script>. AFAIK, bootstrap does not wrap itself in any AMD and so it does not exports anything, so even if you would try to import, you would get nil there. Probably bootstrap exposes its JS parts through some global (then, you should can use the global directly). There is a nice AMD way to capture such global-defining modules into AMD system as well. If you want to, try add this to bootstrap.amd.json: "shim": { "bootstrap": { /* maybe some other things. like deps */ "exports": "name-of-the-global-you-can-even-use-dot-notation" } } this way, requirejs waits until that global appears to be defined, once it is, it takes it as a sign that the module is properly loaded, and also returns value of that thing as the export, so you could do: imports: {'bootstrapVariable' -> 'bootstrap'} and use bootstrapVariable (which can be 'bootstrap' of course). Otherwise, you must go th rough the global. > --Hannes 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. |
Free forum by Nabble | Edit this page |