Angular-cli: Proposal: Ability to change webpack jsonp function name

Created on 16 Dec 2017  路  11Comments  路  Source: angular/angular-cli

I'd like to change webpack jsonp function name during application build (for development and production builds). I'll be using this to link more than one webpack bundled application within one page. I'm using multi app project and i need to change jsonp name at single app level.

All we need to do is to pass user value for output.jsonpFunction attribute within webpack build config. I searched repository for "webpackJsonp" and it looks like it is not referenced directly within CLI codebase.

I'm thinking about passing this as optional build param, exactly as base-href or deploy-url and conditionally extending output object in webpack-configs/common.ts.

I'm looking for tips and suggestions before posting PR. I'm more than willing to provide PR with changes ;)

feature

Most helpful comment

@hansl and @glipecki Has there been any movement on this? I ran into the same problem when trying to use Angular Elements and use my custom element on an existing Angular 5 application. I am also happy to submit a PR if necessary.

All 11 comments

@hansl and @glipecki Has there been any movement on this? I ran into the same problem when trying to use Angular Elements and use my custom element on an existing Angular 5 application. I am also happy to submit a PR if necessary.

Would also like to see this as I am having the same problems as @oliverdavidt

We use post build node script to change function name in generated bundles, but it's rather workaround than real solution.

We use post build node script to change function name in generated bundles, but it's rather workaround than real solution.

same here but this will not work while developing elements in pair with main app (both are angular-cli projects)

Any news on that ?

I am also very interested in an update regarding this matter.

While this seems like a common enough use case to support directly, it can be accomplished with a custom builder. Take a look at https://github.com/meltedspark/angular-builders

I think it might be helpful

https://dev.to/meltedspark/customizing-angular-cli-6-buildan-alternative-to-ng-eject-1oc4

you can create custom webpack config and set the jsonpFunction name
module.exports = {
output: {
jsonpFunction: 'jsonpFunction',
library: 'myApp'
}
};
and specify path in angular.json (follow the article steps)

@alexkushnarov looks good, thanks, definitely will try 馃憤

Heya, this sort of request is what we usually see as a usecase for https://github.com/manfredsteyer/ngx-build-plus. We avoid exposing webpack specific options on our public API because we might change the underlying build system at some point.

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._

Was this page helpful?
0 / 5 - 0 ratings