When you need some code

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Do we need to code everything from scratch ?

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Library

  • Close or Open source (Am I alowed to use it ?)
  • Free or not (Can I afford it ?)
  • Documentation (Is it well documented ?)
  • Community (Is there a community ?)

xeokit
paper.js

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

HTML & JavaScript

NPM - Node Package Manager

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

A simple dependency example

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Problems

  • Versioning
  • Compatibility
  • Security
  • What if a library need a library ?
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Dependency/package/library Manager

  • NPM (NodeJS)
  • Composer (PHP)
  • Bundler (Ruby)
  • Pip (Python)
  • Maven (Java)
  • NuGet (.NET)
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Problems

At first, only one library manager per language existed, and some other appeared later.

Like PNPM for NPM.

The versionning between versions of the same library manager is not always compatible.

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Important files

  • package.json (NPM)

  • composer.json (Composer)

  • package-lock.json (NPM)

  • composer.lock (Composer).

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Package file

{
    "name": "vincent/crud",
    "description": "a crud application",
    "type": "project",
    "license": "AGPL3.0",
    "authors": [
        {
            "name": "Vincent Guidoux",
            "email": "vincent.guidoux@gmail.com"
        }
    ],
    "require-dev": {
        "squizlabs/php_codesniffer": "*"
    }
}
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Lock files

  • Lock files are used to lock the version of the dependencies.
  • They are used to ensure that the same version of the dependencies are used by everyone.
  • It should be committed to the repository.
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Packages folder

  • node_modules (NPM)

  • vendor (Composer)

  • The packages folder is where the dependencies are stored.

  • It should be ignored by the repository.

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

What should I remember ?

  • What a dependency is, what are the advantages and disadvantages about it and when and why we need/use it.
  • What a package manager is, what are the advantages and disadvantages about it and when and why we need/use it.
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Sources

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

This is a way to make link and shortcut in the code

This comment will center everything on the page

Transition ! ![bg right:30%][next]

## This is a quote > This is a quote ## This is an image to the right ![bg right][illustration] ## This is an image to the left ![bg left][illustration] ## This is a full image on the right ![bg right contain][illustration] ## This is an image on the right, but only 30% ![bg right:30%][illustration]