# Research on different Package & Modules Methods

<hr/>
## Table of Contents

- [Introduction](#introduction)

- [Package Methods](#package-methods)

  - [NPM Package](#npm-package)
  - [Bitbucket submodule](#bitbucket-submodule)
  - [Local Module Package](#local-module-package)
  - [Web Components](#web-components)

- [Summary](#summary)

<hr/>

## Introduction

Digital Asset Management Systems (DAMS) is a reusable component package/module that provide asset upload feature. The goal of this project is to make DAMS package/module which can be easily installed and used in different projects.

The main focus of this project is to conduct research into different approaches for packaging the component, with the aim of identifying the most effective and efficient solution. This research phase will involve examining various packaging options and assessing their strengths and weaknesses. Key factors that will be taken into consideration during this phase include modularity, compatibility, and documentation.

<hr/>

## Package Methods

### NPM Package

Docs: https://docs.npmjs.com/packages-and-modules

#### Pros

- **Widely used and well-established in the Node.js community:** NPM is the default package manager for Node.js, and it has a large and active community of developers creating and maintaining packages. This makes it easy to find and use packages for common tasks, as well as to contribute to open-source packages.

- **Provides a centralized location for developers to discover, share, and install packages:** NPM has a large registry of packages that can be easily searched and installed using the npm command-line tool. This makes it easy to share and reuse code across projects and teams.

- **Can be easily installed and managed using the npm command-line tool:** NPM packages can be installed with a single command, and dependencies are automatically managed by NPM. This makes it easy to keep packages up-to-date and ensure that dependencies are compatible.
- **Supports versioning and dependency management:** NPM allows developers to specify the version of a package they want to use, as well as its dependencies. This helps ensure that code will work as expected, and makes it easier to maintain code over time.
- **Can be used in both Node.js and web applications:** NPM packages can be used in both server-side and client-side JavaScript applications.

#### Cons

- **Can result in large package sizes and long installation times due to dependencies:** NPM packages can have many dependencies, and installing them can result in large package sizes and long installation times. This can be a problem for projects with limited disk space or slow internet connections.

- **Requires internet access to install and update packages:** NPM packages are installed from the internet, which means that developers must have internet access to install or update packages.

- **Not ideal for projects that require tight control over dependencies:** NPM packages are designed to be easy to install and use, but this can make it difficult to control dependencies and ensure compatibility with other code.
<hr/>

### Bitbucket Submodule

Docs: https://www.atlassian.com/git/tutorials/git-submodule

#### Pros

- **Allows for easy sharing of code across multiple repositories:** Bitbucket submodules allow developers to easily share code across multiple repositories, which can reduce duplication of effort and save time.
- **Provides better control over dependencies and package size:** Bitbucket submodules allow developers to have better control over dependencies and package size. This can be important for projects with limited disk space or slow internet connections.
- **Can be easily managed using Bitbucket's web-based interface:** Bitbucket submodules can be easily managed using Bitbucket's web-based interface, which can be more user-friendly than the command-line interface used by other package managers.
- **Can be used in both Git and Mercurial repositories:** Bitbucket submodules can be used in both Git and Mercurial repositories, which can be useful for projects that use either version control system.

#### Cons

- **Can be difficult to manage and maintain across multiple repositories:** Bitbucket submodules can be difficult to manage and maintain across multiple repositories, particularly if there are many dependencies or frequent updates.

- **May require additional effort to ensure compatibility with different software environments:** Bitbucket submodules may require additional effort to ensure compatibility with different software environments, particularly if they rely on third-party dependencies.

- **Not as widely used or well-established as other package managers:** Bitbucket submodules are not as widely used or well-established as other package managers, which can make it harder to find help or documentation when needed.
<hr/>

### Local Module Package

Docs: https://www.geeksforgeeks.org/how-to-install-a-local-module-using-npm/
#### Pros

- **Allows for easy reuse of code across multiple projects:** Local module packages can be easily shared and reused across multiple projects. This can save time and reduce duplication of effort.
- **Can be customized and tailored to fit the specific needs of a project:** Local module packages can be customized to fit the specific needs of a project. This can make it easier to use and maintain code over time.
- **Provides better control over dependencies and package size:** Local module packages allow developers to have better control over dependencies and package size. This can be important for projects with limited disk space or slow internet connections.
- **Can be easily installed and managed using the npm command-line tool:** Local module packages can be easily installed and managed using the npm command-line tool.

#### Cons

- **Can be difficult to manage and maintain across multiple projects:** Local module packages can be difficult to manage and maintain across multiple projects, particularly if there are many dependencies or frequent updates.
- **May require additional effort to ensure compatibility with different software environments:** Local module packages may require additional effort to ensure compatibility with different software environments, particularly if they rely on third-party dependencies.

- **Not ideal for sharing code between multiple developers or teams:** Local module packages may not be ideal for sharing code between multiple developers or teams, particularly if they are not well-documented or well-tested.
<hr/>

### Web Components

Docs: https://developer.mozilla.org/en-US/docs/Web/API/Web_components

#### About

- **Custom Elements:** This is the base of the web components, is an specification that allows developers to create new HTML tags and to define their behavior and style using nothing more than JavaScript, HTML and CSS, which can then be used as desired in the user interface. The result is less and modular code that can be reused.

- **Shadow DOM:** This is the technology that allows us to encapsulate parts of the HTML and isolates the CSS and Javascript code with it, which is rendered separately from the main DOM. This is very useful because it allows the developer to control the functionality of the custom component, keeping its features private, so they can be scripted and styled without the fear of collision with other parts of the document.

- **Templates:** These are the elements `<template>` and `<slot>` that allow the developer to write markup templates that are not displayed in the rendered page. These elements are important because they can then be used to populate the shadow DOM of a web component.

#### Pros

- **Allows for easy reuse of code across multiple projects and platforms:** Web components can be easily shared and reused across multiple projects and platforms, including web applications, mobile applications, and desktop applications.

- **Provides better encapsulation and modularity:** Web components provide better encapsulation and modularity than other methods of code sharing, which can make it easier to maintain and update code over time.
- **Can be easily integrated into existing projects:** Web components can be easily integrated into existing projects using standard web technologies like HTML, CSS, and JavaScript.
- **Can be used in both server-side and client-side applications:** Web components can be used in both server-side and client-side JavaScript applications.

#### Cons

- **May require additional effort to ensure compatibility with different software environments:** Web components may require additional effort to ensure compatibility with different software environments, particularly if they rely on third-party dependencies.
- **May require additional effort to ensure accessibility and browser compatibility:** Web components may require additional effort to ensure accessibility and browser compatibility, particularly if they use non-standard web technologies.
- **May not be as widely supported as other code sharing methods:** Web components are a relatively new technology, and may not be as widely supported as other code sharing methods in some software environments.

- **Style sharing between components:** Sometimes the encapsulation advantage of the web components might become a disadvantage, because it doesn�t allow you to share code between components.
<hr/>

## Summary

**<u>Npm packages</u>** are a popular choice for sharing code with **other developers and teams outside of an organization**. They are easy to publish, discover, and install, and can be versioned to ensure compatibility with specific projects.

**<u>Local packages</u>** are a good choice for code that is **specific to an organization or team and not intended to be shared publicly**. They can be created and managed using Node.js and npm, and allow developers to easily share and reuse code across different projects without duplicating code.

**<u>Bitbucket submodules</u>** are a good choice for projects that **require code from multiple repositories or teams**. Submodules allow developers to include specific versions of code from other repositories within their own codebase, which can be useful for managing dependencies and ensuring compatibility.

**<u>Web components</u>** are a good choice for creating **reusable UI components** that can be used across different projects and web applications. They use the Shadow DOM and other web standards to provide encapsulation and modularity, which can help prevent style conflicts and improve code reusability.
