I developed a web app consisting of two separate projects, each housed in different folders with their own set of unique files.
The client component is built using Angular 2 (RC-4) with SystemJS Typescript 1.8.10 (as per instructions found here). The server component is a basic NodeJS application utilizing Typescript 1.8.10 as well.
Both projects have their distinct folders and files, including individual tsconfig.json
configurations.
Everything is functioning properly.
However, I now wish to implement a class MySharedClass {}
that can be utilized in BOTH projects. How would I go about achieving this?
Although I can duplicate the source code in both projects (i.e., have two copies of the source file), resulting in successful build and execution - this is not considered best practice.
One approach I considered was creating a 'third' project named 'common', placing MySharedClass {}
within it. Nevertheless, attempting to import it using
import {MyClass} from "../../../common/my-class";
fails to reference the file during runtime. It appears that referencing a file outside the project's scope is ineffective. Is there something obvious that I am overlooking?
After conducting research, I could not find a clear explanation on how to resolve this issue. Is there some key concept or method that I need to grasp? While I am familiar with the ES6 module system (following the recent shift towards Typescript ES6 behavior), I have not yet delved into using a build tool, opting instead for the scripts provided in the package.json
file (as outlined here). Should I explore implementing Gulp at this point?