@temir.ra/create-ts-lib 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +36 -70
- package/buildinfo.txt +1 -1
- package/dist/cli.bundle.js.map +1 -1
- package/dist/cli.js +1 -1
- package/package.json +2 -2
- package/template/README.md +7 -28
- package/template/package.json +1 -1
- package/template/tsconfig.json +38 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Version 0
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
1. Cleaned up dormant imports.
|
|
6
|
+
2. Cleaned up / updated minor `README.md` inconsistencies.
|
|
7
|
+
3. Updated placeholders in `README.md` in the **Asset resolution** section.
|
|
8
|
+
4. Removed **Asset resolution** section from the generated `README.md`, as the operational passage is given in the template `README.md`.
|
|
9
|
+
5. Removed **AI Assistant Context** section from the `README.md` files.
|
|
10
|
+
7. Cleaned up **Publish** section in the `README.md`.
|
|
11
|
+
|
|
12
|
+
## 0.6.0
|
|
13
|
+
|
|
14
|
+
1. Updated documentation and configs to TypeScript 6.
|
|
15
|
+
|
|
3
16
|
## 0.5.0
|
|
4
17
|
|
|
5
18
|
1. Changed `buildinfo.txt` generation and testing to align with [https://semver.org](https://semver.org).
|
package/README.md
CHANGED
|
@@ -5,8 +5,7 @@ A template for TypeScript libraries distributed via npm-compatible registries. P
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [
|
|
9
|
-
3. [Documentation](#documentation)
|
|
8
|
+
2. [Documentation](#documentation)
|
|
10
9
|
1. [`tsconfig.json` and `tsconfig.build.json`](#tsconfigjson-and-tsconfigbuildjson)
|
|
11
10
|
2. [`package.json`](#packagejson)
|
|
12
11
|
3. [Script `scripts/buildinfo.ts`](#script-scriptsbuildinfots)
|
|
@@ -22,7 +21,7 @@ A template for TypeScript libraries distributed via npm-compatible registries. P
|
|
|
22
21
|
3. [README statement for library consumers](#readme-statement-for-library-consumers)
|
|
23
22
|
4. [When the library is bundled by the consumer](#when-the-library-is-bundled-by-the-consumer)
|
|
24
23
|
8. [`src/dev.ts`](#srcdevts)
|
|
25
|
-
|
|
24
|
+
3. [DevOps](#devops)
|
|
26
25
|
1. [Change Management](#change-management)
|
|
27
26
|
2. [Publish](#publish)
|
|
28
27
|
1. [npmjs.org](#npmjsorg)
|
|
@@ -54,12 +53,6 @@ cd <NEW_PACKAGE>
|
|
|
54
53
|
bun install
|
|
55
54
|
```
|
|
56
55
|
|
|
57
|
-
# AI Assistant Context
|
|
58
|
-
|
|
59
|
-
To generate an AI coding assistant context file for this project:
|
|
60
|
-
|
|
61
|
-
> Generate an AI coding assistant context file. Analyze the project structure and source files, using this README as the primary reference for architecture and conventions. Give particular attention to: the dual tsconfig setup and the import constraints it imposes, the `#src/*.js` alias and where it may and may not be used, the custom `entrypoint` export condition, and the asset resolution contract.
|
|
62
|
-
|
|
63
56
|
# Documentation
|
|
64
57
|
|
|
65
58
|
The following sections explain the configurations and conventions baked into the generated package. Useful when adapting the generated package to fit a specific library's needs.
|
|
@@ -73,15 +66,17 @@ See the typescriptlang documentation on [tsconfig.json](https://www.typescriptla
|
|
|
73
66
|
|
|
74
67
|
"compilerOptions": {
|
|
75
68
|
|
|
76
|
-
// ECMAScript version of emitted output
|
|
77
|
-
"
|
|
69
|
+
// ECMAScript version of emitted output; ESNext targets the latest JS version supported by the TypeScript compiler
|
|
70
|
+
// if the package must support older runtimes or browsers, pin to a specific year (e.g. "ES2022", "ES2024")
|
|
71
|
+
"target": "ESNext",
|
|
78
72
|
|
|
79
73
|
// output module format; ESNext passes ES module syntax through unchanged
|
|
74
|
+
// ES module syntax: import/export statements (as opposed to CommonJS require()/module.exports)
|
|
80
75
|
"module": "ESNext",
|
|
81
76
|
|
|
82
77
|
// type definitions for built-in APIs
|
|
83
78
|
"lib": [
|
|
84
|
-
"
|
|
79
|
+
"ESNext", // standard JavaScript runtime APIs
|
|
85
80
|
"DOM" // browser globals for bundled output
|
|
86
81
|
],
|
|
87
82
|
|
|
@@ -116,6 +111,9 @@ See the typescriptlang documentation on [tsconfig.json](https://www.typescriptla
|
|
|
116
111
|
// do not type-check `.d.ts` files in `node_modules/`
|
|
117
112
|
"skipLibCheck": true,
|
|
118
113
|
|
|
114
|
+
// TS6 defaults types to [] — @types/* packages must be listed explicitly
|
|
115
|
+
"types": ["bun"],
|
|
116
|
+
|
|
119
117
|
// enforce consistent casing across import statements
|
|
120
118
|
"forceConsistentCasingInFileNames": true,
|
|
121
119
|
|
|
@@ -133,7 +131,7 @@ See the typescriptlang documentation on [tsconfig.json](https://www.typescriptla
|
|
|
133
131
|
// output directory for emitted files
|
|
134
132
|
"outDir": "./dist",
|
|
135
133
|
|
|
136
|
-
// root directory mirrored into outDir; set to project root during development, overridden to src/ in tsconfig.build.json
|
|
134
|
+
// root directory mirrored into outDir; set to project root during development, overridden to src/ in tsconfig.build.json (TS6 default — not set in actual config)
|
|
137
135
|
"rootDir": ".",
|
|
138
136
|
|
|
139
137
|
},
|
|
@@ -248,7 +246,7 @@ See npmjs documentation on [package.json](https://docs.npmjs.com/cli/v11/configu
|
|
|
248
246
|
"scripts": {
|
|
249
247
|
|
|
250
248
|
"clean:dist": "rm -rf dist/",
|
|
251
|
-
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
249
|
+
"clean:tsbuildinfo": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
|
|
252
250
|
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
253
251
|
|
|
254
252
|
// lifecycle hook; runs automatically before "build"; generates buildinfo.txt
|
|
@@ -262,8 +260,6 @@ See npmjs documentation on [package.json](https://docs.npmjs.com/cli/v11/configu
|
|
|
262
260
|
// bundles the library into ESM and IIFE formats for distribution
|
|
263
261
|
"build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
|
|
264
262
|
|
|
265
|
-
"build:cli-bundle": "bun build src/cli.ts --entry-naming \"[dir]/[name].bundle.[ext]\" --outdir dist --target node --format esm --minify --sourcemap=external",
|
|
266
|
-
|
|
267
263
|
"typecheck": "tsc --noEmit",
|
|
268
264
|
|
|
269
265
|
// runs src/dev.ts in watch mode
|
|
@@ -272,7 +268,7 @@ See npmjs documentation on [package.json](https://docs.npmjs.com/cli/v11/configu
|
|
|
272
268
|
},
|
|
273
269
|
"devDependencies": {
|
|
274
270
|
"@types/bun": "latest",
|
|
275
|
-
"typescript": "^
|
|
271
|
+
"typescript": "^6.0.2"
|
|
276
272
|
}
|
|
277
273
|
}
|
|
278
274
|
```
|
|
@@ -318,14 +314,21 @@ For CLI packages, add the following to `package.json`:
|
|
|
318
314
|
|
|
319
315
|
The key question to ask is: **does my library retain its own URL at runtime?** Everything else follows from it.
|
|
320
316
|
|
|
317
|
+
```bash
|
|
318
|
+
# placeholder:
|
|
319
|
+
# <@SCOPE: <@SCOPE>
|
|
320
|
+
# <LIB_NAME: <LIB_NAME>
|
|
321
|
+
# <VERSION: <VERSION>
|
|
322
|
+
```
|
|
323
|
+
|
|
321
324
|
### Externalized - loaded from CDN or `node_modules/`
|
|
322
325
|
|
|
323
326
|
The consumer does not bundle the library. It is loaded as a discrete module at runtime. Module identity is preserved regardless of the URL form:
|
|
324
327
|
|
|
325
328
|
```
|
|
326
|
-
https://cdn.jsdelivr.net/npm
|
|
327
|
-
file:///project/node_modules
|
|
328
|
-
https://your-own-cdn.com
|
|
329
|
+
https://cdn.jsdelivr.net/npm/<@SCOPE>/<LIB_NAME>@<VERSION>/dist/index.js
|
|
330
|
+
file:///project/node_modules/<@SCOPE>/<LIB_NAME>/dist/index.js
|
|
331
|
+
https://your-own-cdn.com/<LIB_NAME>/index.js
|
|
329
332
|
```
|
|
330
333
|
|
|
331
334
|
`import.meta.url` is reliable in all these cases. `fetch()` is the correct I/O mechanism because it accepts both `https://` and `file://` URLs, making it universally correct for isomorphic (`--target node` or `--target browser`) libraries.
|
|
@@ -357,12 +360,12 @@ Place all runtime assets under a scoped directory that mirrors the package name:
|
|
|
357
360
|
|
|
358
361
|
```
|
|
359
362
|
assets/
|
|
360
|
-
└──
|
|
361
|
-
└──
|
|
362
|
-
└──
|
|
363
|
+
└── <@SCOPE>/
|
|
364
|
+
└── <LIB_NAME>/
|
|
365
|
+
└── ...
|
|
363
366
|
```
|
|
364
367
|
|
|
365
|
-
This prevents naming collisions when multiple libraries are bundled into the same consumer app. Each library's assets live under their own namespace; no library can shadow another's files.
|
|
368
|
+
This also prevents naming collisions when multiple libraries are bundled into the same consumer app. Each library's assets live under their own namespace; no library can shadow another's files.
|
|
366
369
|
|
|
367
370
|
Add `assets/` to the `files` field in `package.json` so that the assets are included in the published package:
|
|
368
371
|
|
|
@@ -381,13 +384,13 @@ Construct asset URLs directly from `import.meta.url`.
|
|
|
381
384
|
|
|
382
385
|
```typescript
|
|
383
386
|
const packageUrl = new URL('../', import.meta.url);
|
|
384
|
-
const assetsUrl = new URL('assets
|
|
387
|
+
const assetsUrl = new URL('assets/<@SCOPE>/<LIB_NAME>/', packageUrl);
|
|
385
388
|
|
|
386
389
|
// for --target browser
|
|
387
390
|
const asset = await fetch(new URL('<ASSET>', assetsUrl)).then(r => r.json());
|
|
388
391
|
|
|
389
392
|
// for --target node
|
|
390
|
-
import { readFile } from '
|
|
393
|
+
import { readFile } from 'fs/promises';
|
|
391
394
|
import { fileURLToPath } from 'url';
|
|
392
395
|
const asset = JSON.parse(await readFile(fileURLToPath(new URL('<ASSET>', assetsUrl)), 'utf-8'));
|
|
393
396
|
```
|
|
@@ -395,14 +398,9 @@ const asset = JSON.parse(await readFile(fileURLToPath(new URL('<ASSET>', assetsU
|
|
|
395
398
|
### README statement for library consumers
|
|
396
399
|
|
|
397
400
|
```markdown
|
|
398
|
-
<!-- placeholder:
|
|
399
|
-
<SCOPE: <SCOPE>
|
|
400
|
-
<LIB_NAME: <LIB_NAME>
|
|
401
|
-
-->
|
|
402
|
-
|
|
403
401
|
## Asset resolution
|
|
404
402
|
|
|
405
|
-
This library resolves assets at runtime using `import.meta.url`. If you bundle this library into your application, copy `node_modules
|
|
403
|
+
This library resolves assets at runtime using `import.meta.url`. If you bundle this library into your application, copy `node_modules/<@SCOPE>/<LIB_NAME>/assets/<@SCOPE>/<LIB_NAME>/` into your build output directory alongside your bundle.
|
|
406
404
|
```
|
|
407
405
|
|
|
408
406
|
#### When the library is bundled by the consumer
|
|
@@ -413,12 +411,12 @@ The consumer must copy the assets into their build output at the same relative p
|
|
|
413
411
|
consumer output/
|
|
414
412
|
├── bundle.js ← import.meta.url points here
|
|
415
413
|
└── assets/
|
|
416
|
-
└──
|
|
417
|
-
└──
|
|
418
|
-
└──
|
|
414
|
+
└── <@SCOPE>/
|
|
415
|
+
└── <LIB_NAME>/
|
|
416
|
+
└── ... ← copied; relative path preserved
|
|
419
417
|
```
|
|
420
418
|
|
|
421
|
-
From the bundle's perspective `assets
|
|
419
|
+
From the bundle's perspective `assets/<@SCOPE>/<LIB_NAME>/` is at the same directory level as `bundle.js`, so `new URL('assets/<@SCOPE>/<LIB_NAME>/...', import.meta.url)` resolves correctly. No code configuration is needed - only the file copy.
|
|
422
420
|
|
|
423
421
|
## `src/dev.ts`
|
|
424
422
|
|
|
@@ -427,13 +425,13 @@ Development scratchpad - not published, excluded from `tsconfig.build.json`. Run
|
|
|
427
425
|
# DevOps
|
|
428
426
|
|
|
429
427
|
```bash
|
|
430
|
-
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
428
|
+
# remove dist/ and tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo
|
|
431
429
|
bun run clean
|
|
432
430
|
|
|
433
431
|
# remove dist/ only
|
|
434
432
|
bun run clean:dist
|
|
435
433
|
|
|
436
|
-
# remove tsconfig.build.tsbuildinfo only
|
|
434
|
+
# remove tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo only
|
|
437
435
|
bun run clean:tsbuildinfo
|
|
438
436
|
|
|
439
437
|
# compile + bundle
|
|
@@ -455,15 +453,6 @@ bun run dist/cli.bundle.js -- example
|
|
|
455
453
|
|
|
456
454
|
## Publish
|
|
457
455
|
|
|
458
|
-
See the following sources to configure the target registry and authentication.
|
|
459
|
-
|
|
460
|
-
- [Configuring npm - `npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc)
|
|
461
|
-
- [Bun package manager - `install.registry`](https://bun.com/docs/runtime/bunfig#install-scopes)
|
|
462
|
-
|
|
463
|
-
⚠️ Package Scope and the authentication for the target registry must be aligned.
|
|
464
|
-
|
|
465
|
-
### `npmjs.org`
|
|
466
|
-
|
|
467
456
|
Publish to the public npm registry.
|
|
468
457
|
|
|
469
458
|
```powershell
|
|
@@ -472,26 +461,3 @@ npm login
|
|
|
472
461
|
# publish
|
|
473
462
|
bun publish --registry https://registry.npmjs.org/ --access public
|
|
474
463
|
```
|
|
475
|
-
|
|
476
|
-
### Custom registry
|
|
477
|
-
|
|
478
|
-
```bash
|
|
479
|
-
# placeholder:
|
|
480
|
-
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
481
|
-
# <REGISTRY_URL: <REGISTRY_URL>
|
|
482
|
-
# <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
`~/.bunfig.toml` or `bunfig.toml`:
|
|
486
|
-
|
|
487
|
-
```toml
|
|
488
|
-
[install.scopes]
|
|
489
|
-
"<SCOPE_WITHOUT_AT>" = { url = "<REGISTRY_URL>", token = "$BUN_PUBLISH_AUTH_TOKEN" }
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
```powershell
|
|
493
|
-
# authenticate
|
|
494
|
-
$env:BUN_PUBLISH_AUTH_TOKEN = "<BUN_PUBLISH_AUTH_TOKEN>"
|
|
495
|
-
# publish
|
|
496
|
-
bun publish
|
|
497
|
-
```
|
package/buildinfo.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.6.1+f14d02f
|
package/dist/cli.bundle.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["..\\src\\cli.ts", "..\\src\\constants.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve
|
|
5
|
+
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve } from 'path';\r\nimport {\r\n templatePath,\r\n changelogPath,\r\n buildinfoPath,\r\n readmePath\r\n} from './constants.js';\r\n\r\n\r\ntry {\r\n\r\n const packageNameArgument = process.argv[2];\r\n if (!packageNameArgument) throw new Error('Package name argument is required. Usage: `create-ts-lib <package-name>`');\r\n const packageName = packageNameArgument.replace(/\\\\/g, '/');\r\n\r\n const destinationPath = resolve(process.cwd(), packageName);\r\n\r\n cpSync(templatePath, destinationPath, { recursive: true });\r\n cpSync(changelogPath, resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(buildinfoPath, resolve(destinationPath, 'buildinfo-template.txt'));\r\n cpSync(readmePath, resolve(destinationPath, 'README-template.md'));\r\n\r\n const packageJsonPath = resolve(destinationPath, 'package.json');\r\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\r\n packageJson.name = packageName;\r\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\r\n\r\n renameSync(resolve(destinationPath, 'gitignore'), resolve(destinationPath, '.gitignore'));\r\n\r\n console.log(`Template has been successfully instantiated at '${destinationPath}' with package name '${packageName}'.`);\r\n\r\n}\r\ncatch (error) {\r\n const err = error instanceof Error ? error : new Error(String(error));\r\n console.error('Error:', err.message);\r\n process.exit(1);\r\n}\r\n",
|
|
6
6
|
"import { resolve } from 'path';\r\nimport { fileURLToPath } from 'url';\r\n\r\n\r\nexport const packageUrl: URL = new URL('../', import.meta.url);\r\nexport const packagePath: string = resolve(fileURLToPath(packageUrl));\r\n\r\nexport const templatePath: string = resolve(packagePath, 'template/');\r\n\r\nexport const changelogPath: string = resolve(packagePath, 'CHANGELOG.md');\r\nexport const buildinfoPath: string = resolve(packagePath, 'buildinfo.txt');\r\nexport const readmePath: string = resolve(packagePath, 'README.md');\r\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAEA,iBAAS,kBAAQ,gBAAc,mBAAY,WAC3C,kBAAS,aCHT,kBAAS,aACT,wBAAS,YAGF,IAAM,EAAkB,IAAI,IAAI,MAAO,YAAY,GAAG,EAChD,EAAsB,EAAQ,EAAc,CAAU,CAAC,EAEvD,EAAuB,EAAQ,EAAa,WAAW,EAEvD,EAAwB,EAAQ,EAAa,cAAc,EAC3D,EAAwB,EAAQ,EAAa,eAAe,EAC5D,EAAqB,EAAQ,EAAa,WAAW,EDClE,GAAI,CAEA,IAAM,EAAsB,QAAQ,KAAK,GACzC,GAAI,CAAC,EAAqB,MAAU,MAAM,0EAA0E,EACpH,IAAM,EAAc,EAAoB,QAAQ,MAAO,GAAG,EAEpD,EAAkB,EAAQ,QAAQ,IAAI,EAAG,CAAW,EAE1D,EAAO,EAAc,EAAiB,CAAE,UAAW,EAAK,CAAC,EACzD,EAAO,EAAe,EAAQ,EAAiB,uBAAuB,CAAC,EACvE,EAAO,EAAe,EAAQ,EAAiB,wBAAwB,CAAC,EACxE,EAAO,EAAY,EAAQ,EAAiB,oBAAoB,CAAC,EAEjE,IAAM,EAAkB,EAAQ,EAAiB,cAAc,EACzD,EAAc,KAAK,MAAM,EAAa,EAAiB,OAAO,CAAC,EACrE,EAAY,KAAO,EACnB,EAAc,EAAiB,KAAK,UAAU,EAAa,KAAM,CAAC,CAAC,EAEnE,EAAW,EAAQ,EAAiB,WAAW,EAAG,EAAQ,EAAiB,YAAY,CAAC,EAExF,QAAQ,IAAI,mDAAmD,yBAAuC,KAAe,EAGzH,MAAO,EAAO,CACV,IAAM,EAAM,aAAiB,MAAQ,EAAY,MAAM,OAAO,CAAK,CAAC,EACpE,QAAQ,MAAM,SAAU,EAAI,OAAO,EACnC,QAAQ,KAAK,CAAC",
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
3
|
-
import { resolve
|
|
3
|
+
import { resolve } from 'path';
|
|
4
4
|
import { templatePath, changelogPath, buildinfoPath, readmePath } from './constants.js';
|
|
5
5
|
try {
|
|
6
6
|
const packageNameArgument = process.argv[2];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temir.ra/create-ts-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Typescript library template",
|
|
5
5
|
"author": "temir.ra",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "latest",
|
|
42
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^6.0.2"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/template/README.md
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [
|
|
9
|
-
3. [
|
|
10
|
-
4. [DevOps](#devops)
|
|
8
|
+
2. [Documentation](#documentation)
|
|
9
|
+
3. [DevOps](#devops)
|
|
11
10
|
1. [Change Management](#change-management)
|
|
12
11
|
2. [Publish](#publish)
|
|
13
12
|
1. [npmjs.org](#npmjsorg)
|
|
@@ -16,13 +15,13 @@
|
|
|
16
15
|
# Quick Start
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
|
-
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
18
|
+
# remove dist/ and tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo
|
|
20
19
|
bun run clean
|
|
21
20
|
|
|
22
21
|
# remove dist/ only
|
|
23
22
|
bun run clean:dist
|
|
24
23
|
|
|
25
|
-
# remove tsconfig.build.tsbuildinfo only
|
|
24
|
+
# remove tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo only
|
|
26
25
|
bun run clean:tsbuildinfo
|
|
27
26
|
|
|
28
27
|
# compile + bundle
|
|
@@ -35,30 +34,10 @@ bun run tests
|
|
|
35
34
|
bun run dev
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
**Publish** - see [Publish](#publish).
|
|
39
|
-
|
|
40
|
-
# AI Assistant Context
|
|
41
|
-
|
|
42
|
-
To generate an AI coding assistant context file for this project:
|
|
43
|
-
|
|
44
|
-
> Generate an AI coding assistant context file. `README-template.md` is available now and documents the architectural conventions of this package — use it as your primary source. The generated context file must be self-contained: `README-template.md` will be deleted after context generation, so do not reference it in the output. Give particular attention to: the dual tsconfig setup and the import constraints it imposes, the `#src/*.js` alias and where it may and may not be used, the custom `entrypoint` export condition, and the asset resolution contract.
|
|
45
|
-
|
|
46
37
|
# Documentation
|
|
47
38
|
|
|
48
39
|
*<DOCUMENTATION>*
|
|
49
40
|
|
|
50
|
-
## Asset Resolution
|
|
51
|
-
|
|
52
|
-
*<!-- Remove this section if the library has no runtime assets. Replace `@scope/lib-name` throughout with the actual package name. -->*
|
|
53
|
-
|
|
54
|
-
Assets are placed under `assets/@scope/lib-name/` (scoped to the package name to prevent collisions). They are resolved at runtime via `import.meta.url` and loaded with `fetch()` (browser) or `readFile` (Node). `assets/` must be listed in `files` in `package.json`.
|
|
55
|
-
|
|
56
|
-
`import.meta.url` is reliable when the library is loaded as a discrete module (from CDN or `node_modules/`). When the consumer bundles the library, they must copy the assets - see below.
|
|
57
|
-
|
|
58
|
-
### For consumers bundling this library
|
|
59
|
-
|
|
60
|
-
Copy `node_modules/@scope/lib-name/assets/` into your build output alongside the bundle, preserving the relative path. No code configuration is required - only the file copy.
|
|
61
|
-
|
|
62
41
|
# DevOps
|
|
63
42
|
|
|
64
43
|
## Change Management
|
|
@@ -95,9 +74,9 @@ bun publish --registry https://registry.npmjs.org/ --access public
|
|
|
95
74
|
|
|
96
75
|
```bash
|
|
97
76
|
# placeholder:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
77
|
+
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
78
|
+
# <REGISTRY_URL: <REGISTRY_URL>
|
|
79
|
+
# <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
|
|
101
80
|
```
|
|
102
81
|
|
|
103
82
|
`~/.bunfig.toml` or `bunfig.toml`:
|
package/template/package.json
CHANGED
package/template/tsconfig.json
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"lib": [
|
|
6
|
-
"
|
|
7
|
-
"DOM"
|
|
8
|
-
],
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"verbatimModuleSyntax": true,
|
|
12
|
-
"noUncheckedIndexedAccess": true,
|
|
13
|
-
"exactOptionalPropertyTypes": true,
|
|
14
|
-
"noImplicitOverride": true,
|
|
15
|
-
"isolatedDeclarations": true,
|
|
16
|
-
"esModuleInterop": true,
|
|
17
|
-
"composite": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ESNext",
|
|
7
|
+
"DOM"
|
|
8
|
+
],
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"exactOptionalPropertyTypes": true,
|
|
14
|
+
"noImplicitOverride": true,
|
|
15
|
+
"isolatedDeclarations": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"composite": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"types": [
|
|
20
|
+
"bun"
|
|
21
|
+
],
|
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
|
23
|
+
"resolveJsonModule": true,
|
|
24
|
+
"declaration": true,
|
|
25
|
+
"declarationMap": true,
|
|
26
|
+
"emitDeclarationOnly": true,
|
|
27
|
+
"outDir": "./dist",
|
|
28
|
+
},
|
|
29
|
+
"include": [
|
|
30
|
+
"src/**/*.ts",
|
|
31
|
+
"tests/**/*.ts",
|
|
32
|
+
"scripts/**/*.ts",
|
|
33
|
+
"scripts/**/*.json"
|
|
34
|
+
],
|
|
35
|
+
"exclude": [
|
|
36
|
+
"node_modules",
|
|
37
|
+
"dist"
|
|
38
|
+
]
|
|
37
39
|
}
|