Title: Angular Elements: DOMException when embedding other angular app · Issue #30951 · angular/angular · GitHub
Open Graph Title: Angular Elements: DOMException when embedding other angular app · Issue #30951 · angular/angular
X Title: Angular Elements: DOMException when embedding other angular app · Issue #30951 · angular/angular
Description: 🐞 bug report Affected Package @angular/elements Is this a regression? No Description Our use case is to create an angular agnostic shell that would be able to contain other web applications inside of it. I thought one possible candidate ...
Open Graph Description: 🐞 bug report Affected Package @angular/elements Is this a regression? No Description Our use case is to create an angular agnostic shell that would be able to contain other web applications inside ...
X Description: 🐞 bug report Affected Package @angular/elements Is this a regression? No Description Our use case is to create an angular agnostic shell that would be able to contain other web applications inside ...
Opengraph URL: https://github.com/angular/angular/issues/30951
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Angular Elements: DOMException when embedding other angular app","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\n@angular/elements\r\n\r\n\r\n### Is this a regression?\r\nNo\r\n\r\n### Description\r\n\r\nOur use case is to create an angular agnostic shell that would be able to contain other web applications inside of it. I thought one possible candidate for this type of web app would be Angular Elements, since they are supposed to be agnostic and not interfere with the frameworks / scripts of other web applications.\r\n\r\nUnfortunately, when trying to embed an angular-cli generated application within a website containing Angular Elements, we get the following error:\r\n\r\n`Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry`\r\n\r\nIf ONE of the apps (The angular elements app or the angular-cli app) changes it's `\"optimizations\"` property in package.json to false, there will be no issue. Note: these optimizations are only triggered when running with the `--prod` flag when doing `ng build`\r\n\r\nBuilding both in production mode with the flag set to true (The default setting) results in this error.\r\n\r\n## 🔬 Minimal Reproduction\r\n\r\n**Combined app index.html:**\r\n\r\n```\r\n\u003c!DOCTYPE html>\r\n\u003chtml lang=\"en\">\r\n\u003cbody>\r\n\u003capp-custom-element>\u003c/app-custom-element>\r\n\u003cscript src=\"./angular8app.js\">\u003c/script>\r\n\u003c!-- EMBEDDED APP START -->\r\n \u003capp-root>\u003c/app-root>\r\n \u003cscript type=\"text/javascript\" src=\"./runtime-es5.js\">\u003c/script>\u003cscript type=\"text/javascript\" \r\n src=\"./main-es5.js\">\u003c/script>\r\n\u003c!-- EMBEDDED APP END -->\r\n\u003c/body>\r\n\u003c/html>\r\n```\r\n\r\n**Angular Element app.module:**\r\n\r\n```\r\nimport { BrowserModule } from '@angular/platform-browser';\r\nimport { CUSTOM_ELEMENTS_SCHEMA, NgModule, Injector } from '@angular/core';\r\nimport { CustomComponent } from './custom/custom.component';\r\nimport { createCustomElement } from '@angular/elements';\r\n\r\n@NgModule({\r\n declarations: [\r\n CustomComponent\r\n ],\r\n imports: [\r\n BrowserModule\r\n ],\r\n providers: [],\r\n entryComponents: [CustomComponent],\r\n schemas: [CUSTOM_ELEMENTS_SCHEMA]\r\n})\r\nexport class AppModule {\r\n constructor(injector: Injector) {\r\n const customElement = createCustomElement(CustomComponent, {injector});\r\n customElements.define('app-custom-element', customElement);\r\n }\r\n ngDoBootstrap() {}\r\n}\r\n```\r\n\r\n**batch script to create concatenated angular8app.js:**\r\n`ng build angular8-custom --prod --output-hashing=none && type \"dist\\angular8-custom\\runtime-es2015.js\" \"dist\\angular8-custom\\polyfills-es2015.js\" \"dist\\angular8-custom\\scripts.js\" \"dist\\angular8-custom\\main-es2015.js\" > \"output\\angular8app.js\"`\r\n\r\n**angular8app.js**: The script file for the angular element app, which is a concat of \"runtime.js, main.js and polyfills.js\"\r\n\r\n**app-custom-element**: The custom element tag, defined in app.module\r\n\r\n**app-root**: The app root of the embedded angular8 cli generated application.\r\n\r\n**Other scripts**: Scripts for the angular8 cli generated application.\r\n\r\n_Angular CLI app is all boilerplate / exactly what is generated from angular-cli_\r\n\r\n## 🔥 Exception or Error\r\n`Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry`\r\n\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\nAngular CLI: 8.0.2\r\nNode: 10.15.3\r\nOS: win32 x64\r\nAngular: 8.0.0\r\n... animations, common, compiler, compiler-cli, core, elements\r\n... forms, language-service, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.800.2\r\n@angular-devkit/build-angular 0.800.2\r\n@angular-devkit/build-optimizer 0.800.2\r\n@angular-devkit/build-webpack 0.800.2\r\n@angular-devkit/core 8.0.2\r\n@angular-devkit/schematics 8.0.2\r\n@angular/cli 8.0.2\r\n@ngtools/webpack 8.0.2\r\n@schematics/angular 8.0.2\r\n@schematics/update 0.800.2\r\nrxjs 6.4.0\r\ntypescript 3.4.5\r\nwebpack 4.30.0\r\n\r\n**Anything else relevant?**\r\n\r\n","author":{"url":"https://github.com/xyfer","@type":"Person","name":"xyfer"},"datePublished":"2019-06-10T14:03:19Z","url":"https://github.com/angular/angular/issues/30951"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:61c941ae-8b80-c5af-c332-67689fc24267 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A322:6DC60:BEA6EA:EF4303:6B01311C |
| html-safe-nonce | c7c2d69f5cc08be7428090be7c8f385b39c9ec704496354374db9aba22f5e83a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzIyOjZEQzYwOkJFQTZFQTpFRjQzMDM6NkIwMTMxMUMiLCJ2aXNpdG9yX2lkIjoiNDgxOTE3OTc1NTc2Mjk1NDUyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0f47d95d471b8a3f6f98598b2f872a17103f217194afc6a6eaede60210e14555 |
| hovercard-subject-tag | issue:454187160 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/30951/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b955038d0f8705f1ecd359f73b3459858b7d6b7f77a7710e7bd620f15939a8bb/angular/angular/issues/30951 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b955038d0f8705f1ecd359f73b3459858b7d6b7f77a7710e7bd620f15939a8bb/angular/angular/issues/30951 |
| og:image:alt | 🐞 bug report Affected Package @angular/elements Is this a regression? No Description Our use case is to create an angular agnostic shell that would be able to contain other web applications inside ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | xyfer |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width