@pikku/skills 0.12.12 → 0.12.13
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/package.json
CHANGED
|
@@ -6,18 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
8
|
my-addon/
|
|
9
|
-
├── package.json #
|
|
9
|
+
├── package.json # imports -> dist, exports -> dist
|
|
10
10
|
├── pikku.config.json # addon: true + metadata
|
|
11
|
-
├── tsconfig.json # #pikku path mapping
|
|
11
|
+
├── tsconfig.json # #pikku path mapping (source side)
|
|
12
12
|
├── src/
|
|
13
13
|
│ ├── services.ts # createSingletonServices (required)
|
|
14
14
|
│ └── functions/
|
|
15
15
|
│ └── *.function.ts # Function definitions
|
|
16
16
|
├── types/
|
|
17
17
|
│ └── application-types.d.ts # SingletonServices interface
|
|
18
|
-
└── .pikku/
|
|
18
|
+
└── .pikku/addon/ # Generated (gitignored)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
An addon's generated tree roots one level down, at `.pikku/addon/`, so its own
|
|
22
|
+
leaves are reached as `#pikku/addon/<leaf>` while an application's are
|
|
23
|
+
`#pikku/<leaf>`. `paths` are global to a tsx process rather than scoped to the
|
|
24
|
+
package that declared them, and the extra segment is what stops a linked addon's
|
|
25
|
+
`#pikku/function` from matching the *host application's* flat leaf.
|
|
26
|
+
|
|
21
27
|
## pikku.config.json
|
|
22
28
|
|
|
23
29
|
```json
|
|
@@ -34,30 +40,74 @@ my-addon/
|
|
|
34
40
|
}
|
|
35
41
|
```
|
|
36
42
|
|
|
43
|
+
`outDir` stays `./.pikku`; `addon: true` is what appends the `addon` segment.
|
|
44
|
+
|
|
37
45
|
## package.json (key fields)
|
|
38
46
|
|
|
39
47
|
```json
|
|
40
48
|
{
|
|
41
49
|
"name": "@my-org/addon-todos",
|
|
42
50
|
"imports": {
|
|
43
|
-
"#pikku/*.js": "
|
|
44
|
-
"#pikku/*": "
|
|
51
|
+
"#pikku/*.js": "./dist/.pikku/*.js",
|
|
52
|
+
"#pikku/*": ["./dist/.pikku/*/index.js", "./dist/.pikku/*"]
|
|
45
53
|
},
|
|
46
54
|
"exports": {
|
|
47
55
|
".": { "types": "./dist/src/index.d.ts", "import": "./dist/src/index.js" },
|
|
48
|
-
"./.pikku/*": "
|
|
49
|
-
"./.pikku/pikku-metadata.gen.json": "
|
|
56
|
+
"./.pikku/*": "./dist/.pikku/addon/*",
|
|
57
|
+
"./.pikku/pikku-metadata.gen.json": "./dist/.pikku/addon/pikku-metadata.gen.json",
|
|
50
58
|
"./.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js": {
|
|
51
|
-
"types": "
|
|
59
|
+
"types": "./dist/.pikku/addon/rpc/pikku-rpc-wirings-map.internal.gen.d.ts"
|
|
52
60
|
}
|
|
53
61
|
},
|
|
54
|
-
"files": ["dist"
|
|
62
|
+
"files": ["dist"],
|
|
55
63
|
"peerDependencies": {
|
|
56
|
-
"@pikku/core": "*"
|
|
64
|
+
"@pikku/core": "*",
|
|
65
|
+
"zod": "^4"
|
|
57
66
|
},
|
|
58
67
|
"scripts": {
|
|
68
|
+
"prebuild": "pikku all",
|
|
59
69
|
"pikku": "pikku all",
|
|
60
|
-
"build": "tsc && cp -r .pikku dist/"
|
|
70
|
+
"build": "tsc && cp -r .pikku types dist/"
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
```
|
|
74
|
+
|
|
75
|
+
**`imports` names `dist`, never the source tree.** `files: ["dist"]` is the whole
|
|
76
|
+
published package, and `build` copies `.pikku` and `types` into it — so a
|
|
77
|
+
`#pikku/*` target under `./.pikku/` resolves for the author and for nobody else.
|
|
78
|
+
It is a silent break: the addon compiles, packs, installs and then throws
|
|
79
|
+
`Cannot find module '.../.pikku/addon/function/index.ts'` on first import in the
|
|
80
|
+
consuming app, out of a file the consumer never wrote. The addon's own build
|
|
81
|
+
does not read `imports` at all — tsconfig `paths` covers it, which is why the
|
|
82
|
+
two maps point at different trees.
|
|
83
|
+
|
|
84
|
+
**`exports` targets carry the `addon` segment; the subpaths do not.** A consumer
|
|
85
|
+
writes `@my-org/addon-todos/.pikku/rpc/...`, exactly as it would in an
|
|
86
|
+
application, and the leaf stays the package's own business.
|
|
87
|
+
|
|
88
|
+
## tsconfig.json (key fields)
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"compilerOptions": {
|
|
93
|
+
"module": "NodeNext",
|
|
94
|
+
"moduleResolution": "NodeNext",
|
|
95
|
+
"rootDir": ".",
|
|
96
|
+
"outDir": "./dist",
|
|
97
|
+
"paths": {
|
|
98
|
+
"#pikku/*.js": ["./.pikku/*.ts"],
|
|
99
|
+
"#pikku/*": ["./.pikku/*/index.ts", "./.pikku/*"]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"include": ["src/**/*", "types/**/*", ".pikku/**/*.ts"],
|
|
103
|
+
"exclude": ["node_modules", "dist", ".pikku/**/*.d.ts"]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`paths` resolves the source tree because `dist` does not exist yet on the build
|
|
108
|
+
that creates it. Both patterns are needed: the `.js` one reaches a generated
|
|
109
|
+
file (`#pikku/addon/variables/pikku-variables.gen.js`), the bare one reaches a
|
|
110
|
+
leaf's barrel (`#pikku/addon/function`). Keep the `.js` pattern first: both keys
|
|
111
|
+
share the `#pikku/` prefix, and TypeScript takes the first match of the longest
|
|
112
|
+
prefix rather than the most specific pattern. Node sorts by specificity and does
|
|
113
|
+
not care about the order.
|