diff --git a/packages/sui-bundler/README.md b/packages/sui-bundler/README.md index 21bb6a67b..dedc5fd42 100644 --- a/packages/sui-bundler/README.md +++ b/packages/sui-bundler/README.md @@ -102,6 +102,21 @@ $ sui-bundler dev -L ../frontend-ma--uilib-components/components And of course you can combine `link-all` and `link-package` flags +#### Packages with their own watcher (dev script) + +When using `--link-package` or `--link-all`, packages that define a `dev` script in their `package.json` are **automatically excluded** from being linked by `sui-bundler`. These packages are expected to handle their own file watching and compilation via their `dev` script, so linking them would be redundant or could cause conflicts. + +```json +// package.json of the linked package +{ + "scripts": { + "dev": "tsup --watch" // this package will NOT be linked by sui-bundler + } +} +``` + +> **Note:** If the package is **not part of the monorepo** (i.e. it lives outside the project remember to use [`npm link`](https://docs.npmjs.com/cli/commands/npm-link) directly instead. + ### Production ``` diff --git a/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js b/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js index 147f11541..d7c4294da 100644 --- a/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js +++ b/packages/sui-bundler/loaders/linkLoaderConfigBuilder.js @@ -10,8 +10,12 @@ const diccFromAbsolutePaths = (paths, init = {}) => const packagePath = path.resolve(pkg) try { const pkg = require(path.join(packagePath, 'package.json')) - acc[pkg.name] = path.join(packagePath, 'src') - log.success(`✔ ${pkg.name} from path "${packagePath}"`) + if (pkg.scripts?.dev) { + log.info(`ℹ Package from path "${packagePath}" wouldn't be linked because it has its own watcher.`) + } else { + acc[pkg.name] = path.join(packagePath, 'src') + log.success(`✔ ${pkg.name} from path "${packagePath}"`) + } return acc } catch (e) { log.warn(`⚠ Package from path "${packagePath}" can't be linked.\n Path is wrong or package.json is missing.`)