Skip to content
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

class private methods are not enabled #24411

Closed
1 task done
dzonatan opened this issue Dec 10, 2022 · 4 comments · Fixed by #24413
Closed
1 task done

class private methods are not enabled #24411

dzonatan opened this issue Dec 10, 2022 · 4 comments · Fixed by #24413
Assignees
Labels

Comments

@dzonatan
Copy link
Contributor

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/build-angular@15.0.3.

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.

@Julien-Marcou
Copy link
Contributor

Julien-Marcou commented Dec 10, 2022

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.

@Talb2005
Copy link

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];

@iskudrat
Copy link

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

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 12, 2022
…hen targeting Safari <=v15

This commits enables `@babel/plugin-proposal-private-methods` when targetting Safari <=v15 as this is needed to hande private class methods when using `@babel/plugin-proposal-class-properties`.

Closes angular#24411
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 12, 2022
…hen targeting Safari <=v15

This commits enables `@babel/plugin-proposal-private-methods` when targeting Safari <=v15 as this is needed to handle private class methods when using `@babel/plugin-proposal-class-properties`.

Closes angular#24411
@alan-agius4 alan-agius4 self-assigned this Dec 12, 2022
angular-robot bot pushed a commit that referenced this issue Dec 12, 2022
…hen targeting Safari <=v15

This commits enables `@babel/plugin-proposal-private-methods` when targeting Safari <=v15 as this is needed to handle private class methods when using `@babel/plugin-proposal-class-properties`.

Closes #24411
angular-robot bot pushed a commit that referenced this issue Dec 12, 2022
…hen targeting Safari <=v15

This commits enables `@babel/plugin-proposal-private-methods` when targeting Safari <=v15 as this is needed to handle private class methods when using `@babel/plugin-proposal-class-properties`.

Closes #24411

(cherry picked from commit 9737301)
@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 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
5 participants