I'm building a website, where I'd use different polymer components, some of them multiple times.
My problem is that the compiled code contains a
customElements.define('dom-module', DomModule);
that throws
Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry at CustomElementRegistry.value
I have no idea how to resolve this.
If you include polymer using two different paths in two different components, both of them gets executed and both tries to define dom-module, dom-if etc.
So check the networks panel for identical file names but different paths.
Example:
/bower_components/webcomponentsjs/webcomponents-loader.js
and
/components/webcomponentsjs/webcomponents-loader.js
Related
I am struggling to understand how to include Angular 2, a massive framework, into my content script.
My main concern is that every file needs to be included in the content script / manifest.json file. I have tried different variations, but I fail with obscure error messages every time.
I have tried to find some instructions on the internet, but to no avail. The best resource I found was https://www.devbattles.com/en/sand/post-3072-Build_Your_Own_Chrome_Extension_Using_Angular_2__TypeScript but it does not seem to be about content scripts, rather it is about having an isolated webpage. It is also a bit outdated.
This is me struggling with the manifest.json file.. (partial)
{
"matches": [ "https://hp.my.salesforce.com/console*", "https://hp.my.salesforce.com/ui/support/servicedesk/ServiceDeskPage*" ],
"js": [
"ze_modules/systemjs/dist/system.js",
"ze_modules/rxjs/bundles/Rx.js",
"ze_modules/#angular/core/bundles/core.umd.js",
"ze_modules/#angular/common/bundles/common.umd.js",
"ze_modules/requirejs/require.js",
"settings-ui/test.component.js",
"console/includes/jquery-2.2.3.min.js",
"console/includes/toastr.js",
...
...
Does anyone have any pointers? How do I get require to work? How do I get SystemJS to work? It's all a big blur for me.
I've had no issues developing the extension so far, by manually and hastily including some js libs in the manifest.json, but this is just an extreme amount of files.
Some of the error messages..
Uncaught TypeError: Cannot read property 'Subject' of undefined(anonymous function) # core.umd.js:9194(anonymous function) # core.umd.js:14(anonymous function) # core.umd.js:15
common.umd.js:14 Uncaught TypeError: Cannot read property 'Observable' of undefined(anonymous function) # common.umd.js:14(anonymous function) # common.umd.js:15
require.js:168 Uncaught Error: Module name "#angular/core" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
So what I learned here is that chrome extensions differ from regular web development in two major ways:
Everything follows CSP policy, meaning dynamic evaluation is more limited and will cause you pain depending on which libraries you want to use (Angular for example, unless you want to utilize AoT which is still beta)
Files you use need to be declared in the manifest.json file.
I'm not going to document everything I've learned in how to do the above, but basically you need to get into using Webpack. If you want to use Angular 2 like in my case, you need to use Webpack 2.x and Angular 2.x along with AoT compilation (using angular cli).
Webpack helps you because it bundles all your work into single files, which are a lot easier to declare in your manifest.json file(s, you can have several using webpack config).
A developer on my team did some refactoring of a control we're using in WinPhone 8 that represents a card that can be flipped.
We've created two animations using the storyboard named FrontToBackFlip and BackToFrontFlip, with declarations like: <Storyboard x:Name="FrontToBackFlip">
When a Tap is received we call
this.FrontToBackFlip.Begin()
or
this.BackToFrontFlip.Begin()
The refactoring the code worked before, but now we are getting the following error:
'Views.CardCarousel.IssuerCardControl' does not contain a definition for 'FrontToBackFlip' and no extension method 'FrontToBackFlip' accepting a first argument of type 'Views.CardCarousel.IssuerCardControl' could be found (are you missing a using directive or an assembly reference?)
Note that intellisense can find and complete the references to the Storyboards, so the namespaces and type names seem to be correct in both the XAML and code-behind. It's just that the compiler can't resolve these.
Any suggestions for tracking this down?
We were able to fix the issue by simply adding a new user control to the project, copy and paste the code from the control that was not building.
I am developing a custom module for my employer. The my_module.module fill got too big and unmanageable so I decided to separate related code into separate .inc files.
I then included those files in the following code:
function my_module_init(){
module_load_include('inc', 'my_module', 'questionnaire_nodetypes');
module_load_include('inc', 'my_module', 'questionnaire_config');
module_load_include('inc', 'my_module', 'email_friends');
}
My code continued to work for a while but I suddenly got a undefined function error for a function that was definitely present in questionnaire_config.inc. Other similar errors soon followed for other confirmed and existing function in the other included .inc files.
It was suggested to me to run the update.php script but this did not fix the problem. In fact, I got more undefined function errors.
There's no need to put those lines in a hook, just dump them straight into the top of the module file (I've been doing it for years and it's never caused an issue).
hook_init() doesn't get called for cached pages, so it's conceivable your files aren't being included when another (non-cached) part of the system is relying on the existence of those functions.
I've been banging my head against a wall for this for almost a couple days now and hoping that someone can point me in the right direction.
Working in a very large Flash application, previously in AS2/CS3 I would have a setup like the following:
root.swf
-- modules
---- code_a.swf
---- code_b.swf
-- views
---- view_a.swf
---- view_b.swf
Using _exclude.xml files, I could exclude the classes defined in code_a and code_b from the ouptut .swf of view_a and view_b. root.swf would be responsible for loading the code modules before view_a or view_b, ensuring that class definitions that view_a and view_b depended on existed.
The Problem
We've recently migrated to using Actionscript 3/CS5. *_exclude.xml files no longer exist. To get the same functionality as above, I've tried the following:
My setup now looks something like:
root.swf
-- modules
---- class_a.as
---- class_b.as
-- views
---- view_a.swf
---- view_b.swf
Use mxmlc to compile root.swf, view_a.swf and view_b.swf, passing it -externs option to specify classes that will be loaded externally (the two classes in modules). This ensures that the class is excluded from the compiled swf.
Use compc to compile class_a.as and class_b.as into classes.swf, using -directory=true to access library.swf for external loading.
However, when I try running one of the two view files which depend on classes.swf, I get runtime errors telling me that a class definition is not present.
Current Workaround
I've devised a workaround which I'm currently not happy with as it's backwards to the modular approach that I was previously using:
Rather than loading the code modules, I statically link all class definitions required by child movies into root.swf. When building root.swf, I use the -link-report option of mxmlc to provide a list of included classes. When building child swfs, I can the use -load-externs to ensure that class definitions that already exist will not be included in the compile output.
Is there a way that anyone is aware of to replicate the AS2/_exclude.xml solution that I had using AS3/CS5?
I'd recommend compiling shared libraries to SWCs.
There are other options such as RSLs:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf674ba-7fff.html#WS2db454920e96a9e51e63e3d11c0bf69084-7f1e
Hope that helps.
In my project there is some common package which gets its dependencies resolved by the UnityContainer which is defined in unity.config file.
There is another custom package which I want to have its own custom UnityContainer in a seperated CustomUnity.config file.
In runtime I want both files to be loaded and when I get the unity section, I want it to contain both UnityContainers.
How can i achieve it?
Thanks!
The UnityContainer.LoadConfiguration method can be called multiple times on the same container. Each time it loads whatever's in that configuration section, but it doesn't remove what was previously in the container - it's additive. If there's a conflict (both sections configure the same type) then last one in wins.
So, the approach would be to use the ConfigurationManager APIs to load your two separate UnityConfigurationSections, and then call LoadConfiguration twice, once for each configuration section. That should be all you have to do.
I wrote a library that lets you write your ioc container configuration in modules. It supports unity but you will have to configure your container in codes instead of using the files. I don't know if will solve your problem, but you can check it out at bootstrapper.codeplex.com