@olegkuibar/plunk 0.2.0-canary.04ff96f

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/add-5ZRFUL6Z.mjs +258 -0
  4. package/dist/chokidar-XGAEDN45.mjs +1746 -0
  5. package/dist/chunk-34UXZ622.mjs +98 -0
  6. package/dist/chunk-4O2QOKVO.mjs +1958 -0
  7. package/dist/chunk-CSMZ6DZA.mjs +367 -0
  8. package/dist/chunk-CZM4TNAI.mjs +292 -0
  9. package/dist/chunk-EDUXIQ5W.mjs +1729 -0
  10. package/dist/chunk-GAAB2TLH.mjs +160 -0
  11. package/dist/chunk-HKNM3UWU.mjs +496 -0
  12. package/dist/chunk-I6SN7BBN.mjs +1131 -0
  13. package/dist/chunk-KYDBD2KQ.mjs +39 -0
  14. package/dist/chunk-LKQINKH4.mjs +130 -0
  15. package/dist/chunk-PUSXMPOF.mjs +82 -0
  16. package/dist/chunk-S4HJSJ32.mjs +69 -0
  17. package/dist/chunk-W3C72UKC.mjs +113 -0
  18. package/dist/chunk-WSECI6M7.mjs +85 -0
  19. package/dist/chunk-XMIZ7OUZ.mjs +26 -0
  20. package/dist/chunk-XZK5T4GK.mjs +23 -0
  21. package/dist/chunk-ZOYNYK5Y.mjs +23 -0
  22. package/dist/chunk-ZQCGJUBJ.mjs +92 -0
  23. package/dist/clean-LTR5MZTY.mjs +84 -0
  24. package/dist/cli.mjs +57 -0
  25. package/dist/dev-LFXQP6SA.mjs +194 -0
  26. package/dist/dist-DUFCZSIL.mjs +813 -0
  27. package/dist/doctor-R7ZVR7PY.mjs +230 -0
  28. package/dist/hash-worker.mjs +65 -0
  29. package/dist/index.d.ts +194 -0
  30. package/dist/index.mjs +9486 -0
  31. package/dist/init-SWCNRISY.mjs +310 -0
  32. package/dist/list-B77L2F34.mjs +119 -0
  33. package/dist/migrate-X5TIC5SS.mjs +124 -0
  34. package/dist/prompt-HTPH6HQ7.mjs +756 -0
  35. package/dist/publish-UXCLPNM6.mjs +63 -0
  36. package/dist/push-JI6HGCFG.mjs +197 -0
  37. package/dist/remove-DCR7KKD5.mjs +149 -0
  38. package/dist/restore-SUN3WGSW.mjs +124 -0
  39. package/dist/status-MESRBH54.mjs +103 -0
  40. package/dist/tailwind-source-JBBEIXIJ.mjs +89 -0
  41. package/dist/update-SKDSA673.mjs +100 -0
  42. package/dist/vite-config-BAK67JHB.mjs +128 -0
  43. package/dist/vite-plugin.d.ts +5 -0
  44. package/dist/vite-plugin.mjs +42 -0
  45. package/dist/workspace-76HJPAK2.mjs +97 -0
  46. package/package.json +96 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 plunk contributors
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,95 @@
1
+ <p align="center">
2
+ <img src="plunk_logo.png" width="200" alt="plunk logo" />
3
+ </p>
4
+
5
+ # plunk
6
+
7
+ Modern local package development tool. Smart file copying into `node_modules` — no symlinks, no git contamination.
8
+
9
+ ```bash
10
+ npx plunk init # set up your app
11
+ plunk add my-lib # link a package
12
+ plunk push --watch # continuous dev mode
13
+ ```
14
+
15
+ ## Why not symlinks?
16
+
17
+ `npm link` creates symlinks that break module resolution: duplicate React instances, peer dep mismatches, bundlers that can't follow links outside the project root. `yalc` improves on this but [still has issues](https://github.com/wclr/yalc/issues) with pnpm, git contamination, and watch mode.
18
+
19
+ **plunk** just copies built files directly into `node_modules/`. It works.
20
+
21
+ ## How it works
22
+
23
+ ```mermaid
24
+ graph LR
25
+ A["my-lib/"] -- "plunk publish" --> B["~/.plunk/store/<br/>my-lib@1.0.0"]
26
+ B -- "plunk add" --> C["app/node_modules/<br/>my-lib/"]
27
+ B -- "plunk push" --> D["app-2/node_modules/<br/>my-lib/"]
28
+
29
+ style A fill:#2e7d32,stroke:#66bb6a,color:#e8f5e9
30
+ style B fill:#1565c0,stroke:#64b5f6,color:#e3f2fd
31
+ style C fill:#e65100,stroke:#ffb74d,color:#fff3e0
32
+ style D fill:#e65100,stroke:#ffb74d,color:#fff3e0
33
+ ```
34
+
35
+ 1. `publish` copies built files to a local store at `~/.plunk/store/`
36
+ 2. `add` copies from store into your app's `node_modules/`
37
+ 3. `push` = publish + copy to all consumers
38
+ 4. `--watch` = file change → build → push loop
39
+
40
+ > Uses CoW reflinks for instant copy-on-write on APFS/btrfs/ReFS, with automatic fallback. Reflink support is probed once per volume and cached — no wasted syscalls. Only changed files are re-copied (xxhash-based diffing).
41
+
42
+ ## Quick start
43
+
44
+ ```bash
45
+ # In your app — one-time setup
46
+ cd my-app
47
+ npx plunk init
48
+
49
+ # In your library — build and publish to plunk store
50
+ cd my-lib
51
+ pnpm build
52
+ plunk publish
53
+
54
+ # Back in your app — link the library
55
+ cd my-app
56
+ plunk add my-lib
57
+
58
+ # Continuous dev: watch → build → push
59
+ cd my-lib
60
+ plunk push --watch --build "pnpm build"
61
+ ```
62
+
63
+ ## At a glance
64
+
65
+ | | npm link | yalc | plunk |
66
+ |---|---|---|---|
67
+ | Module resolution | Broken (dual instances) | Works | Works |
68
+ | Git contamination | None | package.json + .yalc/ | None |
69
+ | Bundler HMR | Often broken | Fragile | Works |
70
+ | pnpm support | Fragile | Broken since v7.10 | Works |
71
+ | Watch mode | None | External | Built-in |
72
+ | Survives `npm install` | No | No | `plunk restore` |
73
+
74
+ ## Install
75
+
76
+ ```bash
77
+ pnpm add -g plunk # or npm, yarn, bun
78
+ npx plunk init # set up a consumer project
79
+ ```
80
+
81
+ ## Documentation
82
+
83
+ | | |
84
+ |---|---|
85
+ | [Getting Started](docs/getting-started.md) | Install, first publish/add cycle, watch mode |
86
+ | [Commands](docs/commands.md) | Every command, every flag |
87
+ | [How It Works](docs/how-it-works.md) | Store format, injection, CoW copies |
88
+ | [Bundler Guide](docs/bundlers.md) | Vite, Webpack, esbuild, Turbopack setup |
89
+ | [Comparison](docs/comparison.md) | npm link vs yalc vs plunk |
90
+ | [Examples](examples/) | Try it yourself with real packages |
91
+ | [Contributing](CONTRIBUTING.md) | Dev setup and guidelines |
92
+
93
+ ## License
94
+
95
+ [MIT](LICENSE)
@@ -0,0 +1,258 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
+ import {
4
+ addToTranspilePackages
5
+ } from "./chunk-WSECI6M7.mjs";
6
+ import {
7
+ backupExisting,
8
+ checkMissingDeps,
9
+ inject
10
+ } from "./chunk-CZM4TNAI.mjs";
11
+ import {
12
+ ensureConsumerInit
13
+ } from "./chunk-ZQCGJUBJ.mjs";
14
+ import {
15
+ detectBundler,
16
+ detectPackageManager,
17
+ detectYarnNodeLinker,
18
+ hasYarnrcYml
19
+ } from "./chunk-34UXZ622.mjs";
20
+ import {
21
+ addLink,
22
+ registerConsumer
23
+ } from "./chunk-GAAB2TLH.mjs";
24
+ import {
25
+ publish
26
+ } from "./chunk-4O2QOKVO.mjs";
27
+ import {
28
+ errorWithSuggestion
29
+ } from "./chunk-S4HJSJ32.mjs";
30
+ import {
31
+ findStoreEntry
32
+ } from "./chunk-W3C72UKC.mjs";
33
+ import {
34
+ Timer
35
+ } from "./chunk-XZK5T4GK.mjs";
36
+ import "./chunk-PUSXMPOF.mjs";
37
+ import {
38
+ getConsumerStatePath
39
+ } from "./chunk-EDUXIQ5W.mjs";
40
+ import {
41
+ output,
42
+ suppressHumanOutput
43
+ } from "./chunk-ZOYNYK5Y.mjs";
44
+ import {
45
+ defineCommand
46
+ } from "./chunk-CSMZ6DZA.mjs";
47
+ import {
48
+ exists
49
+ } from "./chunk-HKNM3UWU.mjs";
50
+ import {
51
+ consola,
52
+ isJsonOutput,
53
+ verbose
54
+ } from "./chunk-I6SN7BBN.mjs";
55
+ import "./chunk-KYDBD2KQ.mjs";
56
+
57
+ // src/commands/add.ts
58
+ import { spawn } from "child_process";
59
+ import { platform } from "os";
60
+ import { resolve, basename } from "path";
61
+ var add_default = defineCommand({
62
+ meta: {
63
+ name: "add",
64
+ description: "Link a package from the plunk store into this project"
65
+ },
66
+ args: {
67
+ package: {
68
+ type: "positional",
69
+ description: "Package name to add",
70
+ required: true
71
+ },
72
+ from: {
73
+ type: "string",
74
+ description: "Path to package source (will publish first)"
75
+ },
76
+ yes: {
77
+ type: "boolean",
78
+ alias: "y",
79
+ description: "Auto-accept prompts (install missing deps, etc.)",
80
+ default: false
81
+ }
82
+ },
83
+ async run({ args }) {
84
+ suppressHumanOutput();
85
+ const timer = new Timer();
86
+ const consumerPath = resolve(".");
87
+ const packageName = args.package;
88
+ if (args.from) {
89
+ const fromPath = resolve(args.from);
90
+ consola.info(`Publishing from ${fromPath}...`);
91
+ await publish(fromPath);
92
+ }
93
+ const entry = await findStoreEntry(packageName);
94
+ if (!entry) {
95
+ errorWithSuggestion(
96
+ `Package "${packageName}" not found in store. Run 'plunk publish' in the package directory first, or use --from <path>.`
97
+ );
98
+ process.exit(1);
99
+ }
100
+ const needsInit = !await exists(getConsumerStatePath(consumerPath));
101
+ const pm = await detectPackageManager(consumerPath);
102
+ if (needsInit) {
103
+ await ensureConsumerInit(consumerPath, pm);
104
+ consola.success("Auto-initialized plunk (consumer mode)");
105
+ }
106
+ verbose(`[add] Detected package manager: ${pm}`);
107
+ consola.info(`Detected package manager: ${pm}`);
108
+ if (pm === "yarn") {
109
+ const linker = await detectYarnNodeLinker(consumerPath);
110
+ if (linker === "pnp" || linker === null && await hasYarnrcYml(consumerPath)) {
111
+ consola.error(
112
+ `Yarn PnP mode is not compatible with plunk.
113
+
114
+ plunk works by copying files into node_modules/, but PnP eliminates
115
+ node_modules/ entirely. To use plunk with Yarn Berry, add this to
116
+ .yarnrc.yml:
117
+
118
+ nodeLinker: node-modules
119
+
120
+ Then run: yarn install`
121
+ );
122
+ process.exit(1);
123
+ }
124
+ }
125
+ const hasBackup = await backupExisting(consumerPath, packageName, pm);
126
+ if (hasBackup) {
127
+ consola.info(`Backed up existing ${packageName} installation`);
128
+ }
129
+ const result = await inject(entry, consumerPath, pm);
130
+ consola.success(
131
+ `Linked ${packageName}@${entry.version} \u2192 node_modules/${packageName} (${result.copied} files copied, ${result.skipped} unchanged)`
132
+ );
133
+ if (result.binLinks > 0) {
134
+ consola.info(`Created ${result.binLinks} bin link(s)`);
135
+ }
136
+ const linkEntry = {
137
+ version: entry.version,
138
+ contentHash: entry.meta.contentHash,
139
+ linkedAt: (/* @__PURE__ */ new Date()).toISOString(),
140
+ sourcePath: entry.meta.sourcePath,
141
+ backupExists: hasBackup,
142
+ packageManager: pm,
143
+ buildId: entry.meta.buildId ?? ""
144
+ };
145
+ await addLink(consumerPath, packageName, linkEntry);
146
+ await registerConsumer(packageName, consumerPath);
147
+ const missing = await checkMissingDeps(entry, consumerPath);
148
+ if (missing.length > 0) {
149
+ if (isJsonOutput()) {
150
+ verbose(`[add] Missing transitive deps (json mode): ${missing.join(", ")}`);
151
+ } else if (args.yes) {
152
+ const cmd = buildInstallCommand(pm, missing);
153
+ consola.info(`Installing missing dependencies: ${missing.join(", ")}`);
154
+ const ok = await runInstallCommand(cmd, consumerPath);
155
+ if (ok) {
156
+ consola.success("Installed missing dependencies");
157
+ } else {
158
+ consola.warn(`Install failed. Run manually: ${cmd}`);
159
+ }
160
+ } else {
161
+ const confirm = await consola.prompt(
162
+ `Install ${missing.length} missing dependencies? (${missing.join(", ")})`,
163
+ { type: "confirm", initial: true }
164
+ );
165
+ if (confirm) {
166
+ const cmd = buildInstallCommand(pm, missing);
167
+ const ok = await runInstallCommand(cmd, consumerPath);
168
+ if (ok) {
169
+ consola.success("Installed missing dependencies");
170
+ } else {
171
+ consola.warn(`Install failed. Run manually: ${cmd}`);
172
+ }
173
+ } else {
174
+ consola.warn(
175
+ `Missing transitive dependencies: ${missing.join(", ")}
176
+ Run: ${buildInstallCommand(pm, missing)}`
177
+ );
178
+ }
179
+ }
180
+ }
181
+ const bundler = await detectBundler(consumerPath);
182
+ if (bundler.type === "next" && bundler.configFile) {
183
+ const configResult = await addToTranspilePackages(
184
+ bundler.configFile,
185
+ packageName
186
+ );
187
+ if (configResult.modified) {
188
+ consola.success(
189
+ `Added ${packageName} to transpilePackages in ${basename(bundler.configFile)}`
190
+ );
191
+ } else if (configResult.error) {
192
+ consola.info(
193
+ `Add to next.config manually: transpilePackages: ['${packageName}']`
194
+ );
195
+ }
196
+ } else if (bundler.type === "vite" && bundler.configFile) {
197
+ const { addPlunkVitePlugin } = await import("./vite-config-BAK67JHB.mjs");
198
+ const viteResult = await addPlunkVitePlugin(bundler.configFile);
199
+ if (viteResult.modified) {
200
+ consola.success(`Added plunk plugin to ${basename(bundler.configFile)}`);
201
+ } else if (viteResult.error) {
202
+ consola.info(
203
+ `Add manually:
204
+ import plunk from "@olegkuibar/plunk/vite"
205
+ plugins: [plunk()]`
206
+ );
207
+ }
208
+ }
209
+ const { findTailwindCss, addTailwindSource } = await import("./tailwind-source-JBBEIXIJ.mjs");
210
+ const tailwindCss = await findTailwindCss(consumerPath);
211
+ if (tailwindCss) {
212
+ const twResult = await addTailwindSource(tailwindCss, packageName, consumerPath);
213
+ if (twResult.modified) {
214
+ consola.success(`Added @source for ${packageName} to ${basename(tailwindCss)}`);
215
+ } else if (twResult.error) {
216
+ consola.info(`Add to your CSS manually: @source "../node_modules/${packageName}";`);
217
+ }
218
+ }
219
+ consola.info(`Done in ${timer.elapsed()}`);
220
+ output({
221
+ package: packageName,
222
+ version: entry.version,
223
+ copied: result.copied,
224
+ skipped: result.skipped,
225
+ binLinks: result.binLinks,
226
+ elapsed: timer.elapsedMs()
227
+ });
228
+ }
229
+ });
230
+ function buildInstallCommand(pm, deps) {
231
+ const joined = deps.join(" ");
232
+ switch (pm) {
233
+ case "pnpm":
234
+ return `pnpm add ${joined}`;
235
+ case "yarn":
236
+ return `yarn add ${joined}`;
237
+ case "bun":
238
+ return `bun add ${joined}`;
239
+ default:
240
+ return `npm install ${joined}`;
241
+ }
242
+ }
243
+ function runInstallCommand(cmd, cwd) {
244
+ return new Promise((resolve2) => {
245
+ const isWin = platform() === "win32";
246
+ const shell = isWin ? "cmd" : "sh";
247
+ const shellFlag = isWin ? "/c" : "-c";
248
+ const child = spawn(shell, [shellFlag, cmd], {
249
+ cwd,
250
+ stdio: "inherit"
251
+ });
252
+ child.on("close", (code) => resolve2(code === 0));
253
+ child.on("error", () => resolve2(false));
254
+ });
255
+ }
256
+ export {
257
+ add_default as default
258
+ };