question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PurifyPlugin require statement for build-optimizer missing in ejected config

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

ng eject --aot --prod --build-optimizer --no-sourcemaps generates a webpack.config.js that tries to use PurifyPlugin without importing it (ReferenceError: PurifyPlugin is not defined).

ng build --aot --prod --build-optimizer --no-sourcemaps fails with this error:

 92% chunk asset optimization
<--- Last few GCs --->

[455:0x560e167f5620]   707807 ms: Mark-sweep 1413.1 (1518.5) -> 1413.1 (1502.5) MB, 7277.9 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 7279 ms) last resort
[455:0x560e167f5620]   715214 ms: Mark-sweep 1413.1 (1502.5) -> 1413.1 (1502.5) MB, 7406.3 / 0.0 ms  last resort


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x364665b1bbd9 <JS Object>
    2: def_variable [0x364665b02241 <undefined>:3551] [pc=0x4528827ac2b](this=0x1f233b8a5261 <an AST_Function with map 0x127ef311b591>,symbol=0x1f233b8bfc71 <an AST_SymbolFunarg with map 0x150b45cc9009>)
    3: visit [0x364665b02241 <undefined>:3402] [pc=0x45286bed532](this=0x2b8b84e771a1 <a TreeWalker with map 0x3e9d366dda09>,node=0x1f233b8bfc71 <an AST_SymbolFunarg with map 0x150b45cc9009>,de...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [@angular/cli]
 2: 0x560e14f2b97e [@angular/cli]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [@angular/cli]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [@angular/cli]
 5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [@angular/cli]
 6: v8::internal::Factory::NewScopeInfo(int) [@angular/cli]
 7: v8::internal::ScopeInfo::Create(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::Scope*, v8::internal::MaybeHandle<v8::internal::ScopeInfo>) [@angular/cli]
 8: v8::internal::DeclarationScope::AllocateVariables(v8::internal::ParseInfo*, v8::internal::AnalyzeMode) [@angular/cli]
 9: v8::internal::DeclarationScope::Analyze(v8::internal::ParseInfo*, v8::internal::AnalyzeMode) [@angular/cli]
10: v8::internal::Compiler::Analyze(v8::internal::ParseInfo*, v8::internal::ThreadedList<v8::internal::ThreadedListZoneEntry<v8::internal::FunctionLiteral*> >*) [@angular/cli]
11: 0x560e148b8aaa [@angular/cli]
12: 0x560e148b9b2f [@angular/cli]
13: 0x560e148be795 [@angular/cli]
14: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [@angular/cli]
15: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [@angular/cli]
16: 0x452869840bd
../commands/prodbuild.sh: line 10:   455 Aborted                 ng build --aot --prod --build-optimizer --no-sourcemaps

Expected behavior

Both of these commands should work.

Minimal reproduction of the problem with instructions

  • ng new balls ; cd balls ; ng eject --aot --prod --build-optimizer --no-sourcemaps

  • The ng build out of memory error can’t be reproduced as easily, so maybe it only happens with sufficiently large projects. I’ll get back to you on this one.

What is the motivation / use case for changing the behavior?

Functioning as documented.

Environment


Angular version: 4.3.4
Angular CLI version: 1.3.0


For Tooling issues:
- Node version: 8.2.1
- Platform: Debian Sid x86-64 in a Docker image with 4 GB RAM allocated

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
ClemensSchneidercommented, Aug 22, 2017

https://github.com/angular/angular-cli/issues/7110 is related to the TypeError: Cannot read property 'type' of undefined. If you don’t need the operators bindCallback and bindNodeCallback which will both get included if you (or some other module you are using in your application) import all of rxjs using import 'rxjs/Rx' or import { Observable } from 'rxjs/Rx', you can workaround the issue by only importing the operators you actually use. Or just revert back to typescript 2.3.x until the issue is fixed.

See https://github.com/angular/angular-cli/issues/3904 or https://christianliebel.com/2017/07/import-rxjs-correctly/

3reactions
gregbowncommented, Oct 7, 2017

temp fix for ejected Webpack build, add the following line to webpack.config.js const { PurifyPlugin } = require('@angular-devkit/build-optimizer'); or const PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-devkit/build-optimizer Code Examples - Snyk
Learn more about how to use @angular-devkit/build-optimizer, based on @angular-devkit/build-optimizer code ... PurifyPlugin; const config = require('.
Read more >
angular-cli where is webpack.config.js file - Stack Overflow
There's a nice way to eject webpack.config.js from angular-cli. Just run: $ ng eject. This will generate webpack.config.js in the root folder of...
Read more >
@ngtools/webpack: Versions | Openbase
To control ECMA version and features use the Browerslist configuration. require.context are no longer parsed. Webpack specific features are not supported ...
Read more >
angular-devkit/build-optimizer v0.1302.1 - npm.io
Import tslib: applied when TypeScript helpers are found. Non-transform optimizations are applied via the Purify Plugin. Some of these optimizations add /*@ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found