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鈥檒l 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 · 3 comments

Comments

@dexster
Copy link

@dexster 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

This comment has been minimized.

Copy link
Author

@dexster 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

This comment has been minimized.

Copy link
Member

@JoostK JoostK commented Nov 7, 2019

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

@filipbech

This comment has been minimized.

Copy link

@filipbech filipbech commented Nov 7, 2019

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 added 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 in 310ce6d Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can鈥檛 perform that action at this time.