In my application I want to use ClarityIcons.add() to add a custom icon. However I get the following error:
index.js:402 Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry
at Object../src/clr-icons/index.ts (http://localhost:4200/vendor.js:84958:20)
at __webpack_require__ (http://localhost:4200/vendor.js:84586:30)
at ./src/clr-icons/clr-icons-api.ts.Object.defineProperty.value (http://localhost:4200/vendor.js:84635:18)
at http://localhost:4200/vendor.js:84638:10
at webpackUniversalModuleDefinition (http://localhost:4200/vendor.js:84564:20)
at Object../node_modules/#clr/icons/index.js (http://localhost:4200/vendor.js:84566:3)
at __webpack_require__ (http://localhost:4200/runtime.js:84:30)
at Module../src/app/core/components/core/core.component.ts (http://localhost:4200/main.js:1528:68)
at __webpack_require__ (http://localhost:4200/runtime.js:84:30)
at Module../src/app/app.module.ts (http://localhost:4200/main.js:618:94)
I tried reproducing it in a stackblitz but there it worked fine. In other questions I read about deleting the package-lock.json and then reinstalling node modules. I tried this but I still have the same result. Any idea where the error could be?
It looks like you are somehow including Clarity Icons twice in your app. Typically, this can happen if you include the pre-compiled clr-icons.min.js and also bundle the icons library as part of your own JS bundle.
Since you call ClarityIcons.add(), I'm guessing you import { ClarityIcons } from "#clr/icons";. If you do this, you want to remove clr-icons.min.js from your index.html and follow the "Load Clarity Icons API and icon sets in Typescript" section in the documentation: https://vmware.github.io/clarity/icons/clarity-icons
Has anybody had any luck with using blueimp jquery-file-upload with browserify? I have the following requires in my javascript ...
require("jquery");
require("blueimp-file-upload/js/jquery.iframe-transport.js");
require("blueimp-file-upload");
require("blueimp-file-upload/js/jquery.fileupload-angular.js");
and I get the following error when I use the resulting browserified code...
TypeError: $element.fileupload is not a function
... at the line ...
$element.fileupload(angular.extend(
... inside of jquery.fileupload-angular.js. Without browserify this was working fine. I can't figure out where the fileupload() function is being added to the prototype of the $element.
By request I'm posting what I did here to get around the issue. So technically speaking not an answer but a "work around". As I indicated in my comment above I used gulp-concat along with gulp-uglify to do the minimizing "manually". I say manually because I have to list all of the source files here rather than relying on the requires.
gulp.src([src1, src2, ..., srcN])
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest(outputdir));
I understand that requirejs and browserify can load my files dependent on its current context, and that it is amazing. I would really prefer to use the #section sections syntax that the razor engine uses. Was just wondering if there is a way to implement this into a typescript / angularjs application.
for example
index.html
#renderSection scripts;
// which could turn into something like
<script data-render="scripts"></scripts>
// the app.run() could declare all the scripts that will be needed on every
// page view
view.html
<script ng-section-repeat="injected in injection"></script>
// the ng-section-repeat is basically taking all the items in the
// typescript constructor and then finding out which ones are needed for
// that view.
I like the idea injecting application file dependencies in the view , without a configuration file and all the added extras that comes with the loaders.
I just want to easily define what files are needed in the actual view and get them loaded, with angular's dependency injection handling the dependency itself.
If you are handling all your dependencies with $inject then , as far as i can tell, dependency is technically already setup in the controllers, all one would need, is to load this as it is called. Which could even eliminate the need for the #section scripts completely
Update:
What i have done to sort of replicate the module loaders is to just use gulp-concat and define the file order in my gulp.config.js and then pass it to the gulp-src before running $.concat .this allows me to have the files in the gulp steam , in dependent order . They are however loaded on the first load. With gulp-uglify the files are tiny ( its now at 566Kb with 16 external libraries loading in 69ms . To put that into perspective it takes 209ms to load one google font ).
I dont know maybe i am not understanding browserify correctly but i honestly struggle to see the need for it, its seems extremely convoluted for something so simple
It is possible using external modules and an injector to do what you asked for:
I just want to easily define what files are needed in the actual view
import {UserFactory} from 'models/userFactory';
import {UserValidator} from 'models/userValidator';
import {Inject} from 'angular2/di';
and get them loaded, with angular's dependency injection handling the dependency itself.
Note: My example uses angular 2.x because I less familiar with angular 1.x and I'm sure you can do something really similar...
class SomeComponent {
userName: string;
userRating: number;
rating: number;
constructor(
#Inject(UserFactory) UserFactory
#Inject(UserValidator) UserValidator
)
{
this.UserFactory = UserFactory;
this.UserValidator = UserValidator;
}
}
Then you can use Browserify to create a bundle.js file that can be executed in a web browser.
I am trying to set up tests for my Angular.js project and I keep getting "$injector:nomod, Module 'result' is not available! You either misspelled..." error. I am sure that I am including "result" module in the "files" array inside "karma.config.js", basically it looks like this:
files: [
'../javascripts/jquery-2.1.4.min.js',
'../jquery-ui/jquery-ui.min.js',
'../D3/d3.js',
'libs/angular.min.js',
'libs/angular-route.min.js',
'libs/angular-animate.min.js',
'libs/selectize.js',
'libs/angular-selectize.js',
'libs/angular-mocks.js',
'simulator.js',
'*.js',
'services/**/*.js',
'qa/tests-*.js'
],
...
I thought initially that the ordering of the main module: 'simulator' (defined inside 'simulator.js' file) is wrong, so I specifically moved it upwards, before
the other modules, like the following stackoverflow thread recommends:
Angular module not available in Karma Jasmine test run
It did not help. Then I tried to make sure that the files are imported in the same order as in my angular apps' main entry file (except for angular-mocks.js and qa/tests-*.js), importing each single file, instead of using wildcards, but no success.
Jasmine definitely goes inside the test files but stumbles upon the line where I am trying to import the module "result":
describe('simulator.chartService', function() {
var chartService;
var graphConfig;
console.log("instantiating module result");
beforeEach(module('result'));
console.log("finished instantiating");
beforeEach(inject(function($injector) {
graphConfig = $injector.get('graphConfig');
chartService = $injector.get('chartService');
}));
it('should be created', function() {
expect(chartService.calcColors(10)).not.toBeNull();
});
});
So, I see that the error happens in-between two console.log() statements.
I suspect that still something can be wrong with the ordering of my files inside the array "files" in "karma.config.js". I have main module "simulator" which is dependent on other modules:
angular.module('simulator', ['ngRoute','ngAnimate','selectize','newexp2','newexp','login','edit','exps', 'result','templates','commons'])
Modules 'newexp2', 'newexp', 'login', 'edit', 'exps', 'result', 'templates' are all dependent on the module 'commons'.
How to correctly import interdependent modules inside the "files" array?
Is it just enough to place "simulator.js", main module, above all others,
or I also need to place all other modules before "commons.js"?
Another my suspicion is that angular.js library version that I downloaded from the official angular website, "angular-mocks.js", can be incompatible with other modules that I am using. I had such an issue with "angular-animate.js" file before.
As long as I surround my test code with $(function(){...}) (and all other my modules ARE surrounded with it) it does not generate the error while importing the result module, so I start seeing two console.log() statements without an error in-between, however, this generates some unknown error which prevents me from invoking the it part at all, whereas when I do not surround it with $(function(){...}), the it test is invoked, but the module result import fails.
So far I am pretty much stuck and do not know where to move and what to try. Any suggestion would be greatly appreciated.
OK, I figured it out. The issue was that ALL of my angular code was enclosed inside $(function(){...}). The solution is to remove all of the $function(){...}), then reorder javascript imports inside the main entry .html file, and then all of the testing starts working good.
The question might be better to mark as duplicate with:
Angular document.ready() issue
I am using the yo react-boilerplate scaffold for a simple react project where I hope to test out the magic-move component.
When I run gulp dev I am getting the following error message:
Error: Parsing file /Users/Andrew/work/magicmove/node_modules/react-magic-move/modules/components/MagicMove.js: Unexpected token (22:6)
at Deps.parseDeps (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/module-deps/index.js:439:28)
at fromSource (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/module-deps/index.js:378:44)
at /Users/Andrew/work/magicmove/node_modules/browserify/node_modules/module-deps/index.js:372:17
at ConcatStream.<anonymous> (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/concat-stream/index.js:36:43)
at ConcatStream.emit (events.js:129:20)
at finishMaybe (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:460:14)
at endWritable (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
at ConcatStream.Writable.end (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
at DuplexWrapper.onend (/Users/Andrew/work/magicmove/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
at DuplexWrapper.g (events.js:199:16)
I am using a simple require statement like:
var MagicMove = require('react-magic-move');
Any thoughts on where the error is coming from? I'm thinking perhaps it could be a jsx related issue? Do I need something like jsx loader?
Here is the scaffold I am using so that you can look at the gulpfile.. maybe there is something I need to alter here?
https://github.com/mitchbox/generator-react-boilerplate
Thanks.
MagicMove.js has a parsing error on line 22.
MagicMove.js: Unexpected token (22:6)
I would start there.
Probably a jsx error, but it's hard to tell without seeing the code.
Looks like MagicMove.js is written in ES6 so you need something like babel.
Babelify (in case you are using browserify) may help to compile the code.