Skip to content

class private methods are not enabled #24411

Closed

Description

@dzonatan

Command

build, serve

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

15.0.2

Description

Class private methods no longer works with @angular-devkit/[email protected].

Minimal Reproduction

  • ng new repro-app
  • add an empty private method to the app.component.ts, e.g.:
    #myPrivateMethod() {}
  • ng serve

Exception or Error

./src/app/app.component.ts - Error: Module build failed (from ./node_modules/@angular-devkit/build-a
ngular/src/babel/webpack-loader.js):
SyntaxError: /Users/dzonatan/dev/sandbox/ng15/src/app/app.component.ts: Class private methods are no
t enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
  37 |     
> 38 |     #myPrivateMethod() {
     |     ^
  39 |     }
...

Your Environment

Angular CLI: 15.0.3
Node: 16.18.0
Package Manager: npm 8.19.2
OS: darwin arm64

Angular: 15.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, 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.0
@angular-devkit/schematics      14.2.9
@angular/cdk                    15.0.2
@schematics/angular             15.0.3
ng-packagr                      15.0.3
rxjs                            7.5.7
typescript                      4.8.4

Anything else relevant?

I believe #24357 was a cause.

Activity

  1. Julien-Marcou commented on Dec 10, 2022

    @Julien-Marcou
    Contributor

    Same issue here, I have upgrade from Angular 14 to angular 15.0.3, and now my project does not build anymore.

    My project has a depency to "scrollable-component": "^2.0.0-next.0", this package is using private class properties & methods.

    I get the following error when building:

    ./node_modules/scrollable-component/index.js - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
    SyntaxError: /home/jmarcou/dev/angular-project/node_modules/scrollable-component/index.js: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
    
  2. Talb2005 commented on Dec 11, 2022

    @Talb2005

    Same here..

    ./node_modules/pdfjs-dist/build/pdf.js - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
    SyntaxError: /node_modules/pdfjs-dist/build/pdf.js: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
      3253 |   #objs = Object.create(null);
      3254 |
    > 3255 |   #ensureObj(objId) {
           |   ^
      3256 |     const obj = this.#objs[objId];
    
  3. iskudrat commented on Dec 12, 2022

    @iskudrat

    Такая же ошибка как у @Talb2005

  4. added 2 commits that reference this issue on Dec 12, 2022
    6f1b03c
    8d08c94
  5. self-assigned this
    on Dec 12, 2022
  6. added 2 commits that reference this issue on Dec 12, 2022
    9737301
    507f756
  7. angular-automatic-lock-bot commented on Jan 12, 2023

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: @angular-devkit/build-angularfreq1: lowseverity5: regressiontype: bug/fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions