z--
z--

Reputation: 2236

How to add a non-Amber library with bower? (for example processing js)

I have started a project with amber init and then bower install processing --save to get processing.js added. I do the initialisation with

firstProcessingInstance

     <return Processing.instances[0]>

This method is called by the instance method initializeand it worked a pre-Amber v0.13 version.

How do I initialize Processing.js in Amber 0.13 and 0.14?

The code of the example is here

Addition after answer by Herby

In version 0.13 and 0.14 a configuration file processing.amd.json has to be added manually to the root directory. Files libraryname.amd.json in the root directory of the project are needed if the library does not have a local.amd.json file in the library directory.

Examples for libraryname.amd.json files from Amber Smalltalk and Helios are

project amber; file jquery.amd.json

{
"paths": {
           "jquery": ["dist/jquery", "jquery"]
         }
}

project amber; file es5-shim.amd.json

{
"paths": {
           "amber_lib/es5-shim": "."
         }
}

project helios; file showdown.amd.json

{
"paths": {
    "helios/showdown": "src/showdown"
}
}

project: https://github.com/hhzl/Amber-snapsvg-demo file: snap.svg.amd.json

{
"paths": {
          "snap.svg" : "dist/snap.svg"
         }
}

References

Question

What is wrong with this processing.amd.json library mapping file?

{
"paths": {
            "processing" : "processing"
         }
}

Note After a change in processing.amd.json run grunt devel

Upvotes: 0

Views: 362

Answers (1)

user1046334
user1046334

Reputation:

Adding external non-Amber library to the project involves more steps than just bower install. You must create libdir.amd.json in root of the project with mapping the library file to the symbolic name. Then, you should add the symbolic name into either deploy.js or devel.js (depending on the context in which it is used), outside the place intended for amber packages (that is, not between the two delimiter comments).

EDIT: There is nothing wrong with the cited processing.amd.json, it's right and correct. With this, "processing" module name is mapped to .../processing/processing (.js is omitted from AMD mapping by design). After all, see your config.js to check the mapping is correct. If you have problems loading processing.js, it is outside this domain (.amd.json and Amber's mappings).

Upvotes: 1

Related Questions