2015-03-05 10 views
8

aşağıdaki komutu kullanarak, css eklentisini yüklediğinizde:JSPM eklentileri yüklerken config.js'ye bağımlılıkları eklemek nasıl engellenir?

jspm install css 

benim config.js eklenir aşağıdadır:

System.config({ 
    "map": { 
    "css": "github:systemjs/[email protected]", 
    "github:jspm/[email protected]": { 
     "assert": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "buffer": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "events-browserify": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "Base64": "npm:[email protected]", 
     "events": "github:jspm/[email protected]", 
     "inherits": "npm:[email protected]", 
     "stream": "github:jspm/[email protected]", 
     "url": "github:jspm/[email protected]", 
     "util": "github:jspm/[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "https-browserify": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "os-browserify": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "path-browserify": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "process": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "stream-browserify": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "url": "npm:[email protected]" 
    }, 
    "github:jspm/[email protected]": { 
     "util": "npm:[email protected]" 
    }, 
    "github:systemjs/[email protected]": { 
     "clean-css": "npm:[email protected]", 
     "fs": "github:jspm/[email protected]", 
     "path": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "fs": "github:jspm/[email protected]", 
     "module": "github:jspm/[email protected]", 
     "path": "github:jspm/[email protected]", 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "util": "npm:[email protected]" 
    }, 
    "npm:[email protected]": { 
     "base64-js": "npm:[email protected]", 
     "ieee754": "npm:[email protected]", 
     "is-array": "npm:[email protected]" 
    }, 
    "npm:[email protected]": { 
     "buffer": "github:jspm/[email protected]", 
     "commander": "npm:[email protected]", 
     "fs": "github:jspm/[email protected]", 
     "http": "github:jspm/[email protected]", 
     "https": "github:jspm/[email protected]", 
     "os": "github:jspm/[email protected]", 
     "path": "github:jspm/[email protected]", 
     "process": "github:jspm/[email protected]", 
     "source-map": "npm:[email protected]", 
     "url": "github:jspm/[email protected]", 
     "util": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "child_process": "github:jspm/[email protected]", 
     "events": "github:jspm/[email protected]", 
     "path": "github:jspm/[email protected]", 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "buffer": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "http": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "util": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "os": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "buffer": "github:jspm/[email protected]", 
     "core-util-is": "npm:[email protected]", 
     "events": "github:jspm/[email protected]", 
     "inherits": "npm:[email protected]", 
     "isarray": "npm:[email protected]", 
     "process": "github:jspm/[email protected]", 
     "stream": "npm:[email protected]", 
     "string_decoder": "npm:[email protected]", 
     "util": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "amdefine": "npm:[email protected]", 
     "fs": "github:jspm/[email protected]", 
     "path": "github:jspm/[email protected]", 
     "process": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "events": "github:jspm/[email protected]", 
     "inherits": "npm:[email protected]", 
     "readable-stream": "npm:[email protected]" 
    }, 
    "npm:[email protected]": { 
     "buffer": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "assert": "github:jspm/[email protected]", 
     "punycode": "npm:[email protected]", 
     "querystring": "npm:[email protected]", 
     "util": "github:jspm/[email protected]" 
    }, 
    "npm:[email protected]": { 
     "inherits": "npm:[email protected]", 
     "process": "github:jspm/[email protected]" 
    } 
    } 
}); 

nasıl amacıyla düzenli benim config.js tutabilir Tüm bu bilgileri tüm sayfalarda da eklemekten kaçının (config.js'nin her sayfaya dahil olması gerektiğinden)? Burada fazla JSPM yeniyim ve büyük config.js boyutları hakkında benzer bir tepki vardı, ama

+1

config.js'de bildirilen birçok bağımlılık olsa bile, bunların hepsinin uygulama tarafından yükleneceği anlamına gelmez. System.js yalnızca aldığınız bağımlılıkları (veya require()) yükler. –

+0

Teşekkür ederiz @AdrianMitev. Bunu biliyorum, her sayfada 15-20kb dahil etmekten kaçınmaya çalışıyorum (kullandığım kitaplıkların bağımlılıkları) –

+0

Tarayıcı her sayfaya yüklenmeyecek şekilde uygun önbellek başlıkları ekleyin. –

cevap

7

öğrendiğim birkaç şey var:

1) Düğüm modülleri için JSPM kullanmayacağı kadar sadece Sunucu tarafında/geliştirme makinesinde kullanmak istiyorum. Sadece bunlar için NPM'yi kullanmaya devam edebilirsiniz. Bu hatayı yaptım - JSPM'yi tüm bağımlılıklar için kullanmam gerektiğini düşünerek hem Bower hem de NPM'yi değiştirdim. JSPM aracılığıyla gulp'u yükledim ve config.js'm aniden 700 satırın üzerindeydi! 2) Bağımlılıkların tüm bağımlılıkları değil, paketin üst seviyedeki bağımlılıklarını - paket.jsondaki gibi- kaydetmek için yapılandırmanın mümkün olup olmadığını merak ettim ... Ses böyle gelmiyor. Ben Gitter group sordu ve yanıt oldu: "Büyük olduğu gibi, size npm içinde olmayan akran bağımlılıkları üzerinde kontrol sağlar". (Teşekkürler Mitranim).

3) require.js hakkında bilgi sahibi iseniz, config.js dosyanızı require.config(...) numaranız gibi düşünebilirsiniz. Yaptığı şeylerden biri, modüllerinizi dahil etmek için kullanabileceğiniz kısa isimlerinizi oluşturmaktır. Eski bir require.js kullanıcısı olarak, giriş noktası olarak front-ucuma require.js yapılandırma dosyasını eklemem gerektiğini ve config.js için de aynı şeyi kabul ettiğimi kabul ettim - en azından, geliştirme için ...

4) Üretim başka bir konudur. "Guy Bedford on the Gitter group: 'dan alıntı", yapılandırma dosyasının " geliştirilecek olan üretim \ iş akışlarına dahil edilmesi anlamına gelmez." Başlangıç ​​Kılavuzu'nda "Bundle for production" section'da daha fazla bilgi var.) 5) Yararlı bir başlangıç ​​noktası, Jack Franklindemo from Async Brighton. Özellikle not: o, betimlenen komutları sadece minimize edilmiş app.min.js işaret etmek için anahtarlayan üretim için bir paket iş akışına sahiptir - Makefile'a bakın.

+0

Yalnızca css, jquery ve semantic-ui'yi yükledim ve dosyamın zaten 1,743 satırı var. – darkangel

+0

npm modülünü "semantic-ui" için yüklediniz mi? Bu, bir grup diğer Node modüllerini, gulp ve her çeşit gibi çekecek ... Sadece CSS ve JS'yi müşteri tarafında mı istiyorsun? Bu gibi yükleme hakkında: jspm install semantic-ui = github: Semantik-Org/Semantik-UI (Bu, ovucu paketinin ifade ettiği github repo'su) – poshaughnessy

+0

Ayrıca, birisi JSPM kayıt defterine ekleyecekti (https: // github.com/jspm/kayıt defteri) sadece bir dahaki sefere jspm install semantic-ui ' – poshaughnessy