@olegkuibar/plunk 0.7.2 → 0.7.3-canary.5e852ba

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/dist/cli.mjs CHANGED
@@ -8,4 +8,4 @@ var o=c(a$1(),1);var r=`
8
8
  \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557
9
9
  \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
10
10
  `;function a(){console.log(o.default.yellow(r)),console.log(o.default.cyan(" \u{1F4E6} Local npm package development without symlinks")),console.log(o.default.dim(` Copies built files into consumer node_modules with incremental sync
11
- `));}a$2(a,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var d=process.argv.slice(2),p=d.some(e=>!e.startsWith("-")&&["init","publish","add","remove","push","dev","restore","list","status","update","clean","gc","doctor","migrate"].includes(e));p||a();var u={meta:{name:"plunk",version:"0.7.2",description:"Local npm package development \u2014 copies built files into consumer node_modules"},args:{verbose:{type:"boolean",alias:"v",description:"Enable verbose debug logging",default:false},"dry-run":{type:"boolean",description:"Preview changes without writing files",default:false},json:{type:"boolean",description:"Output machine-readable JSON",default:false}},subCommands:{init:a$2(()=>import('./init-C6XCSFCU.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-6A7PX5IH.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-GYBX4VAZ.mjs').then(e=>e.default),"add"),remove:a$2(()=>import('./remove-5DAQD627.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-AM6JDGUN.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-QMDH32K7.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-JVH6INAG.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-QSPN7FE5.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-22YV26A3.mjs').then(e=>e.default),"status"),update:a$2(()=>import('./update-33ICRFYZ.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-GJGAAT6J.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-4TFDXO4G.mjs').then(e=>e.default),"migrate")}};a$4(u);
11
+ `));}a$2(a,"showBanner");process.env.UV_THREADPOOL_SIZE??=String(Math.max(availableParallelism(),8));a$3();var d=process.argv.slice(2),p=d.some(e=>!e.startsWith("-")&&["init","publish","add","remove","push","dev","restore","list","status","update","clean","gc","doctor","migrate"].includes(e));p||a();var u={meta:{name:"plunk",version:"0.7.3-canary.5e852ba",description:"Local npm package development \u2014 copies built files into consumer node_modules"},args:{verbose:{type:"boolean",alias:"v",description:"Enable verbose debug logging",default:false},"dry-run":{type:"boolean",description:"Preview changes without writing files",default:false},json:{type:"boolean",description:"Output machine-readable JSON",default:false}},subCommands:{init:a$2(()=>import('./init-C6XCSFCU.mjs').then(e=>e.default),"init"),publish:a$2(()=>import('./publish-6A7PX5IH.mjs').then(e=>e.default),"publish"),add:a$2(()=>import('./add-GYBX4VAZ.mjs').then(e=>e.default),"add"),remove:a$2(()=>import('./remove-5DAQD627.mjs').then(e=>e.default),"remove"),push:a$2(()=>import('./push-AM6JDGUN.mjs').then(e=>e.default),"push"),dev:a$2(()=>import('./dev-QMDH32K7.mjs').then(e=>e.default),"dev"),restore:a$2(()=>import('./restore-JVH6INAG.mjs').then(e=>e.default),"restore"),list:a$2(()=>import('./list-QSPN7FE5.mjs').then(e=>e.default),"list"),status:a$2(()=>import('./status-22YV26A3.mjs').then(e=>e.default),"status"),update:a$2(()=>import('./update-33ICRFYZ.mjs').then(e=>e.default),"update"),clean:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"clean"),gc:a$2(()=>import('./clean-F2IWAVRP.mjs').then(e=>e.default),"gc"),doctor:a$2(()=>import('./doctor-GJGAAT6J.mjs').then(e=>e.default),"doctor"),migrate:a$2(()=>import('./migrate-4TFDXO4G.mjs').then(e=>e.default),"migrate")}};a$4(u);
@@ -1,6 +1,6 @@
1
1
  // src/vite-plugin.ts
2
2
  import { join, normalize } from "path";
3
- import { readFileSync, existsSync, rmSync } from "fs";
3
+ import { readFileSync } from "fs";
4
4
  function readLinkedPackagesSync(stateFile) {
5
5
  try {
6
6
  const content = readFileSync(stateFile, "utf-8");
@@ -12,8 +12,6 @@ function readLinkedPackagesSync(stateFile) {
12
12
  }
13
13
  function plunkPlugin() {
14
14
  let plunkStateFile;
15
- let rootDir;
16
- let cacheDir;
17
15
  let nodeModulesDir;
18
16
  let pollTimer;
19
17
  return {
@@ -47,8 +45,6 @@ function plunkPlugin() {
47
45
  return result;
48
46
  },
49
47
  configResolved(config) {
50
- rootDir = config.root;
51
- cacheDir = config.cacheDir;
52
48
  nodeModulesDir = join(config.root, "node_modules");
53
49
  plunkStateFile = normalize(join(config.root, ".plunk", "state.json"));
54
50
  console.log(`[plunk] Watching state file: ${plunkStateFile}`);
@@ -84,7 +80,7 @@ function plunkPlugin() {
84
80
  }
85
81
  }
86
82
  }
87
- async function clearCacheAndRestart(source) {
83
+ async function restartServer(source) {
88
84
  if (isRestarting) {
89
85
  pendingRestart = true;
90
86
  console.log(`[plunk] Restart already in progress, queued: ${source}`);
@@ -97,21 +93,13 @@ function plunkPlugin() {
97
93
  `[plunk] ${source}, restarting server...`,
98
94
  { timestamp: true }
99
95
  );
100
- try {
101
- if (existsSync(cacheDir)) {
102
- rmSync(cacheDir, { recursive: true, force: true });
103
- console.log(`[plunk] Cleared cache: ${cacheDir}`);
104
- }
105
- } catch (err) {
106
- console.error(`[plunk] Failed to clear cache:`, err);
107
- }
108
96
  try {
109
97
  await server.restart();
110
98
  } finally {
111
99
  isRestarting = false;
112
100
  if (pendingRestart) {
113
101
  pendingRestart = false;
114
- await clearCacheAndRestart("Queued change detected");
102
+ await restartServer("Queued change detected");
115
103
  }
116
104
  }
117
105
  }
@@ -119,22 +107,37 @@ function plunkPlugin() {
119
107
  if (debounceTimer) clearTimeout(debounceTimer);
120
108
  debounceTimer = setTimeout(() => {
121
109
  debounceTimer = null;
122
- clearCacheAndRestart(source);
123
- }, 100);
110
+ restartServer(source);
111
+ }, 1500);
124
112
  }
125
113
  server.watcher.add(plunkStateFile);
126
114
  console.log(`[plunk] Added watcher for: ${plunkStateFile}`);
127
115
  syncPackageWatchers();
128
116
  server.watcher.on("change", async (changedPath) => {
129
117
  const normalizedChanged = normalize(changedPath);
130
- if (normalizedChanged !== plunkStateFile) return;
131
- const currentPackages = readLinkedPackagesSync(plunkStateFile);
132
- const hasNew = currentPackages.some((pkg) => !watchedPackages.has(pkg));
133
- if (!hasNew) {
134
- console.log("[plunk] state.json changed but no new packages, skipping restart");
118
+ if (normalizedChanged === plunkStateFile) {
119
+ const currentPackages = readLinkedPackagesSync(plunkStateFile);
120
+ const hasNew = currentPackages.some((pkg) => !watchedPackages.has(pkg));
121
+ scheduleRestart(
122
+ hasNew ? "New package linked" : "Package files updated"
123
+ );
135
124
  return;
136
125
  }
137
- scheduleRestart("New package linked");
126
+ const isLinkedPackage = [...watchedPackages].some(
127
+ (pkg) => normalizedChanged.includes(normalize(join(nodeModulesDir, pkg)))
128
+ );
129
+ if (isLinkedPackage) {
130
+ scheduleRestart("Linked package file changed");
131
+ }
132
+ });
133
+ server.watcher.on("add", (addedPath) => {
134
+ const normalizedAdded = normalize(addedPath);
135
+ const isLinkedPackage = [...watchedPackages].some(
136
+ (pkg) => normalizedAdded.includes(normalize(join(nodeModulesDir, pkg)))
137
+ );
138
+ if (isLinkedPackage) {
139
+ scheduleRestart("New file in linked package");
140
+ }
138
141
  });
139
142
  if (process.versions?.webcontainer) {
140
143
  if (pollTimer) clearInterval(pollTimer);
@@ -152,9 +155,9 @@ function plunkPlugin() {
152
155
  const hasNew = currentPackages.some(
153
156
  (pkg) => !watchedPackages.has(pkg)
154
157
  );
155
- if (hasNew) {
156
- scheduleRestart("New package linked (polling fallback)");
157
- }
158
+ scheduleRestart(
159
+ hasNew ? "New package linked (polling fallback)" : "Package files updated (polling fallback)"
160
+ );
158
161
  }
159
162
  if (!lastStateContent) lastStateContent = content;
160
163
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olegkuibar/plunk",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-canary.5e852ba",
4
4
  "description": "Local npm package development without symlinks. Copies built files into consumer node_modules with incremental sync and watch mode.",
5
5
  "type": "module",
6
6
  "bin": {