@tmjeee/w-lib 0.0.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 +22 -0
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.0.1] - 2026-05-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial library skeleton for npm publishing
|
|
12
|
+
- `helloWorld()` sample function exported as the public API
|
|
13
|
+
- Full ESM + CJS dual package support via tsdown
|
|
14
|
+
- TypeScript strict configuration
|
|
15
|
+
- Vitest test suite with coverage
|
|
16
|
+
- `examples/basic.ts` runnable usage example
|
|
17
|
+
- Complete publish-ready `package.json` (exports map, files, sideEffects, publishConfig)
|
|
18
|
+
- MIT license and minimal conventional changelog
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
- This is the bootstrap release of the w-lib skeleton.
|
|
22
|
+
- Ready for `npm publish --access public`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tmjeee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# w-lib
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tmjeee/w-lib)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A minimal, modern TypeScript library skeleton ready for publishing to npmjs.com.
|
|
7
|
+
|
|
8
|
+
This package demonstrates current (2026) best practices for shipping small, tree-shakeable, dual-format (ESM + CJS) libraries with excellent TypeScript support.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @tmjeee/w-lib
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
This package is **ESM-only**.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { helloWorld } from '@tmjeee/w-lib';
|
|
22
|
+
|
|
23
|
+
console.log(helloWorld()); // "Hello, world!"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> **Note**: CommonJS (`require()`) is not supported.
|
|
27
|
+
> If you are in a CommonJS environment, use dynamic import instead:
|
|
28
|
+
> ```js
|
|
29
|
+
> const { helloWorld } = await import('@tmjeee/w-lib');
|
|
30
|
+
> ```
|
|
31
|
+
|
|
32
|
+
For more information, see the [Node.js documentation on publishing ESM packages](https://nodejs.org/en/learn/modules/publishing-a-package).
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### `helloWorld(): string`
|
|
37
|
+
|
|
38
|
+
Returns the classic greeting.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
helloWorld(); // "Hello, world!"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Install dependencies
|
|
48
|
+
npm install
|
|
49
|
+
|
|
50
|
+
# Type check
|
|
51
|
+
npm run typecheck
|
|
52
|
+
|
|
53
|
+
# Run tests (once, exits after completion)
|
|
54
|
+
npm test
|
|
55
|
+
|
|
56
|
+
# Run tests in watch mode (for development)
|
|
57
|
+
npm run test:watch
|
|
58
|
+
|
|
59
|
+
# Run tests with coverage
|
|
60
|
+
npm run test:coverage
|
|
61
|
+
|
|
62
|
+
# Build (outputs to dist/)
|
|
63
|
+
npm run build
|
|
64
|
+
|
|
65
|
+
# Watch mode during development
|
|
66
|
+
npm run dev
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Project Structure
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
src/index.ts # Source (helloWorld)
|
|
73
|
+
test/index.test.ts # Vitest tests
|
|
74
|
+
examples/basic.ts # Runnable usage demo
|
|
75
|
+
dist/ # Build output (generated)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Publishing
|
|
79
|
+
|
|
80
|
+
This package is configured for immediate publishing.
|
|
81
|
+
|
|
82
|
+
### Recommended: One-command publish
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Bump version first (patch / minor / major)
|
|
86
|
+
npm version patch
|
|
87
|
+
|
|
88
|
+
# Dry-run first (highly recommended)
|
|
89
|
+
npm run publish:npm:dry
|
|
90
|
+
|
|
91
|
+
# Then publish for real
|
|
92
|
+
npm run publish:npm
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Manual / step-by-step (with safety checks)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 1. Make sure everything is clean
|
|
99
|
+
npm run typecheck && npm test && npm run build
|
|
100
|
+
# (npm test now runs once and exits automatically)
|
|
101
|
+
|
|
102
|
+
# 2. Dry-run the publish (strongly recommended)
|
|
103
|
+
npm publish --dry-run --access public
|
|
104
|
+
|
|
105
|
+
# 3. Bump version
|
|
106
|
+
npm version patch
|
|
107
|
+
|
|
108
|
+
# 4. Publish
|
|
109
|
+
npm publish --access public
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The `prepublishOnly` hook (and both `publish:npm*` scripts) ensure that `build` + `test` run before anything is published.
|
|
113
|
+
|
|
114
|
+
### What gets published?
|
|
115
|
+
|
|
116
|
+
Only the contents of the `dist/` folder plus `package.json`, `README.md`, `LICENSE`, and `CHANGELOG.md` (controlled via the `"files"` field).
|
|
117
|
+
|
|
118
|
+
### Automated publishing with GitHub Actions
|
|
119
|
+
|
|
120
|
+
This repository includes two GitHub Actions workflows:
|
|
121
|
+
|
|
122
|
+
- **`.github/workflows/ci.yml`** — Runs type checking and tests on every push and pull request. Can also be triggered manually from the Actions tab.
|
|
123
|
+
- **`.github/workflows/publish.yml`** — Publishes to npmjs.com when you create a new GitHub Release. Can also be triggered manually from the Actions tab (use with caution).
|
|
124
|
+
|
|
125
|
+
#### Setup steps (one time)
|
|
126
|
+
|
|
127
|
+
1. Create an npm access token:
|
|
128
|
+
- Go to https://www.npmjs.com/settings/~tokens
|
|
129
|
+
- Generate a new **Automation** token (or **Granular** with publish permission for `@tmjeee/w-lib`)
|
|
130
|
+
2. Add the token as a repository secret:
|
|
131
|
+
- In your GitHub repo → **Settings → Secrets and variables → Actions**
|
|
132
|
+
- Create a new secret named `NPM_TOKEN` with the value from step 1
|
|
133
|
+
3. (Optional but recommended) Enable npm **Trusted Publishing** (OIDC) for passwordless publishing:
|
|
134
|
+
- See the comments in `publish.yml` and https://docs.npmjs.com/trusted-publishers
|
|
135
|
+
|
|
136
|
+
#### How to release
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# 1. Update CHANGELOG.md
|
|
140
|
+
# 2. Commit everything
|
|
141
|
+
git add .
|
|
142
|
+
git commit -m "chore: prepare v0.0.2"
|
|
143
|
+
|
|
144
|
+
# 3. Create a version tag + GitHub Release
|
|
145
|
+
npm version patch
|
|
146
|
+
git push && git push --tags
|
|
147
|
+
|
|
148
|
+
# 4. Go to GitHub → Releases → "Draft a new release"
|
|
149
|
+
# - Choose the tag you just pushed
|
|
150
|
+
# - Publish the release
|
|
151
|
+
|
|
152
|
+
# → The publish workflow will run automatically and publish to npm
|
|
153
|
+
|
|
154
|
+
**Alternative**: You can also manually trigger the publish workflow from the GitHub repo → **Actions** tab → **"Publish to npmjs"** → **"Run workflow"**.
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Tooling
|
|
158
|
+
|
|
159
|
+
- **Build**: [tsdown](https://tsdown.dev/) (Rolldown + Oxc)
|
|
160
|
+
- **Testing**: [Vitest](https://vitest.dev/)
|
|
161
|
+
- **TypeScript**: Strict mode, ES2022 target, bundler resolution
|
|
162
|
+
|
|
163
|
+
### Optional: Add oxlint + oxfmt
|
|
164
|
+
|
|
165
|
+
For consistency with other `@tmjeee` projects you can add:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm install -D oxlint oxfmt
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Then add scripts:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
"lint": "oxlint",
|
|
175
|
+
"format": "oxfmt --check",
|
|
176
|
+
"format:fix": "oxfmt --write"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT © 2026 tmjeee
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Classic hello world sample for the w-lib skeleton.
|
|
4
|
+
*
|
|
5
|
+
* @returns The canonical greeting string
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { helloWorld } from '@tmjeee/w-lib';
|
|
10
|
+
*
|
|
11
|
+
* console.log(helloWorld()); // "Hello, world!"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare function helloWorld(): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { helloWorld };
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;AAYA;;;;;;;;;;;iBAAgB,UAAA,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Classic hello world sample for the w-lib skeleton.
|
|
4
|
+
*
|
|
5
|
+
* @returns The canonical greeting string
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { helloWorld } from '@tmjeee/w-lib';
|
|
10
|
+
*
|
|
11
|
+
* console.log(helloWorld()); // "Hello, world!"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function helloWorld() {
|
|
15
|
+
return "Hello, world!";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { helloWorld };
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Classic hello world sample for the w-lib skeleton.\n *\n * @returns The canonical greeting string\n *\n * @example\n * ```ts\n * import { helloWorld } from '@tmjeee/w-lib';\n *\n * console.log(helloWorld()); // \"Hello, world!\"\n * ```\n */\nexport function helloWorld(): string {\n return 'Hello, world!';\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,aAAqB;AACnC,QAAO"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tmjeee/w-lib",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A minimal, modern TypeScript library skeleton ready for publishing to npmjs.com. Includes helloWorld sample.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"library",
|
|
8
|
+
"npm",
|
|
9
|
+
"esm",
|
|
10
|
+
"hello-world",
|
|
11
|
+
"skeleton"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "tmjeee <tmjeee@gmail.com>",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/tmjeee/w-lib.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/tmjeee/w-lib/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/tmjeee/w-lib#readme",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"CHANGELOG.md"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.14.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"dev": "tsdown --watch",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"test:coverage": "vitest run --coverage",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
52
|
+
"publish:npm": "npm run build && npm run test && npm publish --access public",
|
|
53
|
+
"publish:npm:dry": "npm run build && npm run test && npm publish --access public --dry-run"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.15.0",
|
|
57
|
+
"tsdown": "^0.20.3",
|
|
58
|
+
"typescript": "^5.9.3",
|
|
59
|
+
"vitest": "^4.0.8"
|
|
60
|
+
}
|
|
61
|
+
}
|