使用ng serve
加载应用程序正常,但使用Unexpected token: punc ())
进行构建时抛出ng build --prod
。使用源地图构建应用程序,并找到由angular-gauge-chart引起的原因。向图书馆开发人员寻求帮助,这就是他们说的:
@maihannijat它是一个库,而不是一个有角度的应用程序。我们用ng服务 命令来运行托管该库的开发环境的应用。 可以使用常用的ng build angular-gauge-chart来构建库 命令。
我导入了模块:
@NgModule({
declarations: [XYZ],
imports: [
...
GaugeChartModule,
]
})
并在组件模板中使用:
<rg-gauge-chart [canvasWidth]="canvasWidth"
[needleValue]="needleValue"
[centralLabel]="centralLabel"
[options]="options"
[name]="name"
[bottomLabel]="bottomLabel">
</rg-gauge-chart>
我确实按照他们的指南在这里说的: https://github.com/recogizer/angular-gauge-chart
我尝试将组件中的库导入为:
import 'angular-gauge-chart';
并从模块中删除,但会引发绑定错误,并要求在模块中插入GaugeChartModule
。
编辑:
调试:
ng build --prod --named-chunks --verbose --build-optimizer=false --source-map
错误:
意外令牌:punc()) [./node_modules/gauge-chart/dist/bundle.js:169,0]
.attr(
'transform',
'translate(' + (n + 2 * e) + ', ' + (n + e) + ')',
)
答案 0 :(得分:1)
版本0.7.1
由于尾随逗号而引发错误。我现在正在使用0.6.0
版,直到开发人员在新版本中解决问题为止。
参考:https://github.com/recogizer/angular-gauge-chart/issues/28
答案 1 :(得分:1)
在bundle.js
中已解决。再次感谢您指出这一点。
对于那些将面临相同问题的人,this answer帮助我找到了问题。在我的情况下,问题出在没有适当的prettier
文件的依赖项中。我的Function EncodeBase64ForString(strString As String) As String
Dim arrData() As Byte
arrData = StrConv(strString, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument60
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument60
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64ForString = objNode.text
Set objNode = Nothing
Set objXML = Nothing
End Function
Public Function GetFileBytes(ByVal strPath As String) As Byte()
Dim lngFileNum As Long
Dim bytRtnVal() As Byte
lngFileNum = FreeFile
If LenB(Dir(strPath)) Then ''// Does file exist?
Open strPath For Binary Access Read As lngFileNum
ReDim bytRtnVal(LOF(lngFileNum) - 1&) As Byte
Get lngFileNum, , bytRtnVal
Close lngFileNum
Else
Err.Raise vbObjectError + 1, , "Could not find " & strPath
End If
GetFileBytes = bytRtnVal
Erase bytRtnVal
End Function
的配置方式是格式化已构建的捆绑软件。因此,一些逗号和其他重要信息丢失了。
答案 2 :(得分:-1)
从'angular-gauge-chart'导入*作为angularGaugeChart;