Skip to content

Cannot "import as" with prod build #13577

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

Closed
1 task done
rhino5oh opened this issue Feb 2, 2019 · 5 comments
Closed
1 task done

Cannot "import as" with prod build #13577

rhino5oh opened this issue Feb 2, 2019 · 5 comments

Comments

@rhino5oh
Copy link

rhino5oh commented Feb 2, 2019

  • build

Regression?

I believe so, however, I do not recall the exact last version that it worked

Description

In all of my routing modules, I have the following import:
import { AuthGuardService as AuthGuard } from './../auth/auth-guard.service'

And I use it like so:

const scatRoutes: Routes = [
  { path: 'scat', component: ScatComponent, canActivate: [AuthGuard]  }
];

When I do a prod build, such as:
ng build --prod --source-map

I get the following error when I attempt to access my application (served via Express.js):

ReferenceError: AuthGuard is not defined

Note: I do not have this problem with a regular, non-prod build, e.g. 'ng build'

Also, removing the "as" part of the import, and simply importing the class name itself, does in fact work. So it appears to be in issue with doing import "as". In other words, it works if I change the import to this:

import { AuthGuardService } from './../auth/auth-guard.service'

Here's my environment:

Angular CLI: 7.3.0
Node: 8.11.3
OS: win32 x64
Angular: 7.2.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.10.2
@angular-devkit/build-angular     0.10.2
@angular-devkit/build-optimizer   0.10.2
@angular-devkit/build-webpack     0.10.2
@angular-devkit/core              7.0.2
@angular-devkit/schematics        7.3.0
@angular/cdk                      7.3.0
@angular/cli                      7.3.0
@angular/material                 7.3.0
@ngtools/webpack                  7.0.2
@schematics/angular               7.3.0
@schematics/update                0.13.0
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.19.1

@alan-agius4
Copy link
Collaborator

Hi, kindly update @angular-devkit/build-angular to the lastest version.

Duplicate of
#13212

@rhino5oh
Copy link
Author

rhino5oh commented Feb 2, 2019

why doesn't ng update show me that I need to update any @angular-devkit/* packages?

I submitted an issue for this: #13581

@rhino5oh
Copy link
Author

rhino5oh commented Feb 2, 2019

Also, I updated @angular-devkit/build-angular, now I'm getting this build error:

ERROR in scripts.b0500e1e41820f3b46e0.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (C:\<removed>\node_modules\terser-webpack-plugin\dist\minify.js:175:23)
    at module.exports (C:\<removed>\node_modules\terser-webpack-plugin\dist\worker.js:13:40)
    at handle (C:\<removed>\node_modules\worker-farm\lib\child\index.js:44:8)
    at process.<anonymous> (C:\<removed>\node_modules\worker-farm\lib\child\index.js:51:3)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Edit: just saw someone submitted a bug for this. #13582

@silver-software
Copy link

I have this error also. How can I fix this issue?

@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants