Search code examples
angularsystemjs

What packageConfigPaths is used for in SystemJS configuration?


Working with SystemJS in almost each config Object passed to the SystemJS you ca find 'packageConfigPaths'. In the SystemJS Configuration API documentation there is absolutely no info about this property. Can some one explain what exactly it is doing ? Why there is no documentation on it maybe it is deprecated ?

{ defaultJSExtensions: true, packageConfigPaths: [ '/node_modules/*/package.json', '/node_modules/**/package.json', '/node_modules/@angular/*/package.json' ], ... }


Solution

  • It allows to have configuration options needed by some package in a separate file, which can be distributed together with the package.

    In your example, whenever any package from node_modules needs to be loaded, systemjs will look for package.json file in that package and apply configuration options from that file to the package.

    It's not documented probably because it's not considered stable - for example, there were some changes recently in the lookup procedure AFAIR.