a simpler package manager for no-build websites
0

Configure Feed

Select the types of activity you want to include in your feed.

Update readme

+35 -2
+35 -2
README.md
··· 14 14 - Rather than requiring you to use a compiler and bundler, unpm downloads files that you can serve directly with no build step. 15 15 - Rather forcing you to install your dependencies over and over, unpm is designed for you to just commit them to your repo. 16 16 17 + ## Installation 18 + 19 + unpm requires [Go](https://go.dev/dl/). Once Go is installed, run: 20 + 21 + ```sh 22 + go install tangled.org/jakelazaroff.com/unpm/cmd/unpm@latest 23 + ``` 24 + 17 25 ## Getting started 18 26 19 27 After installing unpm, create an `unpm.json` file at the root of your project: ··· 62 70 63 71 That's it! Your dependencies will now work unbundled in a browser. 64 72 65 - ## Static types 73 + ## TypeScript types 66 74 67 75 unpm can get TypeScript types in a few different ways: 68 76 69 77 - If a JavaScript file includes JSDoc comments, [TypeScript can already check it](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html)! 70 78 - If the response for a vendored file includes the header `x-typescript-types`, unpm will download the type definition file at that URL. 71 79 - If a file has a "sidecar" `.d.ts` file next to it, unpm will download it. 72 - - Finally, you can just point unpm at a TypeScript file and it'll compile it! (Although note that your unpm.json file will no longer be a working import map.) 80 + - Finally, you can add a [`types`](#types) object to `unpm.json` with the URLs of type definition files. 73 81 74 82 You'll need to tell TypeScript where to find any vendored type definitions. You can do that by having your `jsconfig.json` extend the one that unpm generates: 75 83 ··· 144 152 145 153 `imports` is a [module specifier map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#module_specifier_map) that maps between module specifiers and URLs. It's a bit stricter than actual import maps: you can only use ["bare modules"](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#bare_modules), meaning each property must resolve to a JavaScript file rather than a directory. In addition, each value must be a full URL. 146 154 155 + ```json 156 + { 157 + "imports": { 158 + "mylib": "https://example.com/mylib.js" 159 + } 160 + } 161 + ``` 162 + 147 163 Unlike most package managers, unpm doesn't rely on an external package repository like npm or JSR. You can install packages from any URL on the Internet. 164 + 165 + ### types 166 + 167 + `types` is a map from import specifiers to URLs of TypeScript type definition files. It's the highest-priority way to attach types to a dependency (overriding both the `x-typescript-types` response header and any sidecar `.d.ts` files). 168 + 169 + ```json 170 + { 171 + "imports": { 172 + "mylib": "https://example.com/mylib.js" 173 + }, 174 + "types": { 175 + "mylib": "https://example.com/mylib.d.ts" 176 + } 177 + } 178 + ``` 179 + 180 + Each key must match a key in `imports`. You should only need to add entries here when auto-detection doesn't work. 148 181 149 182 ### unpm 150 183