@olegkuibar/plunk 0.7.2 → 0.7.3-canary.c736659

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.c736659",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,7 +107,7 @@ function plunkPlugin() {
119
107
  if (debounceTimer) clearTimeout(debounceTimer);
120
108
  debounceTimer = setTimeout(() => {
121
109
  debounceTimer = null;
122
- clearCacheAndRestart(source);
110
+ restartServer(source);
123
111
  }, 100);
124
112
  }
125
113
  server.watcher.add(plunkStateFile);
@@ -127,14 +115,22 @@ function plunkPlugin() {
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
+ if (!hasNew) {
122
+ console.log("[plunk] state.json changed but no new packages, skipping restart");
123
+ return;
124
+ }
125
+ scheduleRestart("New package linked");
135
126
  return;
136
127
  }
137
- scheduleRestart("New package linked");
128
+ const isLinkedPackage = [...watchedPackages].some(
129
+ (pkg) => normalizedChanged.includes(normalize(join(nodeModulesDir, pkg)))
130
+ );
131
+ if (isLinkedPackage) {
132
+ scheduleRestart("Linked package file changed");
133
+ }
138
134
  });
139
135
  if (process.versions?.webcontainer) {
140
136
  if (pollTimer) clearInterval(pollTimer);
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.c736659",
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": {