@reflex-stack/tsp-bun-example 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexis Bouhet
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,32 @@
1
+ # TSP Example Bun
2
+
3
+ ## This is a test package for @reflex-stack/tsp, do not use it
4
+
5
+ Main bundle is <bundle-size id="main">45b</bundle-size>
6
+ and optional submodule is only <bundle-size id="submodule">75b</bundle-size>
7
+ For a total of <bundle-size id="total">120b</bundle-size>
8
+
9
+ ## Install
10
+
11
+ `bun i @zouloux/test-package-2`
12
+
13
+ ## Usage
14
+
15
+ ##### Main module
16
+ - `import { ... } from "@zouloux/test-package-2"`
17
+
18
+ ##### Sub module
19
+ - `import { ... } from "@zouloux/test-package-2/submodule"`
20
+
21
+ ## Build commands
22
+
23
+ ##### Build
24
+ - `bun run build`
25
+ ##### Test
26
+ - `bun run test`
27
+ ##### Publish
28
+ - `bun run publish`
29
+
30
+ ---
31
+ ## TSP
32
+ This package has been created with [tsp](https://github.com/reflex-stack/tsp)
@@ -0,0 +1 @@
1
+ export declare function randomFunction(): number;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Root index file, export elements here
2
+ // Import nothing from submodule to keep things separated
3
+ export function randomFunction() {
4
+ return 5;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function subRandomFunction(): number;
@@ -0,0 +1,7 @@
1
+ // Sub-module index file, export elements here
2
+ // You can import elements from root
3
+ // Always import with the js extension, event in ts files
4
+ import { randomFunction } from "../index.js";
5
+ export function subRandomFunction() {
6
+ return randomFunction() * 12;
7
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@reflex-stack/tsp-bun-example",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "author": "Neo",
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./submodule": {
15
+ "types": "./dist/submodule/index.d.ts",
16
+ "default": "./dist/submodule/index.js"
17
+ }
18
+ },
19
+ "tsp": {
20
+ "runtime": "bun",
21
+ "src": "./src",
22
+ "dist": "./dist",
23
+ "tests": "./tests",
24
+ "test-files": [
25
+ "test.ts"
26
+ ],
27
+ "tmp": "./tmp",
28
+ "generate-json-report": false
29
+ },
30
+ "scripts": {
31
+ "build": "tsp build",
32
+ "test": "tsp build --noSizeReport && tsp test --noIntro",
33
+ "publish": "tsp build && tsp test --noIntro && tsp publish --noIntro"
34
+ },
35
+ "dependencies": {
36
+ "@reflex-stack/tsp": "0.2.0",
37
+ "terser": "^5.46.1",
38
+ "typescript": "^6.0.2"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git@github.com:reflex-stack/tsp.git",
43
+ "directory": "tests/test-package-bun"
44
+ }
45
+ }
package/tests/test.ts ADDED
@@ -0,0 +1,27 @@
1
+ // If you have no tests, uncomment this
2
+ // console.log("No test implemented.")
3
+ // process.exit(0)
4
+
5
+ // Import your code directly from src directory thanks to bun
6
+ import { randomFunction } from "../src/index.js"
7
+ import { subRandomFunction } from "../src/submodule/index.js"
8
+ // Import Bun testing lib
9
+ import { describe, test, expect } from "bun:test"
10
+
11
+ describe("Main module", () => {
12
+ test("Should call random", () => {
13
+ const rootResult = randomFunction()
14
+ expect(rootResult).toBe(5)
15
+ })
16
+ })
17
+
18
+ describe("Sub module", () => {
19
+ test("Should call sub random", () => {
20
+ const subResult = subRandomFunction()
21
+ expect(subResult).toBe(60)
22
+ })
23
+ // Test error example
24
+ // test("Should fail", () => {
25
+ // expect(5).toBe(12)
26
+ // })
27
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Compilation level target
4
+ // If using a bundler in your project it should be the previous or current year
5
+ "target" : "es2024",
6
+ // Allow types to be resolved in tests
7
+ "checkJs": true,
8
+ "allowJs": true,
9
+ // TS libs used, include needed lib.
10
+ // It should contain the target and "DOM" if it runs in the browser
11
+ // https://www.typescriptlang.org/tsconfig/#lib
12
+ "lib": ["es2024"],
13
+ // Module config, you should not change it
14
+ "module": "NodeNext",
15
+ "isolatedModules": false,
16
+ "allowImportingTsExtensions": false,
17
+ // Compiler config
18
+ "strict": true,
19
+ "useDefineForClassFields" : true,
20
+ "allowSyntheticDefaultImports": true,
21
+ // ---
22
+ // Feel free to configure this file for your needs
23
+ // https://www.typescriptlang.org/tsconfig/
24
+ // ---
25
+ // Forbidden props are :
26
+ // - rootDir
27
+ // - outDir
28
+ // - declaration
29
+ // - noEmitOnError
30
+ // - pretty
31
+ },
32
+ // Compile only from src, avoid looping in dist
33
+ "exclude": ["node_modules", "dist"],
34
+ "include": ["src/**/*"],
35
+ }