ENikS/LINQ

Unexpected token: name (CSharpEnumerator)

Closed this issue · 16 comments

I Use angular-cli to create an angular project, and import linq-es2015.
When I typed:

ng build --prod --aot

there was an error:
8ef7c4cbb4dc50.chunk.js from UglifyJs Unexpected token: name (CSharpEnumerator) [0.4cff4e8ef7c4cbb4dc50.chunk.js:872,6]

Here is a DEMO that can reappearance the problem.

ENikS commented

I am getting these:

ng build --prod --aot

Hash: 49f7c1723ab0805adf33
Time: 9360ms
chunk {0} polyfills.60187f338ba5b0a175a8.bundle.js (polyfills) 157 kB {4} [initial] [rendered]
chunk {1} main.34d479817913c2e259ab.bundle.js (main) 21.1 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.b28ec3831422d17d6458.bundle.js (vendor) 1.1 MB [initial] [rendered]
chunk {4} inline.e0de3f77c7d382fb8ed1.bundle.js (inline) 0 bytes [entry] [rendered]

I can not see the error you mentioned. Perhaps try cloning your project into fresh dir, do install and rebuild?

Hi ENikS, Thanks for your answer.
I update the angular demo project to reappearance the problem.

I ng build --prod --aot at a fresh dir.

ENikS commented

I don't see you following required steps outlined here:
https://github.com/ENikS/LINQ/tree/examples/Angular

Where is your systemjs.config.js?

ENikS commented

It looks like you are running outdated version of CLI (1.0.2). The latest (1.0.3) version compiles and runs just fine. I've updated Angular example to use latest CLI and compiler. Use this sample to troubleshoot your demo.

My Environment:

PS C:\Users\qin_x\GitHub\LINQ\Angular> ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |                   
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.3
node: 6.10.1
os: win32 x64
@angular/common: 4.1.2
@angular/compiler: 4.1.2
@angular/core: 4.1.2
@angular/forms: 4.1.2
@angular/http: 4.1.2
@angular/platform-browser: 4.1.2
@angular/platform-browser-dynamic: 4.1.2
@angular/router: 4.1.2
@angular/cli: 1.0.3
@angular/compiler-cli: 4.1.2

when I finished my project, I need to publish. So I will use ng build --prod --aot to compile angular.
here is an error as below. I use a clone of your Angular example demo project.

PS C:\Users\qin_x\GitHub\LINQ\Angular> ng build --prod --aot
Hash: b328418fa6d59b23c1c9
Time: 6543ms
chunk    {0} polyfills.6ce0bf58446ef5c2585b.bundle.js (polyfills) 157 kB {4} [initial] [rendered]
chunk    {1} main.c41bdfe5ffe65e3d0f1c.bundle.js (main) 22.1 kB {3} [initial] [rendered]
chunk    {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk    {3} vendor.ad3c476facb2f3344732.bundle.js (vendor) 1.14 MB [initial] [rendered]
chunk    {4} inline.fd490338ae1450fbb70b.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in vendor.ad3c476facb2f3344732.bundle.js from UglifyJs
Unexpected token: name (CSharpEnumerator) [vendor.ad3c476facb2f3344732.bundle.js:18488,6]
ENikS commented

Clone sample project and try to build it.

In your package.json you require CLI 1.0.2

"devDependencies": {
    "@angular/cli": "1.0.2",

I cloned your project then ng build --prod --aot.

ENikS commented

... and?

And I got an error like below:

PS C:\Users\qin_x\GitHub\LINQ\Angular> ng build --prod --aot
Hash: b328418fa6d59b23c1c9
Time: 6745ms
chunk    {0} polyfills.6ce0bf58446ef5c2585b.bundle.js (polyfills) 157 kB {4}
 [initial] [rendered]
chunk    {1} main.c41bdfe5ffe65e3d0f1c.bundle.js (main) 22.1 kB {3} [initial
] [rendered]
chunk    {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [i
nitial] [rendered]
chunk    {3} vendor.ad3c476facb2f3344732.bundle.js (vendor) 1.14 MB [initial
] [rendered]
chunk    {4} inline.fd490338ae1450fbb70b.bundle.js (inline) 0 bytes [entry]
[rendered]

ERROR in vendor.ad3c476facb2f3344732.bundle.js from UglifyJs
Unexpected token: name (CSharpEnumerator) [vendor.ad3c476facb2f3344732.bundl
e.js:18488,6]
PS C:\Users\qin_x\Documents\GitHub\LINQ\Angular>
ENikS commented

According to this Uglifyjs does not support ES2015 syntax. If you want to minify your project you have to use babel to transpile it to es5. Read the thread for the explanation and solution for the issue.

You could use ES5 linq-es5 package and stay compatible with Uglifyjs. The packages are binary compatible with linq-es2015 being slightly faster on ES6 browser.

thx.

ENikS commented

Not sure if you still need the minified version but you could use Browserify to compact it

we're using linq-es5 now.

ENikS commented

There is no reason to downgrade performance just because Uglifyjs does not support latest standard. These generators ( functon * ) really do make a difference.

Browserify can do as good of a job if not better to compact packages. There is a minified version in ./dist dictionary if you want to run benchmarks.

Is there a simple example of angular ?

ENikS commented

I do not know.