Commit ab8563f
authored
refactor: unify all packages to rootDir "." pattern (#241)
* docs: unify all packages to use rootDir "." pattern
Replace CLI vs Library distinction with unified TypeScript configuration:
- ALL packages now use rootDir "." (not "src")
- Consistent output: dist/{esm,cjs}/src/ for all packages
- Prevents configuration errors when adding bin executables
- Simplifies documentation and reduces maintenance burden
This change documents the standard pattern going forward.
Existing packages will be migrated incrementally.
Rationale: Previous two-pattern approach required updating 6+ fields
when converting library to CLI package, leading to errors. Unified
approach makes wrong configuration impossible and future-proofs all
packages for potential bin field addition.
* docs: fix CONTRIBUTING.md tsconfig example to use rootDir "."
Update quick start example to align with unified package structure.
All packages must use rootDir "." for consistency.
* fix(emulator): correct CLI bin file to use TypeScript source
- Convert bin/ya-modbus-emulator.js to .ts (TypeScript source)
- Update package.json bin to point to compiled version: ./dist/esm/bin/ya-modbus-emulator.js
- Update tsconfig.esm.json: rootDir "src" → ".", include ["src"] → ["src", "bin"]
- Update tsconfig.cjs.json: rootDir "src" → ".", include ["src"] → ["src", "bin"]
- Fix import path in bin file to use ../src/cli.js (compiled structure)
This follows the same pattern as @ya-modbus/cli package.
The bin file is now compiled with the rest of the TypeScript code,
ensuring it works correctly when the package is installed via npm.
Verified: npx ya-modbus-emulator --help works both in monorepo and when installed
* fix(emulator): complete migration to unified rootDir "." pattern
Update package.json exports to match new tsconfig structure:
- main: ./dist/cjs/src/index.js (was ./dist/cjs/index.js)
- module: ./dist/esm/src/index.js (was ./dist/esm/index.js)
- types: ./dist/esm/src/index.d.ts (was ./dist/esm/index.d.ts)
- exports: all paths updated to include /src/ subdirectory
- files: remove "bin" entry (now compiled to dist/)
This completes the emulator migration started in commit 3c1f920.
The package now follows the unified structure documented in
docs/agents/package-creation.md.
Verified: npx ya-modbus-emulator --help works correctly
* refactor(driver-types): migrate to unified rootDir "." pattern
Update TypeScript and package.json configuration:
- tsconfig: rootDir "src" → "."
- package.json: all paths updated to dist/{esm,cjs}/src/
Part of monorepo-wide migration to unified package structure.
* refactor(driver-sdk): migrate to unified rootDir "." pattern
* refactor(transport): migrate to unified rootDir "." pattern
* refactor(driver-loader): migrate to unified rootDir "." pattern
* refactor(driver-xymd1): migrate to unified rootDir "." pattern
* refactor(driver-or-we-516): migrate to unified rootDir "." pattern
* refactor(driver-ex9em): migrate to unified rootDir "." pattern
* fix(driver-loader): correct testing export path for unified structure
The testing subpath export was pointing to dist/esm/testing/ but with
rootDir "." the actual location is dist/esm/src/testing/.
Updated exports:
- ./dist/esm/testing/index.js → ./dist/esm/src/testing/index.js
- ./dist/cjs/testing/index.js → ./dist/cjs/src/testing/index.js
This fixes module resolution for consumers importing from
@ya-modbus/driver-loader/testing.1 parent afbbd62 commit ab8563f
28 files changed
Lines changed: 108 additions & 96 deletions
File tree
- docs
- agents
- packages
- driver-ex9em
- driver-loader
- driver-or-we-516
- driver-sdk
- driver-types
- driver-xymd1
- emulator
- bin
- transport
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | | - | |
| 607 | + | |
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
40 | 38 | | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 44 | + | |
48 | 45 | | |
49 | | - | |
50 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments