^ 1.0.0-beta.11-webpack“现在使用core-js进行polyfills。
我正在尝试导入地图以在我的应用程序中使用
import {Map} from 'core-js/es6/map'
//import {Map} from 'core-js/library/es6/map'
export function updatePayload(data: any, isDataValid: boolean): Map<string, any> {
const payload: Map<string, any> = new Map<string, any>()
payload.set('data', data)
payload.set('isDataValid', isDataValid)
return payload
}
Run Code Online (Sandbox Code Playgroud)
我什至使用以下命令添加了core-js d.ts文件
npm install --save @types/core-js (typescript 2.0 is used)
Run Code Online (Sandbox Code Playgroud)
但是,两个导入都不会解析Map符号。
我想念什么?
我现在可以使用Map实体,但是即使可以设置/获取地图键/值,在控制台中也会出现很多错误。
client:49 [default] J:\workspace\angular2\ts\epimss\node_modules\@types\core-js\index.d.ts:21:13
Duplicate identifier 'PropertyKey'.errors @ client:49sock.onmessage @ client:83EventTarget.dispatchEvent @ eventtarget.js:51(anonymous function) @ main.js:274SockJS._transportMessage @ main.js:272EventEmitter.emit @ emitter.js:50WebSocketTransport.ws.onmessage @ websocket.js:35wrapFn @ zone.js:769ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423 …Run Code Online (Sandbox Code Playgroud) 我们正在Angular 2项目中使用Angular CLI。该项目使用一个大型SVG,该SVG存储在node_modules文件夹中,并且需要在运行时下载svg。
如果我们将其添加到angular-cli.json
"addons": [
"../node_modules/my_module/**/*.svg"
],
Run Code Online (Sandbox Code Playgroud)
然后require(../node_modules/my_module/icons.svg);在我们的组件之一中,svg文件被散列并按预期工作。
该解决方案的问题是测试失败,业力输出:
ERROR in ./node_modules/my_module/icons.svg
Module parse failed: path-to-svg/node_modules/my_module/icons.svg Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <svg>
| <defs>
Run Code Online (Sandbox Code Playgroud)
问题是将这个文件包含在捆绑程序中的正确方法是什么?
Karma.conf.js:
module.exports = function (config) {
config.set({
basePath: '../',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov' …Run Code Online (Sandbox Code Playgroud) 我已经开始研究Angular CLI生成的项目,并意识到我忘记了--style=sass标志.有没有办法转换我的项目以使用Angular CLI启用SASS?
我现在正在写两个新网站.两者都有很多功能.是否可以使用angular来编写小组件/模块并在其他应用程序中重用它们?它的项目结构是什么,或者我可以使用ng-cli的结构?
reusability angular-module angular-cli angular-components angular
我正在使用angular-cli(测试版26)。对于本地开发来说,它很棒,但是我正在努力查看它如何适合更严重的“一次构建,多次部署”类型的管道?
我正在使用的内置概念environment来存储特定于环境的信息,例如连接字符串。但是我需要在构建时使用来指定环境ng build --environment=xyz。这基本上意味着我必须为每个部署重新构建。理想情况下,我想在运行时选择我的环境(例如,可以使用ASP.NET Core进行选择)。
我在这里想念什么吗?有没有其他方法可以解决此问题?
当我运行ng serve时,它使用默认环境作为dev。有没有一种方法可以更新angular cli以使用其他环境文件?
更新资料
抱歉,我的问题应该更清楚了。我知道我们可以使用--env开关来指定要使用的环境文件,但是想知道是否可以在未指定env的情况下更改默认的环境文件选择。当前我们有environment.local.ts文件,当没有指定环境时,我试图将angular cli配置更新为使用environment.local.ts。
我正在尝试在TeamCity构建服务器上运行Angular CLI项目的单元测试.
如果我使用命令:
ng test --single-run --code-coverage
Run Code Online (Sandbox Code Playgroud)
然后,正如预期的那样,我得到了测试覆盖率报告,但是各个测试结果没有显示在TeamCity中.
如果我打开TeamCity报告:
ng test --single-run --code-coverage --reporters teamcity
Run Code Online (Sandbox Code Playgroud)
然后测试通过并且TeamCity报告完美地工作,但它无声地生成代码覆盖率报告.此行为在我的本地计算机上是可重现的,因此它与构建服务器的配置方式无关.
有这两个选项应该互相排斥的原因吗?
注意 - 这与在TeamCity上为Karma配置代码覆盖率报告不同.如果报告在那里,那么TeamCity会正确显示它,但如果我打开TeamCity报告标志,那么coverage文件夹就不存在了.
附加信息:
业力配置:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma'),
require('karma-teamcity-reporter')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false …Run Code Online (Sandbox Code Playgroud) 在我的AWS机器上,我创建了一个Angular 2 Web应用程序@angular/cli.我已经尝试用yarn/ 安装所有软件包npm但它似乎并没有安装所有软件包,因为当我进入网站时它不会注入任何提供程序而且它无法正常呈现.
我已经删除的整个文件夹node_modules/ .npm/cache yarn/cache与重新安装的一切yarn和npm,但它也不管用.
我的package.json:
{
"name": "seon.site-builder.ui",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.24",
"@ngx-translate/core": "^6.0.0",
"@ngx-translate/http-loader": "^0.0.3",
"angular2-esri-loader": "^0.1.11",
"angular2-esri4-components": "^0.5.0",
"bootstrap": "4.0.0-alpha.6", …Run Code Online (Sandbox Code Playgroud) 我有一个工作的ng cli项目,它是用cli 的beta.21版本创建的.我想更新它以使用cli项目的最新结构,因此使用cli(v.1.0.0)创建了一个新项目.然后,我基本上将现有项目应用程序文件的内容放入新项目中并从那里开始.
奇怪的是,我的新项目构建没有问题,并产生我期待的大小和块.如果我运行基于快速的后端,它提供./dist目录的内容,那么我的应用程序按预期工作.但是,如果我运行,ng serve我会Cannot GET /在浏览器中收到错误.
我真的不确定是什么导致这个(我最大的怀疑是我的项目有文件结构client/src/app而不是标准,src/app但是我已经改变了所有对文件路径的引用我可以找到并且随着构建工作,我假设那很好)?
关于如何进一步调试的任何想法/建议?
client/src/index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>DemoProj</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
.angular-cli.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "coty-monitoring-system"
},
"apps": [
{
"root": "client/src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json", …Run Code Online (Sandbox Code Playgroud) 8月28日更新:下面完全相同的软件包配置,但zone.js 0.8.16不会产生任何错误.知道为什么吗?
编辑:我一直试图找出问题的来源.如果这是一个无限循环,它究竟发生了什么,但我无法破解polyfill或vendor中的代码.
我正在使用Firebase Hosting部署我的Angular应用程序.使用localhost进行编译和测试时,一切正常.但是当我在Firebase Hosting上部署时,我的实时站点永远无法绕过使用Auth0登录,在控制台中无休止地给出了同样的错误.如何确切地找出导致错误的原因?
Uncaught RangeError: Maximum call stack size exceeded
(anonymous) @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
o.(anonymous function) @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
(anonymous) @ vendor.bd83d2a24392414468c4.bundle.js:1
_makeRequest @ vendor.bd83d2a24392414468c4.bundle.js:1
_sendProcessedPayload @ vendor.bd83d2a24392414468c4.bundle.js:1
_send @ vendor.bd83d2a24392414468c4.bundle.js:1
_processException @ vendor.bd83d2a24392414468c4.bundle.js:1
_handleStackInfo @ vendor.bd83d2a24392414468c4.bundle.js:1
captureException @ vendor.bd83d2a24392414468c4.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r @ vendor.bd83d2a24392414468c4.bundle.js:1
L @ polyfills.70fc3f963669a0ddfcd2.bundle.js:1
r …Run Code Online (Sandbox Code Playgroud)angular-cli ×10
angular ×7
webpack ×2
auth0 ×1
deployment ×1
istanbul ×1
npm ×1
reusability ×1
sass ×1
teamcity ×1
yarnpkg ×1
zonejs ×1