@temir.ra/create-test115 0.0.25 → 0.0.27

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 CHANGED
@@ -1,50 +1,5 @@
1
1
  # Version 0
2
2
 
3
- ## next
3
+ ## 0.0.0
4
4
 
5
- 1. Restructured the package files to comply with the "create-" template convention.
6
-
7
- ## 0.3.0
8
-
9
- 1. Updated `scripts/buildinfo.ts` to use `join` from `path` module for better cross-platform compatibility.
10
- 2. Added `scripts/build-cdn.ts` to generate a bundled version of the library for CDN usage.
11
- 3. Added `scripts/build-cdn-map.json` to configure import path rewrites for the CDN build.
12
- 4. Cleaned up legacy fields `main`, `module`, and `types` from `package.json` to rely solely on the `exports` field for module resolution.
13
- 5. Added `browser` condition to the `exports` field in `package.json` to specify the bundled version for CDN usage.
14
- 6. Added `src/dev.ts` as a development entry point for testing and experimentation during development.
15
- 7. Added QoL `clean` and `test` scripts to `package.json`.
16
- 8. Updated `build` workflow in `package.json`. Now it runs `build:lib` to create JavaScript and declaration files, then runs `build:cdn` to create the bundled version for CDN, and finally runs `build:assets` as a placeholder for any future asset build steps.
17
- 9. Added `description` metadata field to `package.json`.
18
- 10. Updated `tsconfig.json` and `tsconfig.build.json` with opiniated settings for better development, build, and publishing experience.
19
- 11. Added documentation for custom scripts and rationale for the selected values in `tsconfig.json`, `tsconfig.build.json`, and `package.json`.
20
- 12. Updated Quick Start instructions to reflect the new scripts and workflow.
21
- 13. Renamed `README.md` and `CHANGELOG.md` to `README.md.template` and `CHANGELOG.md.template` respectively, and added a `bun-create` configuration in `package.json` to rename them back during project creation.
22
- 14. Added `gitignore` (note the missing dot) to the template to ensure that generated projects have a proper `.gitignore` file.
23
-
24
- ## 0.2.0
25
-
26
- 1. Added `tests/` directory for unit tests using Bun's built-in test runner.
27
- 2. Updated `tsconfig.json` to include `tests/` in the `include` array to allow TypeScript to recognize test files during development, while still excluding them from the build output using `tsconfig.build.json`.
28
- 3. Updated `tsconfig.build.json` to exclude `tests/` to ensure that test files are not included in the build output.
29
- 4. Updated `tsconfig.json` to include `baseUrl` and `paths` for better module resolution and cleaner import statements in the source code.
30
-
31
- ## 0.1.4
32
-
33
- 1. Introduced `tsconfig.build.json` to separate build-specific TypeScript configuration from development configuration, allowing for more tailored settings for each use case.
34
- 2. Updated scripts in `package.json` to utilize `tsconfig.build.json` for the build process, ensuring that the build is optimized and does not include unnecessary files or settings meant for development.
35
-
36
- ## 0.1.3
37
-
38
- 1. Added `--no-git` to `bun create` command in Quick Start instructions to allow users to choose when to initialize git repository.
39
-
40
- ## 0.1.2
41
-
42
- 1. Added `--no-install` to `bun create` command in Quick Start instructions to allow users to choose when to install dependencies.
43
-
44
- ## 0.1.1
45
-
46
- 1. Fixed github user in Quick Start instructions.
47
-
48
- ## 0.1.0
49
-
50
- 1. First version of the template.
5
+ 1. Versioning initialized.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Introduction
2
2
 
3
- This package serves as a template for creating Bun libraries. It includes a basic setup with TypeScript, build scripts, and versioning information.
3
+ A template for TypeScript libraries distributed via npm-compatible registries. Provides TypeScript configuration, build tooling for ESM and bundled outputs, and build metadata generation.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -11,9 +11,13 @@ This package serves as a template for creating Bun libraries. It includes a basi
11
11
  3. [Script `scripts/buildinfo.ts`](#script-scriptsbuildinfots)
12
12
  4. [Script `scripts/build-lib-bundle.ts`](#script-scriptsbuild-lib-bundlets)
13
13
  5. [CDN Map `scripts/cdn-rewrite-map.json`](#cdn-map-scriptscdn-rewrite-mapjson)
14
+ 6. [`src/urls.ts`](#srcurlsts)
15
+ 7. [`src/dev.ts`](#srcdevts)
16
+ 8. [`CLAUDE.md` / `AGENTS.md`](#claudemd--agentsmd)
14
17
  3. [DevOps](#devops)
15
- 1. [Change Management](#change-management)
16
- 2. [Publish](#publish)
18
+ 1. [Build](#build)
19
+ 2. [Change Management](#change-management)
20
+ 3. [Publish](#publish)
17
21
  1. [npmjs.org](#npmjsorg)
18
22
  2. [Custom registry](#custom-registry)
19
23
 
@@ -25,13 +29,7 @@ This package serves as a template for creating Bun libraries. It includes a basi
25
29
 
26
30
  bun create --no-install --no-git "@temir.ra/test115" <PACKAGE>
27
31
  cd <PACKAGE>
28
-
29
32
  bun install
30
-
31
- bun run build
32
-
33
- bun run test
34
- bun run dev
35
33
  ```
36
34
 
37
35
  # Documentation
@@ -43,33 +41,44 @@ bun run dev
43
41
 
44
42
  "compilerOptions": {
45
43
 
46
- // supported JavaScript features and syntax in the emitted JavaScript files
47
- // "ES2022" is a reasonable modern baseline
44
+ // ECMAScript version of emitted output
48
45
  "target": "ES2022",
49
-
50
- // how import and export statements are written in the emitted JavaScript files
51
- // "ESNext" emits standard ES module syntax unchanged
46
+
47
+ // output module format; ESNext passes ES module syntax through unchanged
52
48
  "module": "ESNext",
53
-
54
- // available built-in types
49
+
50
+ // type definitions for built-in APIs
55
51
  "lib": [
56
52
  "ES2022", // standard JavaScript runtime APIs
57
- "DOM" // browser globals or `import.meta.url`
53
+ "DOM" // browser globals for bundled output
58
54
  ],
59
55
 
60
- // permissive about file extensions in import statements
61
- // `tsconfig.build.json` switches to a stricter resolution mode
56
+ // module resolution strategy; bundler mode allows omitting file extensions in imports
57
+ // tsconfig.build.json overrides this to nodenext for strict ESM compliance
62
58
  "moduleResolution": "bundler",
63
59
 
64
- // collection of type-safety checks
60
+ // enables all strict type-checking options
65
61
  "strict": true,
66
62
 
67
- // compatibility shims that make it easier to import CommonJS modules as if they were ES modules
63
+ // enforces import type for type-only imports; emitted module syntax matches source exactly
64
+ "verbatimModuleSyntax": true,
65
+
66
+ // array indexing and index signature access returns T | undefined instead of T
67
+ "noUncheckedIndexedAccess": true,
68
+
69
+ // distinguishes absent optional properties from those explicitly set to undefined
70
+ "exactOptionalPropertyTypes": true,
71
+
72
+ // requires explicit override keyword when overriding base class methods
73
+ "noImplicitOverride": true,
74
+
75
+ // requires explicit types on all exported declarations; enables parallel .d.ts generation by external tools
76
+ "isolatedDeclarations": true,
77
+
78
+ // allows default imports from CommonJS modules
68
79
  "esModuleInterop": true,
69
80
 
70
- // enables TypeScript project references
71
- // required for `tsc --build` to work correctly across monorepo packages
72
- // creates `*.tsbuildinfo` files that speed up subsequent builds by only rebuilding packages that have changed since the last build
81
+ // enables project references and incremental builds via *.tsbuildinfo
73
82
  "composite": true,
74
83
 
75
84
  // do not type-check `.d.ts` files in `node_modules/`
@@ -78,42 +87,26 @@ bun run dev
78
87
  // enforce consistent casing across import statements
79
88
  "forceConsistentCasingInFileNames": true,
80
89
 
81
- // allow importing JSON files as modules and infer the full type of the JSON structure
90
+ // allows importing JSON files as typed modules
82
91
  "resolveJsonModule": true,
83
92
 
84
- // generate .d.ts type declaration files alongside the JavaScript output
93
+ // emit .d.ts declaration files
85
94
  "declaration": true,
86
- // allow a consumer's editor to "go to definition" on something from the library
95
+ // emit .d.ts.map files mapping declarations back to source
87
96
  "declarationMap": true,
88
97
 
89
- // prevents tsc from emitting any JavaScript files
90
- // during development, rely on executing environment to handle TypeScript directly
91
- // during build, use `tsconfig.build.json` to override this setting and emit JavaScript files for distribution
98
+ // emit only .d.ts files, no JavaScript; overridden in tsconfig.build.json
92
99
  "emitDeclarationOnly": true,
93
100
 
94
- // the directory where the emitted JavaScript and declaration files will be placed when building the library
101
+ // output directory for emitted files
95
102
  "outDir": "./dist",
96
103
 
97
- // sets source root directory to mirror in the "outDir" when emitting files
98
- // during development, it is set to the project root so that all files in the project are included in the editor features and type-checking
99
- // during build, `tsconfig.build.json` narrows it down to only `src/`
104
+ // root directory mirrored into outDir; set to project root during development, overridden to src/ in tsconfig.build.json
100
105
  "rootDir": ".",
101
106
 
102
- // the base directory to resolve non-relative module imports
103
- "baseUrl": ".",
104
-
105
- // a mapping of module import paths to physical paths in the project
106
- // `paths` is a TypeScript-only feature - it must not be used in import statements in `src/` files
107
- "paths": {
108
- "@/*": [
109
- "src/*"
110
- ]
111
- }
112
-
113
107
  },
114
108
 
115
- // files to be included/excluded by the TypeScript compiler and the development environment
116
- // `tsconfig.build.json` overrides these settings to include only `src/` files
109
+ // includes src/, tests/, and scripts/ for type-checking and IDE support; overridden in tsconfig.build.json
117
110
  "include": [
118
111
  "src/**/*.ts",
119
112
  "tests/**/*.ts",
@@ -128,9 +121,9 @@ bun run dev
128
121
  }
129
122
  ```
130
123
 
131
- During development, the `tsconfig.json` configuration prevents emitting JavaScript files and relies on the executing environment to handle TypeScript directly. The settings include `src/`, `tests/`, and `scripts/` for type-checking and editor features.
124
+ `tsconfig.json` is the development configuration. `tsconfig.build.json` extends it, narrowing scope to `src/` and enabling JavaScript output for distribution.
132
125
 
133
- When building the library for distribution, the `tsconfig.build.json` configuration overrides the settings to emit JavaScript files while including only the `src/`.
126
+ `declarationMap: true` enables go-to-definition for npm/bun consumers. For this to work, the original `.ts` source files must be accessible to the consumer. Consider adding `src/` to the `files` field in `package.json`.
134
127
 
135
128
  ```json
136
129
  {
@@ -139,11 +132,10 @@ When building the library for distribution, the `tsconfig.build.json` configurat
139
132
 
140
133
  "compilerOptions": {
141
134
 
142
- // sets root directory to mirror in the "outDir" when emitting files
135
+ // narrows root to src/ for distribution output
143
136
  "rootDir": "./src",
144
137
 
145
- // "nodenext" is the strictest and most forward-compatible ESM mode
146
- // imports must include explicit `.js` file extensions
138
+ // nodenext enforces strict ESM compliance; imports must use explicit .js file extensions
147
139
  "module": "nodenext",
148
140
  "moduleResolution": "nodenext",
149
141
 
@@ -152,7 +144,6 @@ When building the library for distribution, the `tsconfig.build.json` configurat
152
144
 
153
145
  },
154
146
 
155
- // include only the source files for the build, excluding tests and scripts
156
147
  "include": [
157
148
  "src/**/*.ts"
158
149
  ],
@@ -185,14 +176,18 @@ When building the library for distribution, the `tsconfig.build.json` configurat
185
176
  "url": ""
186
177
  },
187
178
 
188
- // "module" makes every `.js` file in the package to be treated as an ES module unless explicitly named `.cjs`
179
+ // treats all .js files as ES modules; use .cjs extension for CommonJS files
189
180
  "type": "module",
190
181
 
191
- // runtime consults "exports" to find the actual file to load
192
- // "import" condition is used by ESM consumers
193
- // "types" condition is used by TypeScript to find the declaration files
194
- // "browser" condition is used by CDN infrastructure
195
- // "entrypoint" is a custom condition used by the build script to find the entry point for the CDN build
182
+ // no module has side effects; enables full tree-shaking by bundlers
183
+ // set to an array of file paths if some modules do have side effects, e.g. ["./src/polyfill.ts"]
184
+ "sideEffects": false,
185
+
186
+ // package entry points by consumer type
187
+ // "entrypoint" — custom condition; used by the bundle script to locate the source entry point
188
+ // "browser" — CDN consumers; resolves to the bundled output
189
+ // "import" — ESM consumers; resolves to the compiled module output
190
+ // "types" — TypeScript consumers; resolves to the declaration files
196
191
  "exports": {
197
192
  ".": {
198
193
  "entrypoint": "./src/index.ts",
@@ -202,7 +197,13 @@ When building the library for distribution, the `tsconfig.build.json` configurat
202
197
  }
203
198
  },
204
199
 
205
- // specifies the entry point for the CLI executable exposed when the package is installed globally or as a dependency
200
+ // package-internal import aliases resolved natively by Node.js and Bun; keys must start with #
201
+ // use as: import { foo } from "#src/utils.js"
202
+ "imports": {
203
+ "#src/*": "./src/*"
204
+ },
205
+
206
+ // CLI entry point; omit if the package is not a CLI tool
206
207
  "bin": "./dist/cli.bundle.js",
207
208
 
208
209
  // files to include in the published package
@@ -214,30 +215,24 @@ When building the library for distribution, the `tsconfig.build.json` configurat
214
215
 
215
216
  "scripts": {
216
217
 
217
- // cleans the `dist/` directory before building
218
218
  "clean": "rm -rf dist/",
219
219
 
220
- // overwrites `src/buildinfo.ts` with the current version and git hash (if available)
220
+ // lifecycle hook; runs automatically before "build"; generates buildinfo.txt
221
221
  "prebuild": "bun run scripts/buildinfo.ts",
222
222
 
223
- // runs all tests
224
223
  "test": "bun test",
225
224
 
226
- // runs all build steps in sequence
227
225
  "build": "bun run build:lib && bun run build:lib-bundle",
228
226
 
229
- // uses `tsconfig.build.json` to compile the TypeScript source files
230
227
  "build:lib": "tsc --project tsconfig.build.json",
231
- // bundles the library for distribution in both ESM and IIFE formats
228
+ // bundles the library into ESM and IIFE formats for distribution
232
229
  "build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
233
230
 
234
- // builds the CLI (set by "bin" field) for distribution
235
231
  "build:cli-bundle": "bun build src/cli.ts --entry-naming \"[dir]/[name].bundle.[ext]\" --outdir dist --target node --format esm --minify --sourcemap=external",
236
232
 
237
- // type checks the TypeScript source files without emitting any output
238
233
  "typecheck": "tsc --noEmit",
239
234
 
240
- // runs the development file
235
+ // runs src/dev.ts in watch mode
241
236
  "dev": "bun run --watch src/dev.ts"
242
237
 
243
238
  },
@@ -250,21 +245,15 @@ When building the library for distribution, the `tsconfig.build.json` configurat
250
245
 
251
246
  ## Script `scripts/buildinfo.ts`
252
247
 
253
- This script overwrites `buildinfo.txt` with the current version from `package.json` and the current git hash (if available). The generated `buildinfo.txt` file is included in the published package and can be used for debugging and support purposes to quickly identify the exact version of the library being used, along with the corresponding source code in the repository.
248
+ Generates `buildinfo.txt` containing the version from `package.json` and the git commit hash (if available). Included in the published package for build traceability.
254
249
 
255
250
  ## Script `scripts/build-lib-bundle.ts`
256
251
 
257
- This script bundles the library for distribution in both ESM and IIFE formats. It reads the `exports` field from `package.json` to determine the entry points for the library and generates bundled files. A custom condition `entrypoint` is used in the `exports` field to specify the entry point for the build.
258
-
259
- During the bundling process, the import specifiers in the source files can be rewritten to point to a CDN URL of a package, instead of using the package name that would be resolved from `node_modules/`.
260
-
261
- The list of import specifiers to rewrite and their corresponding CDN URLs can be configured in the `scripts/cdn-rewrite-map.json` file.
252
+ Bundles the library to ESM and IIFE formats. Entry points are resolved from the `entrypoint` condition in the `exports` field of `package.json`. Import specifiers can be rewritten to CDN URLs via `scripts/cdn-rewrite-map.json`.
262
253
 
263
254
  ## CDN Map `scripts/cdn-rewrite-map.json`
264
255
 
265
- This JSON file contains a mapping of module import specifiers to their corresponding CDN URLs. During the CDN build process, if an import specifier in the source files matches a key in this map, it will be replaced with the corresponding CDN URL in the bundled output.
266
-
267
- The URL can contain the placeholder `<VERSION>` which will be replaced with the current version of a package from `package.json` that matches the import specifier.
256
+ Maps import specifiers to CDN URLs. During bundling, matching specifiers in source files are rewritten to their CDN equivalents. `<VERSION>` in a URL is replaced with the version of the matching package from `package.json`.
268
257
 
269
258
  ```json
270
259
  {
@@ -272,14 +261,9 @@ The URL can contain the placeholder `<VERSION>` which will be replaced with the
272
261
  }
273
262
  ```
274
263
 
275
- - Keys are the import specifiers as they appear in source code.
276
- - Values are CDN URLs. The URL can contain the placeholder `<VERSION>` which will be replaced with the current version of a package from `package.json` that matches the import specifier.
277
-
278
264
  ## `"bin"` field in `package.json`
279
265
 
280
- The `"bin"` field in `package.json` specifies the entry point for the CLI executable exposed when the package is installed globally or as a dependency.
281
-
282
- If the package is intended to be used as a CLI tool, the `"bin"` field should point to the JavaScript file that serves as the entry point for the CLI. This file will be bundled during the build process (e.g. using `build:cli-bundle` script) and included in the published package.
266
+ For CLI packages, add the following to `package.json`:
283
267
 
284
268
  ```json
285
269
  {
@@ -296,20 +280,45 @@ If the package is intended to be used as a CLI tool, the `"bin"` field should po
296
280
  }
297
281
  ```
298
282
 
283
+ ## `src/urls.ts`
284
+
285
+ Resolves `CHANGELOG.md` and `buildinfo.txt` relative to `dist/` at runtime using `import.meta.url`. Provides stable references to published package assets regardless of install location.
286
+
287
+ ## `src/dev.ts`
288
+
289
+ Development scratchpad — not published, excluded from `tsconfig.build.json`. Run with `bun run dev` in watch mode. Use it to manually test and explore library code during development.
290
+
291
+ ## `CLAUDE.md` / `AGENTS.md`
292
+
293
+ AI assistant context files. Provide project layout, commands, and architecture notes. `AGENTS.md` references `CLAUDE.md`. The template ships two pairs:
294
+
295
+ - Root pair — describes the template package itself (scaffolding tool, CLI, how `template/` maps to generated projects)
296
+ - `template/` pair — describes the generated library project; update to reflect the specific library being developed
297
+
299
298
  # DevOps
300
299
 
300
+ ## Build
301
+
302
+ `prebuild` runs automatically before `build`, generating `buildinfo.txt`.
303
+
304
+ ```bash
305
+ bun run build # compile via tsc + bundle to ESM, IIFE, and CLI
306
+ ```
307
+
301
308
  ## Change Management
302
309
 
303
310
  1. Create a new branch for the change.
304
- 2. Make the changes and commit them to the branch.
305
- 3. Add an entry for the new version in [`CHANGELOG-template.md`](CHANGELOG-template.md).
306
- 4. Pull & publish request the branch.
311
+ 2. Make the changes and commit.
312
+ 3. Bump the version in [`package.json`](package.json).
313
+ 4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
314
+ 5. Run `bun run build`.
315
+ 6. Pull request the branch and publish.
307
316
 
308
317
  ## Publish
309
318
 
310
319
  ### `npmjs.org`
311
320
 
312
- ⚠️ Either run `npm login` or set up `~/.npmrc` or `bunfig.toml` with the appropriate auth token before running the publish command.
321
+ ⚠️ Authenticate first: run `npm login` or configure `~/.npmrc` or `bunfig.toml` with an auth token.
313
322
 
314
323
  ```powershell
315
324
  bun publish --registry https://registry.npmjs.org/ --access public
package/buildinfo.txt CHANGED
@@ -1 +1 @@
1
- 0.0.25+721f42d
1
+ 0.0.27+3f30950
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{cpSync as o,readFileSync as f,renameSync as d,writeFileSync as u}from"fs";import{resolve as t,basename as U}from"path";import{fileURLToPath as a}from"url";var n=new URL(".",import.meta.url),l=new URL("../CHANGELOG.md",n),p=new URL("../buildinfo.txt",n),m=new URL("../template",n);try{let r=process.argv[2];if(!r)throw Error("Destination path is required. Usage: `bun/npm create <template> <destination>`");let e=t(process.cwd(),r),i=U(e),g=t(a(m));o(g,e,{recursive:!0}),o(t(a(l)),t(e,"CHANGELOG-template.md")),o(t(a(p)),t(e,"buildinfo-template.txt"));let s=t(e,"package.json"),c=JSON.parse(f(s,"utf-8"));c.name=i,u(s,JSON.stringify(c,null,2)),d(t(e,"gitignore"),t(e,".gitignore")),console.log(`Template has been successfully instantiated at '${e}' with package name '${i}'.`)}catch(r){let e=r instanceof Error?r:Error(String(r));console.error("Error:",e.message),process.exit(1)}
2
+ import{cpSync as o,readFileSync as U,renameSync as f,writeFileSync as d}from"fs";import{resolve as t,basename as u}from"path";import{fileURLToPath as a}from"url";var n=new URL(".",import.meta.url),l=new URL("../CHANGELOG.md",n),p=new URL("../buildinfo.txt",n),m=new URL("../template",n);try{let r=process.argv[2];if(!r)throw Error("Destination path is required. Usage: `bun/npm create <template> <destination>`");let e=t(process.cwd(),r),i=u(e),g=t(a(m));o(g,e,{recursive:!0}),o(t(a(l)),t(e,"CHANGELOG-template.md")),o(t(a(p)),t(e,"buildinfo-template.txt"));let s=t(e,"package.json"),c=JSON.parse(U(s,"utf-8"));c.name=i,d(s,JSON.stringify(c,null,2)),f(t(e,"gitignore"),t(e,".gitignore")),console.log(`Template has been successfully instantiated at '${e}' with package name '${i}'.`)}catch(r){let e=r instanceof Error?r:Error(String(r));console.error("Error:",e.message),process.exit(1)}
3
3
 
4
- //# debugId=BED85076F5B77B3B64756E2164756E21
4
+ //# debugId=683E20367A2ED95764756E2164756E21
@@ -3,9 +3,9 @@
3
3
  "sources": ["..\\src\\cli.ts", "..\\src\\urls.ts"],
4
4
  "sourcesContent": [
5
5
  "#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve, basename } from 'path';\r\nimport { fileURLToPath } from 'url';\r\nimport { buildinfoUrl, changelogUrl, templateUrl } from './urls.js';\r\n\r\n\r\ntry {\r\n\r\n const dest = process.argv[2];\r\n if (!dest) throw new Error('Destination path is required. Usage: `bun/npm create <template> <destination>`');\r\n\r\n const destinationPath = resolve(process.cwd(), dest);\r\n const packageName = basename(destinationPath);\r\n\r\n const templatePath = resolve(fileURLToPath(templateUrl));\r\n\r\n cpSync(templatePath, destinationPath, { recursive: true });\r\n cpSync(resolve(fileURLToPath(changelogUrl)), resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(resolve(fileURLToPath(buildinfoUrl)), resolve(destinationPath, 'buildinfo-template.txt'));\r\n\r\n const packageManifestPath = resolve(destinationPath, 'package.json');\r\n const packageManifest = JSON.parse(readFileSync(packageManifestPath, 'utf-8'));\r\n packageManifest.name = packageName;\r\n writeFileSync(packageManifestPath, JSON.stringify(packageManifest, 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
- "export const distUrl = new URL('.', import.meta.url);\r\nexport const changelogUrl = new URL('../CHANGELOG.md', distUrl);\r\nexport const buildinfoUrl = new URL('../buildinfo.txt', distUrl);\r\nexport const templateUrl = new URL('../template', distUrl);\r\n"
6
+ "export const distUrl: URL = new URL('.', import.meta.url);\r\nexport const changelogUrl: URL = new URL('../CHANGELOG.md', distUrl);\r\nexport const buildinfoUrl: URL = new URL('../buildinfo.txt', distUrl);\r\nexport const templateUrl: URL = new URL('../template', distUrl);\r\n"
7
7
  ],
8
- "mappings": ";AAEA,iBAAS,kBAAQ,gBAAc,mBAAY,WAC3C,kBAAS,cAAS,aAClB,wBAAS,YCJF,IAAM,EAAU,IAAI,IAAI,IAAK,YAAY,GAAG,EACtC,EAAe,IAAI,IAAI,kBAAmB,CAAO,EACjD,EAAe,IAAI,IAAI,mBAAoB,CAAO,EAClD,EAAc,IAAI,IAAI,cAAe,CAAO,EDKzD,GAAI,CAEA,IAAM,EAAO,QAAQ,KAAK,GAC1B,GAAI,CAAC,EAAM,MAAU,MAAM,gFAAgF,EAE3G,IAAM,EAAkB,EAAQ,QAAQ,IAAI,EAAG,CAAI,EAC7C,EAAc,EAAS,CAAe,EAEtC,EAAe,EAAQ,EAAc,CAAW,CAAC,EAEvD,EAAO,EAAc,EAAiB,CAAE,UAAW,EAAK,CAAC,EACzD,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,uBAAuB,CAAC,EAC9F,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,wBAAwB,CAAC,EAE/F,IAAM,EAAsB,EAAQ,EAAiB,cAAc,EAC7D,EAAkB,KAAK,MAAM,EAAa,EAAqB,OAAO,CAAC,EAC7E,EAAgB,KAAO,EACvB,EAAc,EAAqB,KAAK,UAAU,EAAiB,KAAM,CAAC,CAAC,EAE3E,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",
9
- "debugId": "BED85076F5B77B3B64756E2164756E21",
8
+ "mappings": ";AAEA,iBAAS,kBAAQ,gBAAc,mBAAY,WAC3C,kBAAS,cAAS,aAClB,wBAAS,YCJF,IAAM,EAAe,IAAI,IAAI,IAAK,YAAY,GAAG,EAC3C,EAAoB,IAAI,IAAI,kBAAmB,CAAO,EACtD,EAAoB,IAAI,IAAI,mBAAoB,CAAO,EACvD,EAAmB,IAAI,IAAI,cAAe,CAAO,EDK9D,GAAI,CAEA,IAAM,EAAO,QAAQ,KAAK,GAC1B,GAAI,CAAC,EAAM,MAAU,MAAM,gFAAgF,EAE3G,IAAM,EAAkB,EAAQ,QAAQ,IAAI,EAAG,CAAI,EAC7C,EAAc,EAAS,CAAe,EAEtC,EAAe,EAAQ,EAAc,CAAW,CAAC,EAEvD,EAAO,EAAc,EAAiB,CAAE,UAAW,EAAK,CAAC,EACzD,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,uBAAuB,CAAC,EAC9F,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,wBAAwB,CAAC,EAE/F,IAAM,EAAsB,EAAQ,EAAiB,cAAc,EAC7D,EAAkB,KAAK,MAAM,EAAa,EAAqB,OAAO,CAAC,EAC7E,EAAgB,KAAO,EACvB,EAAc,EAAqB,KAAK,UAAU,EAAiB,KAAM,CAAC,CAAC,EAE3E,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",
9
+ "debugId": "683E20367A2ED95764756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temir.ra/create-test115",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "Typescript library template",
5
5
  "author": "temir.ra",
6
6
  "license": "MIT",
@@ -15,14 +15,20 @@
15
15
  "url": ""
16
16
  },
17
17
  "type": "module",
18
+ "sideEffects": false,
18
19
  "exports": {
19
20
  ".": {
20
- "entrypoint": "./src/index.ts",
21
+ "entrypoint": "./src/cli.ts",
21
22
  "browser": "./dist/index.bundle.js",
22
23
  "import": "./dist/index.js",
23
24
  "types": "./dist/index.d.ts"
24
25
  }
25
26
  },
27
+ "imports": {
28
+ "#src/*": "./src/*",
29
+ "#scripts/*": "./scripts/*",
30
+ "#tests/*": "./tests/*"
31
+ },
26
32
  "bin": "./dist/cli.bundle.js",
27
33
  "files": [
28
34
  "dist",
@@ -0,0 +1 @@
1
+ See [CLAUDE.md](CLAUDE.md).
@@ -0,0 +1,73 @@
1
+ # <package-name>
2
+
3
+ A Bun TypeScript library.
4
+
5
+ ## Project Layout
6
+
7
+ ```
8
+ <package-name>/
9
+ ├── src/
10
+ │ ├── index.ts # Library entry point (public API)
11
+ │ ├── dev.ts # Development scratchpad — run with `bun run dev`
12
+ │ └── urls.ts # URL helpers (changelog, buildinfo)
13
+ ├── scripts/
14
+ │ ├── buildinfo.ts # Writes version + git hash to buildinfo.txt
15
+ │ ├── build-lib-bundle.ts # Bundles the library for ESM + CDN distribution
16
+ │ └── cdn-rewrite-map.json # CDN import rewrite rules (empty by default)
17
+ ├── tests/ # Unit tests (Bun test runner)
18
+ ├── dist/ # Build output (gitignored)
19
+ ├── buildinfo.txt # Written during build; included in published package
20
+ ├── CHANGELOG.md # Version history
21
+ ├── CLAUDE.md # This file — AI context for the library project
22
+ └── AGENTS.md # References CLAUDE.md
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ ```bash
28
+ bun install # Install dependencies
29
+ bun run build # Compile + bundle the library
30
+ bun run test # Run unit tests
31
+ bun run typecheck # Type-check without emitting
32
+ bun run dev # Run src/dev.ts in watch mode
33
+ bun run clean # Remove dist/
34
+ ```
35
+
36
+ ## TypeScript Configuration
37
+
38
+ Two tsconfig files serve different purposes:
39
+
40
+ | File | Purpose |
41
+ |------|---------|
42
+ | `tsconfig.json` | Development — no emit, includes `src/`, `tests/`, `scripts/` |
43
+ | `tsconfig.build.json` | Build — emits JS + `.d.ts`, `src/` only (excludes `dev.ts`, tests, scripts) |
44
+
45
+ `bun run build:lib` uses `tsconfig.build.json`. During development the runtime handles TypeScript directly so no compilation step is needed.
46
+
47
+ Both configs enable an extended strict type-safety profile beyond `strict`: `verbatimModuleSyntax`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitOverride`, `isolatedDeclarations`.
48
+
49
+ ## Build Outputs
50
+
51
+ `bun run build` runs two steps in sequence:
52
+
53
+ 1. **`build:lib`** — `tsc --project tsconfig.build.json` → `dist/*.js` + `dist/*.d.ts`
54
+ 2. **`build:lib-bundle`** — `scripts/build-lib-bundle.ts` → `dist/index.bundle.js` (ESM, minified) + `dist/index.iife.js` (IIFE, minified)
55
+
56
+ The `exports` field in `package.json` maps consumers to the right file:
57
+
58
+ | Condition | File |
59
+ |-----------|------|
60
+ | `import` | `dist/index.js` |
61
+ | `types` | `dist/index.d.ts` |
62
+ | `browser` | `dist/index.bundle.js` |
63
+
64
+ ## Package Configuration
65
+
66
+ Key `package.json` fields:
67
+
68
+ - `"sideEffects": false` — enables full tree-shaking by bundlers
69
+ - `"imports": { "#src/*": "./src/*" }` — package-internal path aliases resolved natively at runtime; use `import { foo } from "#src/utils.js"`
70
+
71
+ ## Publishing
72
+
73
+ See [README.md](README.md) for registry setup and publish commands.
@@ -12,7 +12,25 @@
12
12
 
13
13
  # Quick Start
14
14
 
15
- *&lt;QUICK START INSTRUCTIONS&gt;*
15
+ **Development**
16
+
17
+ ```bash
18
+ bun run dev # run src/dev.ts in watch mode
19
+ bun test # run tests
20
+ bun run typecheck # type-check without emitting
21
+ ```
22
+
23
+ **Build**
24
+
25
+ `prebuild` runs automatically before `build`, generating `buildinfo.txt`.
26
+
27
+ ```bash
28
+ bun run build # compile via tsc + bundle to ESM and IIFE
29
+ ```
30
+
31
+ **Publish**
32
+
33
+ See [Publish](#publish).
16
34
 
17
35
  # Documentation
18
36
 
@@ -23,7 +41,39 @@
23
41
  ## Change Management
24
42
 
25
43
  1. Create a new branch for the change.
26
- 2. Make the changes and commit them to the branch.
44
+ 2. Make the changes and commit.
27
45
  3. Bump the version in [`package.json`](package.json).
28
46
  4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
29
- 5. Pull request the branch.
47
+ 5. Run `bun run build`.
48
+ 6. Pull request the branch and publish.
49
+
50
+ ## Publish
51
+
52
+ ### `npmjs.org`
53
+
54
+ ⚠️ Authenticate first: run `npm login` or configure `~/.npmrc` or `bunfig.toml` with an auth token.
55
+
56
+ ```powershell
57
+ bun publish --registry https://registry.npmjs.org/ --access public
58
+ ```
59
+
60
+ ### Custom registry
61
+
62
+ ```bash
63
+ # placeholder:
64
+ # <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
65
+ # <REGISTRY_URL: <REGISTRY_URL>
66
+ # <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
67
+ ```
68
+
69
+ `bunfig.toml`:
70
+
71
+ ```toml
72
+ [install.scopes]
73
+ <SCOPE_WITHOUT_AT> = { url = "<REGISTRY_URL>", token = "$BUN_PUBLISH_AUTH_TOKEN" }
74
+ ```
75
+
76
+ ```powershell
77
+ $env:BUN_PUBLISH_AUTH_TOKEN = "<BUN_PUBLISH_AUTH_TOKEN>"
78
+ bun publish
79
+ ```
@@ -12,6 +12,7 @@
12
12
  "url": ""
13
13
  },
14
14
  "type": "module",
15
+ "sideEffects": false,
15
16
  "exports": {
16
17
  ".": {
17
18
  "entrypoint": "./src/index.ts",
@@ -20,6 +21,11 @@
20
21
  "types": "./dist/index.d.ts"
21
22
  }
22
23
  },
24
+ "imports": {
25
+ "#src/*": "./src/*",
26
+ "#scripts/*": "./scripts/*",
27
+ "#tests/*": "./tests/*"
28
+ },
23
29
  "files": [
24
30
  "dist",
25
31
  "CHANGELOG.md",
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from 'fs';
2
2
  import { join } from 'path';
3
- import CDN_REWRITE_MAP from 'scripts/cdn-rewrite-map.json';
3
+ import CDN_REWRITE_MAP from '#scripts/cdn-rewrite-map.json';
4
4
 
5
5
 
6
6
  interface ExportConditions {
@@ -1,4 +1,4 @@
1
- const start = performance.now();
1
+ const start: number = performance.now();
2
2
 
3
3
  // dev code
4
4
 
@@ -1,3 +1,3 @@
1
- export const distUrl = new URL('.', import.meta.url);
2
- export const changelogUrl = new URL('../CHANGELOG.md', distUrl);
3
- export const buildinfoUrl = new URL('../buildinfo.txt', distUrl);
1
+ export const distUrl: URL = new URL('.', import.meta.url);
2
+ export const changelogUrl: URL = new URL('../CHANGELOG.md', distUrl);
3
+ export const buildinfoUrl: URL = new URL('../buildinfo.txt', distUrl);
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect } from 'bun:test';
2
2
  import { readFileSync } from 'fs';
3
3
  import { fileURLToPath } from 'url';
4
- import { buildinfoUrl } from '@/urls';
4
+ import { buildinfoUrl } from '#src/urls.js';
5
5
 
6
6
 
7
7
  describe('buildInfo', () => {
@@ -8,6 +8,11 @@
8
8
  ],
9
9
  "moduleResolution": "bundler",
10
10
  "strict": true,
11
+ "verbatimModuleSyntax": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "exactOptionalPropertyTypes": true,
14
+ "noImplicitOverride": true,
15
+ "isolatedDeclarations": true,
11
16
  "esModuleInterop": true,
12
17
  "composite": true,
13
18
  "skipLibCheck": true,
@@ -18,12 +23,6 @@
18
23
  "emitDeclarationOnly": true,
19
24
  "outDir": "./dist",
20
25
  "rootDir": ".",
21
- "baseUrl": ".",
22
- "paths": {
23
- "@/*": [
24
- "src/*"
25
- ]
26
- }
27
26
  },
28
27
  "include": [
29
28
  "src/**/*.ts",