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

ngcc should not crash when scanning a package with "typings" field set to an array value #33646

Closed
dexster opened this issue Nov 7, 2019 · 4 comments
Labels
freq2: medium regression Indicates than the issue relates to something that worked in a previous version state: has PR type: bug/fix
Milestone

Comments

@dexster
Copy link

dexster commented Nov 7, 2019

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler-cli

Is this a regression?

Probably not

Description

ng update fails in postinstall running this command:
ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"

🔥 Exception or Error


TypeError: typings.replace is not a function
    at Object.getEntryPointInfo (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/packages/entry_point.js:61:74)
    at DirectoryWalkerEntryPointFinder.getEntryPointsForPackage (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:91:52)
    at DirectoryWalkerEntryPointFinder.walkDirectoryForEntryPoints (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:53:36)
    at /Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:73:76
    at Array.forEach ()
    at DirectoryWalkerEntryPointFinder.walkDirectoryForEntryPoints (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:69:18)
    at /Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:43:128
    at Array.reduce ()
    at DirectoryWalkerEntryPointFinder.findEntryPoints (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.js:43:54)
    at getAllEntryPoints (/Users/brettupton/Development/components/sbg-components/node_modules/@angular/compiler-cli/ngcc/src/main.js:264:23)

🌍 Your Environment

Angular Version:

9.0.0-rc.1

Angular CLI: 9.0.0-rc.0
Node: 12.3.1
OS: darwin x64
Angular: 9.0.0-rc.1
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.900.0-rc.0
@angular-devkit/build-angular              0.900.0-rc.0
@angular-devkit/build-ng-packagr           0.900.0-rc.0
@angular-devkit/build-optimizer            0.900.0-rc.0
@angular-devkit/build-webpack              0.900.0-rc.0
@angular-devkit/core                       9.0.0-rc.0
@angular-devkit/schematics                 9.0.0-rc.0
@angular/cdk                               8.2.3
@angular/cli                               9.0.0-rc.0
@angular/material                          8.2.3
@angular/material-moment-adapter           8.2.3
@ngtools/webpack                           9.0.0-rc.0
@nguniversal/express-engine                8.1.1
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        9.0.0-rc.0
@schematics/update                         0.900.0-rc.0
ng-packagr                                 9.0.0-rc.1
rxjs                                       6.5.3
typescript                                 3.6.4
webpack                                    4.39.2

Anything else relevant?
I have an npm package, csv-parse, which has this array in the types section

"types": [
    "./lib/index.d.ts",
    "./lib/sync.d.ts"
  ]

This line in entry_point.js expects a string
var metadataPath = file_system_1.resolve(entryPointPath, typings.replace(/\.d\.ts$/, '') + '.metadata.json');

@dexster
Copy link
Author

dexster commented Nov 7, 2019

Just realised I should've created this in angular-cli repo. Do I need to close and open a new one there?

@JoostK
Copy link
Member

JoostK commented Nov 7, 2019

@dexster actually this is the correct repo, it's caused by ngcc which is maintained here :)

@filipbech
Copy link

I have the same issue

@IgorMinar IgorMinar modified the milestones: needsTriage, v9-candidates Nov 9, 2019
@IgorMinar IgorMinar modified the milestones: v9-candidates, v9-blockers Nov 18, 2019
@IgorMinar IgorMinar changed the title ng update postinstall fails while creating entry points ngcc should not crash when scanning a package with "typings" field set to an array value Nov 21, 2019
JoostK added a commit to JoostK/angular that referenced this issue Nov 21, 2019
In a package.json file, the "typings" or "types" field could be an array
of typings files. ngcc would previously crash unexpectedly for such
packages, as it assumed that the typings field would be a string. This
commit lets ngcc skip over such packages, as having multiple typing
entry-points is not supported for Angular packages so it is safe to
ignore them.

Fixes angular#33646
matsko pushed a commit that referenced this issue Nov 22, 2019
…33973)

In a package.json file, the "typings" or "types" field could be an array
of typings files. ngcc would previously crash unexpectedly for such
packages, as it assumed that the typings field would be a string. This
commit lets ngcc skip over such packages, as having multiple typing
entry-points is not supported for Angular packages so it is safe to
ignore them.

Fixes #33646

PR Close #33973
@matsko matsko closed this as completed in 310ce6d Nov 22, 2019
@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 Dec 23, 2019
@kara kara added regression Indicates than the issue relates to something that worked in a previous version and removed severity5: ivy-compat labels Feb 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq2: medium regression Indicates than the issue relates to something that worked in a previous version state: has PR type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants