rsbuild-plugin-workspace-dev 0.1.0 → 0.1.1

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.
@@ -1,5 +1,4 @@
1
1
  export declare const PACKAGE_JSON = "package.json";
2
2
  export declare const PLUGIN_LOG_TITLE = "[Rsbuild Workspace Dev Plugin]: ";
3
3
  export declare const RSLIB_READY_MESSAGE = "build complete, watching for changes";
4
- export declare const MODERN_MODULE_READY_MESSAGE = "Watching for file changes";
5
4
  export declare const TSUP_READY_MESSAGE = "Watching for changes in";
package/dist/index.cjs CHANGED
@@ -41,7 +41,6 @@ var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_
41
41
  const PACKAGE_JSON = 'package.json';
42
42
  const PLUGIN_LOG_TITLE = '[Rsbuild Workspace Dev Plugin]: ';
43
43
  const RSLIB_READY_MESSAGE = 'build complete, watching for changes';
44
- const MODERN_MODULE_READY_MESSAGE = 'Watching for file changes';
45
44
  const TSUP_READY_MESSAGE = 'Watching for changes in';
46
45
  const external_fs_namespaceObject = require("fs");
47
46
  var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
@@ -118,7 +117,6 @@ const external_child_process_namespaceObject = require("child_process");
118
117
  const external_graphlib_namespaceObject = require("graphlib");
119
118
  var external_graphlib_default = /*#__PURE__*/ __webpack_require__.n(external_graphlib_namespaceObject);
120
119
  const external_path_namespaceObject = require("path");
121
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
122
120
  function workspace_dev_define_property(obj, key, value) {
123
121
  if (key in obj) Object.defineProperty(obj, key, {
124
122
  value: value,
@@ -131,7 +129,7 @@ function workspace_dev_define_property(obj, key, value) {
131
129
  }
132
130
  class WorkspaceDevRunner {
133
131
  async init() {
134
- this.metaData = await readPackageJson(external_path_default().join(this.cwd, PACKAGE_JSON));
132
+ this.metaData = await readPackageJson((0, external_path_namespaceObject.join)(this.cwd, PACKAGE_JSON));
135
133
  this.buildDependencyGraph();
136
134
  debugLog(`Dependency graph:\nnodes: ${this.getNodes().join(', ')}\nedges: ${this.getEdges().map((edge)=>`${edge.v} -> ${edge.w}`).join(', ')}\n`);
137
135
  }
@@ -205,12 +203,14 @@ class WorkspaceDevRunner {
205
203
  }
206
204
  visitNodes(node) {
207
205
  return new Promise((resolve)=>{
208
- const { name, path } = this.getNode(node);
206
+ const { name, path, packageJson } = this.getNode(node);
209
207
  const logger = new Logger({
210
208
  name
211
209
  });
212
210
  const config = this.options?.projects?.[name];
213
- if (config?.skip) {
211
+ const command = config?.command ? config.command : 'dev';
212
+ const scripts = packageJson.scripts || {};
213
+ if (config?.skip || !scripts[command]) {
214
214
  this.visited[node] = true;
215
215
  this.visiting[node] = false;
216
216
  debugLog(`Skip visit node: ${node}`);
@@ -220,7 +220,7 @@ class WorkspaceDevRunner {
220
220
  this.visiting[node] = true;
221
221
  const child = (0, external_child_process_namespaceObject.spawn)('npm', [
222
222
  'run',
223
- config?.command ? config.command : 'dev'
223
+ command
224
224
  ], {
225
225
  cwd: path,
226
226
  env: {
@@ -236,7 +236,7 @@ class WorkspaceDevRunner {
236
236
  debugLog(content, `${name}: `);
237
237
  logger.appendLog('stdout', stdout);
238
238
  const match = config?.match;
239
- const matchResult = match ? match(stdout) : stdout.match(RSLIB_READY_MESSAGE) || stdout.match(MODERN_MODULE_READY_MESSAGE) || stdout.match(TSUP_READY_MESSAGE);
239
+ const matchResult = match ? match(stdout) : stdout.match(RSLIB_READY_MESSAGE) || stdout.match(TSUP_READY_MESSAGE);
240
240
  if (matchResult) {
241
241
  logger.flushStdout();
242
242
  this.matched[node] = true;
package/dist/index.js CHANGED
@@ -4,11 +4,10 @@ import json5 from "json5";
4
4
  import { getPackagesSync } from "@manypkg/get-packages";
5
5
  import { spawn } from "child_process";
6
6
  import graphlib, { Graph } from "graphlib";
7
- import path_0 from "path";
7
+ import { join } from "path";
8
8
  const PACKAGE_JSON = 'package.json';
9
9
  const PLUGIN_LOG_TITLE = '[Rsbuild Workspace Dev Plugin]: ';
10
10
  const RSLIB_READY_MESSAGE = 'build complete, watching for changes';
11
- const MODERN_MODULE_READY_MESSAGE = 'Watching for file changes';
12
11
  const TSUP_READY_MESSAGE = 'Watching for changes in';
13
12
  async function pathExists(path) {
14
13
  return fs.promises.access(path).then(()=>true).catch(()=>false);
@@ -88,7 +87,7 @@ function workspace_dev_define_property(obj, key, value) {
88
87
  }
89
88
  class WorkspaceDevRunner {
90
89
  async init() {
91
- this.metaData = await readPackageJson(path_0.join(this.cwd, PACKAGE_JSON));
90
+ this.metaData = await readPackageJson(join(this.cwd, PACKAGE_JSON));
92
91
  this.buildDependencyGraph();
93
92
  debugLog(`Dependency graph:\nnodes: ${this.getNodes().join(', ')}\nedges: ${this.getEdges().map((edge)=>`${edge.v} -> ${edge.w}`).join(', ')}\n`);
94
93
  }
@@ -162,12 +161,14 @@ class WorkspaceDevRunner {
162
161
  }
163
162
  visitNodes(node) {
164
163
  return new Promise((resolve)=>{
165
- const { name, path } = this.getNode(node);
164
+ const { name, path, packageJson } = this.getNode(node);
166
165
  const logger = new Logger({
167
166
  name
168
167
  });
169
168
  const config = this.options?.projects?.[name];
170
- if (config?.skip) {
169
+ const command = config?.command ? config.command : 'dev';
170
+ const scripts = packageJson.scripts || {};
171
+ if (config?.skip || !scripts[command]) {
171
172
  this.visited[node] = true;
172
173
  this.visiting[node] = false;
173
174
  debugLog(`Skip visit node: ${node}`);
@@ -177,7 +178,7 @@ class WorkspaceDevRunner {
177
178
  this.visiting[node] = true;
178
179
  const child = spawn('npm', [
179
180
  'run',
180
- config?.command ? config.command : 'dev'
181
+ command
181
182
  ], {
182
183
  cwd: path,
183
184
  env: {
@@ -193,7 +194,7 @@ class WorkspaceDevRunner {
193
194
  debugLog(content, `${name}: `);
194
195
  logger.appendLog('stdout', stdout);
195
196
  const match = config?.match;
196
- const matchResult = match ? match(stdout) : stdout.match(RSLIB_READY_MESSAGE) || stdout.match(MODERN_MODULE_READY_MESSAGE) || stdout.match(TSUP_READY_MESSAGE);
197
+ const matchResult = match ? match(stdout) : stdout.match(RSLIB_READY_MESSAGE) || stdout.match(TSUP_READY_MESSAGE);
197
198
  if (matchResult) {
198
199
  logger.flushStdout();
199
200
  this.matched[node] = true;
@@ -0,0 +1,6 @@
1
+ import type { Package } from '@manypkg/get-packages';
2
+ export interface PackageWithScripts extends Package {
3
+ packageJson: Package['packageJson'] & {
4
+ scripts?: Record<string, string>;
5
+ };
6
+ }
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Package } from '@manypkg/get-packages';
1
+ import type { PackageWithScripts } from './types.js';
2
2
  export declare const readJson: <T>(jsonFileAbsPath: string) => Promise<T>;
3
- export declare const readPackageJson: (pkgJsonFilePath: string) => Promise<Package["packageJson"]>;
3
+ export declare const readPackageJson: (pkgJsonFilePath: string) => Promise<PackageWithScripts["packageJson"]>;
4
4
  export declare const isDebug: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsbuild-plugin-workspace-dev",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "An Rsbuild plugin to provides workspace recursive dev functionality for Monorepo topologies.",
5
5
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-workspace-dev",
6
6
  "license": "MIT",