简体   繁体   中英

How to load external librarie i.e. moment.js in Amber-Smalltalk?

I don't get moment.js or other external libraries like tinymce working in my amber application.

These are the steps I did so far:

  1. run bower install moment --save
  2. added a moment.and.json in my applications root directory containing the correct path in bower_components: {"paths": {"moment": "moment"}}
  3. added "moment" to deploy.js
  4. run grunt devel

My first problem is that from inside the js console momentjs seems to be not loaded, even if the file shows up in network traffic.

After that how do I use moment.js from inside Amber? How do I need to wrap it?

I read how-to-add-a-non-amber-library-with-bower-for-example-processing and all the other explanations but still have problems grabbing the exact process.

All the documentation I read was inconclusive to me. Isn't there a simple explanation on how to do it?

The amd file has to look like this:

{
    "paths": {
       "moment": "moment"
    },
    "shim": {
       "moment": {
         "exports": "moment"
       }
    },
    "config": {
       "moment": {
         "noGlobal": false
       }
    }
}

As it seems it has to be required like this to work properly: window.moment = require('moment');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM