Skip to content

Cannot create property 'message' on string @angular\common\fesm2022\common.mjs: Unsupported syntax, expected a string literal. #51411

Closed as not planned

Description

@psarno

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

Yes

Description

We upgraded to 16.2.0 and are getting the following error on build.

Any ideas?

Cannot create property 'message' on string '@angular\common\fesm2022\common.mjs: Unsupported syntax, expected a string literal.


  6275 |     }
  6276 |     static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: NgOptimizedImage, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
> 6277 |     static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: NgOptimizedImage, isStandalone: true, selector: "img[ngSrc]", inputs: { ngSrc: "ngSrc", ngSrcset: "ngSrcset", sizes: "sizes", width: ["width", "width", numberAttribute], height: ["height", "height", numberAttribute], loading: "loading", priority: ["priority", "priority", booleanAttribute], loaderParams: "loaderParams", disableOptimizedSrcset: ["disableOptimizedSrcset", "disableOptimizedSrcset", booleanAttribute], fill: ["fill", "fill", booleanAttribute], src: "src", srcset: "srcset" }, host: { properties: { "style.position": "fill ? \"absolute\" : null", "style.width": "fill ? \"100%\" : null", "style.height": "fill ? \"100%\" : null", "style.inset": "fill ? \"0px\" : null" } }, usesOnChanges: true, ngImport: i0 }); }
  6278 | }
  6279 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: NgOptimizedImage, decorators: [{
  6280 |             type: Directive,' [plugin angular-compiler]

    src/app/app.module.ts:6:25:
      6 │ import { DatePipe } from '@angular/common';
        ╵                          ~~~~~~~~~~~~~~~~~

  This error came from the "onLoad" callback registered here:

    node_modules/@angular-devkit/build-angular/src/builders/browser-esbuild/angular/compiler-plugin.js:247:18:
      247 │             build.onLoad({ filter: /\.[cm]?js$/ }, (args) => (0, ...
    at setup (@angular-devkit\build-angular\src\builders\browser-esbuild\angular\compiler-plugin.js:247:19)
    at async handlePlugins (esbuild\lib\main.js:1326:9)

image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 16.2.0
Node: 18.16.0
Package Manager: npm 9.6.7
OS: win32 x64

Angular: 16.2.1
... animations, cdk, common, compiler, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.6
@angular-devkit/build-angular   16.0.6
@angular-devkit/core            16.0.6
@angular-devkit/schematics      16.2.0
@angular/cli                    16.2.0
@angular/compiler-cli           16.0.6
@schematics/angular             16.2.0
rxjs                            7.8.1
typescript                      4.9.3
zone.js                         0.13.1

Anything else?

No response

Activity

  1. JoostK commented on Aug 17, 2023

    @JoostK
    Member

    The problem here is the usage of @angular/compiler-cli 16.0, whereas the other Angular dependencies are 16.2. This is not supported and you should have received peer dependency warnings during npm install.

    We should have bumped the minVersion when adding the transform function to the inputs array in the partial declaration. Once that is present, older versions of the Angular compiler are no longer capable of consuming libraries that have been compiled with newer versions of Angular.

  2. added
    area: compiler
    on Aug 17, 2023
  3. modified the milestone: needsTriage on Aug 17, 2023
  4. JoostK commented on Aug 17, 2023

    @JoostK
    Member

    I am going to put up a PR to increase the minVersion to report a more meaningful error in the future, but this particular instance cannot be fixed; you'll have to align your version of @angular/compiler-cli with the rest of the Angular framework packages.

  5. psarno commented on Aug 17, 2023

    @psarno
    Author

    Thank you @JoostK ... I'm getting twisted because I have to deal with PrimeNG moving to 16.2.1 and have to untangle all of these dependencies and sub-dependencies betwee what they want/need, what I don't want and need.

    It's like the new version of "DLL hell". 👍

  6. added a commit that references this issue on Aug 17, 2023
    41d4993
  7. added 2 commits that reference this issue on Aug 18, 2023
    5bd9fbd
    39ace86
  8. ssams commented on Sep 11, 2023

    @ssams

    We should have bumped the minVersion when adding the transform function to the inputs array in the partial declaration. Once that is present, older versions of the Angular compiler are no longer capable of consuming libraries that have been compiled with newer versions of Angular.

    Just stumbled across this via the Changelog, so if I read this correctly it means that there can be situations where a library compiled with X.1 may not be compatible with release X.0? Either this shouldn't be the case and this was an accidental breaking change, or the documentation is quite misleading: https://angular.io/guide/creating-libraries#ensuring-library-version-compatibility -> no mention of minor releases, I'd expect that any library compiled with some 16.z release to work with projects using all 16.y versions.

  9. JoostK commented on Sep 11, 2023

    @JoostK
    Member

    We try to maintain forwards compatibility for minor versions, but there is no hard guarantee. This particular example shows why: adopting features that have become available in a newer minor cannot be used in an older minor, so using that older minor would then not be possible.

  10. ssams commented on Sep 11, 2023

    @ssams

    We try to maintain forwards compatibility for minor versions, but there is no hard guarantee. This particular example shows why: adopting features that have become available in a newer minor cannot be used in an older minor, so using that older minor would then not be possible.

    but in #50714 (review) by @pkozlowski-opensource

    After discussing it further we want to maintain backward compatibility across the same set of major versions.

    ?

    Also, when creating a project with a separate lib as in https://angular.io/guide/creating-libraries#getting-started, a setup with e.g. ^16.2.0 in both the package.json of the application, and also in the peer dependencies of the library is created. This would allow 16.3 to be used in the project, and thus also for the packager, however then one would need to update the peer dependencies to 16.3 too manually. Without knowing which minimum version the tooling will select internally, it's quite hard to set the correct peer dependency version without being overly strict. I don't think it would be problematic per se if one knows what to expect, but right know there seems to be contradicting or at least very confusing information around in the comments and documentation regarding handling of major and minor versions.

    btw, I suppose we should split this into a separate issue if it's further ongoing, to avoid hijacking this one for a new discussion?

  11. angular-automatic-lock-bot commented on Oct 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.

  12. locked and limited conversation to collaborators on Oct 12, 2023
  13. added a commit that references this issue on Jan 23, 2024
    3076a65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilercompiler: linker

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions