Skip to content

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

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
prabh-62 opened this issue Dec 13, 2022 · 2 comments
Closed
1 task

Comments

@prabh-62
Copy link

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

@alan-agius4
Copy link
Collaborator

Duplicate of #24426

@alan-agius4 alan-agius4 marked this as a duplicate of #24426 Dec 13, 2022
@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
@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 Jan 13, 2023
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

2 participants