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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/babel-loader/lib/index.js): SyntaxError: node_modules/domino/lib/sloppy.js: 'with' in strict mode #17794

Closed
naveedahmed1 opened this issue May 26, 2020 · 3 comments 路 Fixed by #17831

Comments

@naveedahmed1
Copy link

馃悶 Bug report

Command (mark with an x)

  • [x ] build

Is this a regression?

Yes, the previous version in which this bug was not present was: 10.0.0-next.4

Description

When compiling universal project with latest version of Angular CLI it throws below error:

ng run MyProject:server:production

Hash: 80b40f1bfdc7cfb63b6d
Time: 78337ms
Built at: 05/27/2020 12:05:30 AM
  Asset      Size  Chunks  Chunk Names
main.js  5.35 MiB       0  main
Entrypoint main = main.js
chunk    {0} main.js (main) 8.94 MiB [entry] [rendered]

ERROR in ./node_modules/domino/lib/sloppy.js
Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/babel-loader/lib/index.js):
SyntaxError: D:\MyProject\node_modules\domino\lib\sloppy.js: 'with' in strict mode (10:4)

   8 |   Window_run: function _run(code, file) {
   9 |     if (file) code += '\n//@ sourceURL=' + file;
> 10 |     with(this) eval(code);
     |     ^
  11 |   },
  12 |   EventHandlerBuilder_build: function build() {
  13 |     try {
    at Parser._raise (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:742:17)
    at Parser.raiseWithData (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:735:17)
    at Parser.raise (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:729:17)
    at Parser.parseWithStatement (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11588:12)
    at Parser.parseStatementContent (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11177:21)
    at Parser.parseStatement (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11104:17)
    at Parser.parseBlockOrModuleBlockBody (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11679:25)
    at Parser.parseBlockBody (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11665:10)
    at Parser.parseBlock (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11649:10)
    at Parser.parseFunctionBody (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10656:24)
    at Parser.parseFunctionBodyAndFinish (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10639:10)
    at D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11819:12
    at Parser.withTopicForbiddingContext (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10979:14)
    at Parser.parseFunction (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11818:10)
    at Parser.parseFunctionExpression (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10115:17)
    at Parser.parseExprAtom (D:\MyProject\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10023:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MyProject@0.0.0 build:ssr_ignore_dash_dash_watch_from_AngularCliBuilderDotCS: `ng run MyProject:server:production `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the MyProject@0.0.0 build:ssr_ignore_dash_dash_watch_from_AngularCliBuilderDotCS script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Naveed Ahmed\AppData\Roaming\npm-cache\_logs\2020-05-26T19_05_36_581Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MyProject@0.0.0 build:ssr: `npm run build:ssr_ignore_dash_dash_watch_from_AngularCliBuilderDotCS`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the MyProject@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Naveed Ahmed\AppData\Roaming\npm-cache\_logs\2020-05-26T19_05_36_628Z-debug.log

馃敩 Minimal Reproduction

For reproductions, I can add you to a private repo

馃實 Your Environment


Angular: 10.0.0-rc.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Ivy Workspace: 

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.900.7
@angular-devkit/build-angular              0.1000.0-rc.0
@angular-devkit/build-optimizer            0.900.7
@angular-devkit/build-webpack              0.900.7
@angular-devkit/core                       10.0.0-next.3
@angular-devkit/schematics                 10.0.0-next.3
@angular/cdk                               10.0.0-next.1
@angular/fire                              6.0.0
@angular/google-maps                       10.0.0-next.1
@angular/material                          10.0.0-next.1
@angular/pwa                               0.1000.0-next.3
@ngtools/webpack                           9.0.7
@nguniversal/module-map-ngfactory-loader   9.0.0-next.9
@schematics/angular                        10.0.0-next.3
@schematics/update                         0.1000.0-rc.0
rxjs                                       6.5.5
typescript                                 3.9.3
webpack                                    4.41.2
@alan-agius4
Copy link
Collaborator

I thInk the compilation target of your server bundle is es5, which is requires downlevelling and exposes this bug. As a workaround you can set target to es2015 In your server tsconfig.

Is there any reason why you use ES5 syntax for you server bundle?

@naveedahmed1
Copy link
Author

Thank you so much @alan-agius4 , I can confirm this workaround resolved the issue :)

@alan-agius4 alan-agius4 changed the title Angular CLI 10.0.0-rc.0 throws error - ERROR in ./node_modules/domino/lib/sloppy.js Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/babel-loader/lib/index.js): SyntaxError: D:\MyProject\node_modules\domino\lib\sloppy.js: 'with' in strict mode (10:4) Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/babel-loader/lib/index.js): SyntaxError: node_modules/domino/lib/sloppy.js: 'with' in strict mode May 27, 2020
@alan-agius4 alan-agius4 self-assigned this May 29, 2020
clydin pushed a commit that referenced this issue Jun 1, 2020
The supported versions of Node.js support up to ES2018, the only reason why we don't use ES2017+ is because native `async` and `await` don't work with zone.js

See: angular/angular#31730

With this change, we also ensure that we don't downlevel the server bundle to ES5 which is unnecessary.

Closes: #17794
clydin pushed a commit that referenced this issue Jun 1, 2020
The supported versions of Node.js support up to ES2018, the only reason why we don't use ES2017+ is because native `async` and `await` don't work with zone.js

See: angular/angular#31730

With this change, we also ensure that we don't downlevel the server bundle to ES5 which is unnecessary.

Closes: #17794
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants