How to call `ng add` of library in custom `ng new` - angular-schematics

I have a workspace including two angular libraries with ng add schematics and a schematics project with a custom ng new schematic.
I'd like to call the ng add schematics of the libraries from my ng new schematic, so I don't have to maintain their setup in two places.
Unfortunately this seems impossible because the externalSchematics function requires the collection to be available which makes calling ng add kind of pointless.
Is there another way to accomplish this?

Adding the library with the ng add schematic as a dependency of the schematics project should actually let you call externalSchematics('library', 'ng-add', options) from the custom ng new.
Unfortunately there is a regression bug and this doesn't work since the change to Angular 9: https://github.com/angular/angular-cli/issues/18098.

Related

Should I compile my react hook library, or publish only the ES6 code?

I have a very simple hook that I want to publish to npm, and I'm struggling to see why I should compile my hook at all. Let me first provide some context.
My hook depends only upon React.useState and React.useEffect. The purpose of this hook is to be used with my existing library: https://npmjs.com/package/simple-shared-state. As you can see, there's very little to this hook:
import { useEffect, useState } from "react";
export default (store, selectors) => {
const [state, setState] = useState([]);
useEffect(() => {
const unwatch = store.watchBatch(selectors, (array) => {
setState(array.slice());
});
return unwatch;
}, []);
return state;
};
I've looked at the create-react-hook cli tool, and tried it out, but I don't see how the included dev-dependencies are needed for my project. My hook is already usable in my mono-repo, where I added a folder, react-test-ground/, in which I provide a working app that I bootstrapped using CRA.
Concerning Testing:
If it makes sense to do, I can go the extra step of adding unit tests specifically for this hook, but at the moment, I can't see a strong need for this since the core of the functionality is in simple-shared-state, and all of that logic is already covered with pretty extensive tests.
I had a look at react-hooks-testing-library, and based on the "When to use this library" and "When not to use this library", it seems to me that my situation is one where I don't need to use this library. I think my hook is simple enough that the extra steps of adding more tests are hard to justify. Do you agree? Can you think of a reason why I should use react-hooks-testing-library?
Concerning compilation:
I can't see a strong reason to compile and minify my hook, since react app developers will almost exclusively be compiling their project from JSX anyway.
Summary
Given all of the above, is there any reason to do anything more than simply publish my hook, exactly as shown, on npm? Meaning, the package.json would include "main": "src/index.js", and no dist/ directory. React would go in the package.json under peerDependencies, and that's it. App developers would simply compile the source ES6 code of this hook into their bundle, and that's all.
Thanks in advance for taking the time to read and reply!
You can publish ES6 code.
The current js spec is ES2020. All runtimes should support all features from this spec.
Thus you need compile own code to latest standard. If user want to use your code on older runtimes(e.g. IE11) he can transpile all code in his build process.

Running multiple AOT functions within function

I'm trying to implement my template matching (with drawing) in AOT form and when I was testing whether the different methods work by including separate static libraries that are compiled from another project, I got build errors like:
Severity Code Description Project File Line Suppression State
Error LNK2005 _ZN6Halide7Runtime8Internal13custom_mallocE already defined in template_matching_ccorr.lib(template_matching_ccorr.lib.obj) Halide Template Matching v2 AOT Run c:\Users\Admin\documents\visual studio 2015\Projects\Halide Template Matchign v2 AOT Run\Halide Template Matchign v2 AOT Run\template_matching_sqdiff.lib(template_matching_sqdiff.lib.obj) 1
Is there a way to be able to include multiple libraries and be able to run different functions?
Also is there a similar function as realize that can be used in a AOT compilation code or would that require me to make two different AOT functions (assuming I can call multiple functions to begin with)
EDIT: a quick fix seems to be adding /FORCE:MULTIPLE to linker's command line
EDIT2: managed to get it to compile with adding
Target target = get_host_target();
target.set_feature(Target::NoRuntime, true);
to most of the pipelines except one which solves the multiple definitions. Now I'm wondering why I have to have one pipeline with the runtime even though I could just include HalideRuntime.h but it doesn't really work.
/FORCE:MULTIPLE works. So does judicious use of the no_runtime target feature. See http://halide-lang.org/tutorials/tutorial_lesson_15_generators_usage.html for details.
You can compile each pipeline without a runtime, and then link them together with a standalone runtime. Or you can just compile one of your pipelines with a runtime.

ASP.Net Library name conflict between Ektron app_code and library

I've got an Ektron 8.2 site, and I was trying to integrate Quartz.NET into it, in order to run some scheduling. Quartz.NET requires a library Common.Logging. This library introduces a conflict and breaks the Ektron code in App_Code/VBCode.
E.g. the following code from Utilities.vb
Case Is = Common.EkEnumeration.FolderType.Community
imageURL &= "images/ui/icons/folderCommunity.png"
Case Common.EkEnumeration.FolderType.Catalog
imageURL &= "images/ui/icons/folderGreen.png"
now gives a compile time error-
App_Code\VBCode\Utilities.vb(703,0): error BC30456: 'EkEnumeration' is not a member of 'Common'.
It appears that Common.Logging is conflicting with Ektron.Cms.Common (the Ektron files have a Imports Ektron.Cms statement). Is it possible to specify the priority on libraries? Or namespace an imported library?
Update
The Utilities.vb code is written by Ektron. I'd like to either make no changes to this code, or minimal changes, as any changes would need to be re-done upon Ektron upgrades. This is really a clash between 2 libraries - Ektron and Quartz.Net. Can I resolve this clash without changing the code of either library? Is there a configuration setting for aliasing libraries?
A simple solution is to use the full namespace, Ektron.Cms.Common.EkEnumeration, rather than relying on the include to sort things out automatically.
I.e.
Case Is = Ektron.Cms.Common.EkEnumeration...
Not elegant, but should get you working again.
Another alternative is to use a namespace alias:
using EkCommon = Ektron.Cms.Common;
So your code would instead look like:
EkCommon.EkEnumeration.FolderType.Community

How do I create a standalone mode extension for ACE?

I'd like to extend ace with a mode for a custom language. As far as I can tell, the general process is:
Download the ace source.
Create a new lib/ace/mode/foo.js for your custom language.
run "make build" (or similar) to rebuild ACE.
Use the newly compiled build/src-min-no-conflict (or whatever) ACE distribution in your website.
But I want to just use an existing ACE distribution from their website, combined with my standalone new mode. I don't want to have to rebuild ACE as part of my build process in order to build my new mode. I got close by doing:
ace.config.setModuleUrl("foo-mode", "./foo.js");
session.setMode("foo-mode");
But I quickly ran into requirejs / dependency problems. For instance I couldn't do require("ace/mode/matching_brace_outdent") inside my mode. I temporarily hacked around that by first calling setMode('ace/mode/c_cpp') (which as a byproduct defines the matching_brace_outdent module). But I ran into even worse problems trying to get a custom WorkerClient to work.
Is my only option to build my mode as part of ACE? Or am I missing something?
Try the pre-built release.
https://github.com/ajaxorg/ace-builds/releases
You might need to edit other files (lists of modes etc.) depending on how you wish to present your new language in the UI:
With regards to require under no-conflict mode in custom modes that aren't workers, if you define your custom mode as a module or a series of modules inside define or ace.define, you should just be able to use the require provided to you in the function wrapper:
ace.define("ace/mode/your_module_name",
["require","exports","module","ace/your_other_dependencies"],
function(require, exports, module) {
// you can use require('...') here
});
I believe you can also use ace.require.
I am less sure about how to "manually build" a custom worker, but following this answer, I think I got it to work by copying code around the core of the relatively slim worker-json.js.

Maven flex project using source directory from seperate module with new artifactId

Finding it difficult to express myself easily around this issue so thought best to start with a context section:
Context:
I have a Flex based application (a rather complex system) that can be compiled using "conditional compilation" into various use cases eg:
Compilation One = portalProjectUserOne
Compilation two = portalProjectUserTwo
Whether using conditional compilation is a sound idea is a completly different argument and therefore lets assume one is forced down this road, I then however decide to create a project for each of my desired compilations:
portalProjectUserOne
-branches
-tags
-trunk
-src
-pom
portalProjectUserTwo
-branches
-tags
-trunk
-src
-{NEEDS TO USE PROJECT ONES SOURCE}
As I do not want to break the ever rigid laws of programming and not duplicate anything I need a way of accessing the source of project ONE and using the source to do a CUSTOM compilation.
Things I have tried:
I tried using relative paths (../../portalProjectUserOne/trunk/src/etc...) with successful compilation but when it came time to release a final product to the nexus repo it had a few issues with reaching out the project structure, that and it felt a bit dirty really.
I attempted to use the "maven-dependency-plugin" to try and copy the sources from the first project, maybe this a pure lack of understanding on my part but I can not get my head around how you generate your classes in one project and access them from another.
This is my first question on stackoverflow and if I have been far to broad please let me know and I shall update with more extensive examples if required.
Thanks for listening/reading/being a coder.

Resources