Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular CLI build optimization fails #243

Closed
RyanHow opened this issue Nov 16, 2018 · 15 comments
Closed

Angular CLI build optimization fails #243

RyanHow opened this issue Nov 16, 2018 · 15 comments

Comments

@RyanHow
Copy link

RyanHow commented Nov 16, 2018

Hi All,

I've been having trouble integrating Cicero into an Angular CLI project.

I'm having 2 separate issues.

The build hangs indefinitely on the composer-concerto\lib\introspect\parser.js file

45% building modules 297/298 modules 1 active ...poser-concerto\lib\introspect\parser.js

If I disable the build optimizer, then the Terser minifier spits the dummy.

ERROR in main.abfced9f8456db47574e.js from Terser
Unexpected token: punc ()) [main.abfced9f8456db47574e.js:188444,4]

So the only way to get a successful production build is to disable the buildOptimizer and minifier, which is not ideal.

I'm just logging this issue here and will follow it up with the Angular CLI team.

You can reproduce this issue with the following steps

git clone https://github.com/RyanHow/angular-cicero-build.git
cd angular-cicero-build
npm install
ng build --prod    <--- This hangs indefinitely
ng build --prod --buildOptimizer=false    <--- This fails
ng build --prod --buildOptimizer=false --optimization=false     <-- This completes

Using
cicero-core 0.9.6
angular 7.0.4
angular cli 7.0.6

@mttrbrts
Copy link
Member

Thanks for the great report @RyanHow. @jeromesimeon , I wonder if this is related to the whitespace issues that you mentioned since the Nearley upgrade? kach/nearley#413

@RyanHow can you share a link to an Angular issue if you have one, please?

@jeromesimeon
Copy link
Member

@mttrbrts That looks unrelated to me? The issue seems to be in composer-concerto. I believe it's using pegjs as a parser. I could look into it.

@jeromesimeon
Copy link
Member

This issue should be filed against https://github.com/hyperledger/composer-concerto

@RyanHow
Copy link
Author

RyanHow commented Nov 18, 2018

Angular CLI issue is here

angular/angular-cli#12975

I've worked around the Terser issue using a custom builder for angular and changing the options for Terser.

I really think the build optimizer is a bug with Angular CLI. It shouldn't just hang indefinitely.

@RyanHow
Copy link
Author

RyanHow commented Nov 18, 2018

So it looks like the issue is a trailing comma in a function call

cicero-core\lib\logger.js
ergo-compiler\lib\logger.js

line 98

let logger = winston.createLogger({
    format: winston.format.combine(
        winston.format.json(),
        enumerateErrorFormat(),
        winston.format.colorize(),
        jsonColor(),    <-------- here
    ),
    transports: [
        new winston.transports.Console({
            level: 'info',
        }),
    ]
});

Angular runs Terser with ecma=6. Apparently by default Terser runs with ecma=8 which allows the trailing comma.

I'll keep following up the build optimizer hanging.

@mttrbrts
Copy link
Member

Thanks @RyanHow for the follow up.

I see that there are a number of other issues beyond this one in cicero-core alone,

/Users/matt/dev/accordproject/cicero/packages/cicero-core/lib/logger.js
  99:5  error  Parsing error: Unexpected token )

/Users/matt/dev/accordproject/cicero/packages/cicero-core/lib/template.js
  650:42  error  Parsing error: Unexpected token =>

/Users/matt/dev/accordproject/cicero/packages/cicero-core/lib/templatelibrary.js
  53:11  error  Parsing error: Unexpected token clearCache

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/clause.js
  36:82  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/contract.js
  33:97  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/grammarvisitor.js
  59:68  error  Parsing error: Unexpected token =>

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/script.js
  35:60  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/scriptmanager.js
  36:57  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/template.js
  35:7  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/templateinstance.js
  30:48  error  Parsing error: Unexpected token function

/Users/matt/dev/accordproject/cicero/packages/cicero-core/test/templatelibrary.js
  29:52  error  Parsing error: Unexpected token function

I'll take a look at either transpiling or converting to ECMA 6/5

@RyanHow
Copy link
Author

RyanHow commented Nov 19, 2018 via email

@mttrbrts
Copy link
Member

Interesting, this is the output from my linter when downgrading the rules to ECMA 6.

I'm happy to cut a release just with the change in logger.js, but I'm keen to fix the problem properly if there is a bigger issue.

@RyanHow
Copy link
Author

RyanHow commented Nov 19, 2018 via email

@RyanHow
Copy link
Author

RyanHow commented Nov 20, 2018 via email

@mttrbrts
Copy link
Member

Yes, thanks @RyanHow, that is helpful.

Can you try again, @accordproject/cicero-core@0.9.7-20181119152855, please that contains a transpiled version of the entire module that should have removed all of the bad code, please?

npm i @accordproject/cicero-core@unstable

@RyanHow
Copy link
Author

RyanHow commented Nov 20, 2018

Yes! It's working now! Thanks! :)

The build optimizer issue looks like a typescript parser issue... not sure of a workaround for that one. I'll file it on the typescript issue tracker and see if anything happens...

@jeromesimeon
Copy link
Member

Just a clarification in this issue:

Transpilation of Cicero targets ES6 (or ECMA2015) not ES5.

@RyanHow can we close this issue?

@RyanHow
Copy link
Author

RyanHow commented Jan 25, 2019 via email

@jeromesimeon
Copy link
Member

Thanks. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants