Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/sui-bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
8 changes: 6 additions & 2 deletions packages/sui-bundler/loaders/linkLoaderConfigBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
Expand Down
Loading