{"id":19703335,"url":"https://github.com/trevorkarjanis/angular-multiple-bundles","last_synced_at":"2026-05-19T04:03:30.926Z","repository":{"id":45467943,"uuid":"313669987","full_name":"TrevorKarjanis/angular-multiple-bundles","owner":"TrevorKarjanis","description":"Run two distinct Angular element bundles in the same page.","archived":false,"fork":false,"pushed_at":"2021-12-13T00:10:50.000Z","size":1470,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T16:54:24.113Z","etag":null,"topics":["angular","angular-elements","custom-elements"],"latest_commit_sha":null,"homepage":"https://trevorkarjanis.github.io/angular-multiple-elements","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrevorKarjanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-17T15:58:17.000Z","updated_at":"2022-01-24T19:51:00.000Z","dependencies_parsed_at":"2022-07-14T17:17:46.005Z","dependency_job_id":null,"html_url":"https://github.com/TrevorKarjanis/angular-multiple-bundles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TrevorKarjanis/angular-multiple-bundles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrevorKarjanis%2Fangular-multiple-bundles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrevorKarjanis%2Fangular-multiple-bundles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrevorKarjanis%2Fangular-multiple-bundles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrevorKarjanis%2Fangular-multiple-bundles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrevorKarjanis","download_url":"https://codeload.github.com/TrevorKarjanis/angular-multiple-bundles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrevorKarjanis%2Fangular-multiple-bundles/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269962760,"owners_count":24504284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-elements","custom-elements"],"created_at":"2024-11-11T21:17:34.933Z","updated_at":"2026-05-19T04:03:25.884Z","avatar_url":"https://github.com/TrevorKarjanis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiple Angular Bundles\n\nThis project demonstrates running two distinct, localized [Angular element](https://angular.io/guide/elements) bundles in the same page using [@angular-builders/custom-webpack](https://www.npmjs.com/package/@angular-builders/custom-webpack). For simplicity of implementation, they look the same, but they are two distinct sources and builds.\n\n## Demo\n\nA live demo is available at [https://trevorkarjanis.github.io/angular-multiple-bundles](https://trevorkarjanis.github.io/angular-multiple-bundles).\n\n## Build\n\nRun `npm run build` to build the project.\n\n## Development Server\n\nRun `npm start` to start a development server at [http://127.0.0.1:8080](http://127.0.0.1:8080/).\n\n## Procedures\n\n1. Install @angular-builders/custom-webpack.\n\n```\nnpm install --save-dev @angular-builders/custom-webpack\n```\n\n2. Configure the builder and custom webpack configuration for each project in angular.json.\n\n```json\n\"app-element\": {\n  \"projectType\": \"application\",\n  ...\n  \"architect\": {\n    \"build\": {\n      \"builder\": \"@angular-builders/custom-webpack:browser\",\n      \"options\": {\n        \"customWebpackConfig\": {\n          \"path\": \"projects/\u003cproject name\u003e/webpack.config.js\",\n          \"mergeStrategies\": {\n            \"externals\": \"replace\"\n          }\n        }\n      }\n```\n\n3. Create a custom webpack configuration file, webpack.config.js, in each project directory.\n\n4. In each custom webpack configuration, define unique values for the jsonpFunction and library output configuration options ([example](https://github.com/TrevorKarjanis/angular-multiple-bundles/blob/238a1bfe40665be0c5988bc90015ad9a08da2ba2/angular.json#L17)).\n\n```javascript\nmodule.exports = {\n  output: {\n    jsonpFunction: 'webpackJsonp\u003cproject name\u003e',\n    library: '\u003cproject name\u003e'\n  }\n}\n```\n\n5. Build the project.\n\n6. Include each project's runtime, styles, and main bundles in the correct order in the target page. Include the polyfills bundle only once ([example](https://github.com/TrevorKarjanis/angular-multiple-bundles/blob/f314993dde3bfa916e611ef9cce1ecf355295330/index.html#L25)).\n\n```html\n\u003cscript src=\"app-element/runtime.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element/polyfills.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element/styles.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element/main.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element-2/runtime.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element-2/styles.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"app-element-2/main.js\" defer\u003e\u003c/script\u003e\n```\n\n## Optimization\n\nThis project demonstrates running multiple elements with separate Angular runtimes. It is preferred, however, to include multiple elements in one bundle that utilizes a single instance of the framework and unique chunks. In some cases, it may be reasonable to distribute all elements in a single bundle built from a selfcontained, unbootstrapped \"application\" build. Optimally, the components would be distributed in an Angular library and either defined as custom elements in independent modules or bundled per consuming application.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorkarjanis%2Fangular-multiple-bundles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrevorkarjanis%2Fangular-multiple-bundles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorkarjanis%2Fangular-multiple-bundles/lists"}