【发布时间】:2017-08-04 16:11:49
【问题描述】:
当我想创建一个空的(!) - non angular-cli - 应用程序时,我很难知道应该使用哪些包/库。
当我在 npmjs 中搜索 angular2 时,我得到了不需要的结果,我需要点击:
为了到达messy list,我不知道一个模块是否可以与另一个模块一起使用:
另外 - 即使我使用 @angular/core js ,我也不知道应该包含哪些文件才能使用其他组件。
让我们举个例子 - 我想使用 HTTP - The messy list doesn't contain any http in there 当我转到 docs - 我看到它来自 @angular/http 然后我再次转到 npmjs 并输入 @angular/http 然后我使用unpkg.com 来访问文件系统(使用 unpkg.com 的 chrome 扩展名)只是为了下载 js 文件:
这非常不友好。 (更不用说经常对包进行更改 - 但互联网永远不会忘记)
我不想使用 angular-cli 并且不想下载我不知道它们做什么的东西(如果我需要它们)。
所以我问:
问题
jQuery 有一个download builder page,它允许您选择要下载的内容 - 根据您的需要!我如何才能(对于 angular2)只下载我需要的组件(及其依赖组件)?
例如 - 我正在查看 at this basic angular 2 - plunker 的 system.js 的地图部分
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
// other libraries
'rxjs': 'npm:rxjs@5.0.1',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
'typescript': 'npm:typescript@2.0.10/lib/typescript.js',
},
plunker 的作者是如何知道哪些软件包(除了看起来合法的common/core/http/router 软件包)要下载?
有人可以澄清一下还是我做错了?
【问题讨论】:
-
为什么不直接使用现有的快速启动/种子项目?
-
@jonrsharpe 作为一名高级开发人员——我不觉得想了解我在下载什么很奇怪——尤其是在从头开始启动 ng2 时。而且我希望事情会更容易找到 - 除非 - 再次 - 我做错了。
-
那你为什么不从
@angular/core开始,看看你得到了什么错误? -
当您查看初始启动文件时:main.ts、app.module.ts、app.component.ts,您会发现导入语句如:
import { Component } from '@angular/core'。这为您提供了有关要加载哪些模块以及为什么要加载的线索。在加载它们时,有时还需要导入一些依赖模块(即@angular/common) -
从官方文档开始总是一个好主意,然后逐步缩小到您需要的唯一包。 angular.io/docs/ts/latest/quickstart.html
标签: javascript angularjs angular npm