Skip to content

Error: Class private methods are not enabled when using pdfjs-dist library  #24429

Closed as not planned
@prabh-62

Description

@prabh-62

Command

build, serve, test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Angular v15 CLI is not able to build and serve app if pdfjs-dist library is imported

Minimal Reproduction

  • npx @angular/cli@15 new admin-console
  • cd admin-console
  • npm install pdfjs-dist
  • npm ls pdfjs-dist -> 3.1.81
  • Edit src/app/app.component.ts and update the file with this code
import { Component } from '@angular/core';
import * as pdfjsLib from 'pdfjs-dist';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  title = 'admin-console';

  private initialize() {
    console.log(pdfjsLib.version);
  }
}
  • npm run build

class_private_methods_angular_v15_cli

Exception or Error

./node_modules/pdfjs-dist/build/pdf.js - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
SyntaxError: /Users/prabh/dev/tmp/admin-console/node_modules/pdfjs-dist/build/pdf.js: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
  2591 | class PDFObjects {
  2592 |   #objs = Object.create(null);
> 2593 |   #ensureObj(objId) {

Your Environment

Angular CLI: 15.0.3
Node: 18.12.1
Package Manager: npm 8.19.3
OS: darwin arm64

Angular: 15.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.3
@angular-devkit/build-angular   15.0.3
@angular-devkit/core            15.0.3
@angular-devkit/schematics      15.0.3
@schematics/angular             15.0.3
rxjs                            7.5.7
typescript                      4.8.4

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions