liveBook · Manning

Package.json

As explained in Web Component Development with Modern Libraries and Tooling

A JSON project manifest that declares package metadata, dependencies, scripts, and related configuration.

A `package.json` file keeps a small web-component project’s npm setup in one place. Create it in the project directory with `npm init -y`, then install Vite with `npm install -D vite`. Add a `dev` script so `npm run dev` starts the local server. section 1.3 section 9.2

Listing 2.1 package.json
{
  "name": "some-project-name",
  "scripts": {
    "dev": "vite"
  },
  "dependencies": {
    "@awesome.me/webawesome": "^3.0.0"
  },
  "devDependencies": {
    "vite": "^8.0.3"
  }
}

This example records a project name, a `vite` development script, Web Awesome under `dependencies`, and Vite under `devDependencies`. The component files are used separately by the page; the manifest records the packages and command needed for the project. section 2.2

For a project using only local component files, the setup can be simpler: create `package.json`, install Vite, and add `"dev": "vite"`. A Web Awesome project can instead use its personal CDN, but installing the npm package gives more control over the source files and helps avoid vendor lock-in. section 9.2 section 2.2

How Web Component Development with Modern Libraries and Tooling covers it

How deep it goes
Shows creation commands, a dev script, and a complete example manifest; does not explain npm manifest rules in detail.
Examples
Shows a Web Awesome manifest with a Vite script and a smaller vanilla-component setup using the same script.
What it assumes
Assumes Node.js is installed but gives commands to create the manifest and install the development server.
What you can do after
Operate/configure it by creating package.json, adding a Vite dev script, and running the local server with `npm run dev`.
How it connects
Connects package.json to npm, dependencies, development dependencies, Vite, and web components.

Also explained in

Compare how 7 books explain package.json →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Component Development with Modern Libraries and Tooling. The section links point to the parts of the book it draws on.