-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1693 from balinterdi/add-broccoli-side-watch-package
Add broccoli-side-watch package
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# @embroider/broccoli-side-watch | ||
|
||
A micro library that allows watching folders for changes outside the `app` folder in Ember apps | ||
|
||
## Usage | ||
|
||
Let's assume you have a v2 addon in the `grand-prix` folder of your top-level folder of your Ember app. | ||
|
||
Every time you change something in the source of that add-on, you can rebuild it by watching the addon's build (currently using Rollup). However, by default the host Ember app doesn't rebuild automatically, so you have to restart the Ember app every time this happens which is a slog. | ||
|
||
With this library, you can add the following to your `ember-cli-build.js` to vastly improve your life as a developer: | ||
|
||
```js | ||
const sideWatch = require('@embroider/broccoli-side-watch'); | ||
|
||
const app = new EmberApp(defaults, { | ||
trees: { | ||
app: sideWatch('app', { watching: ['./grand-prix/src'] }), | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// From https://github.com/cardstack/boxel/blob/d54f834f/packages/host/lib/with-side-watch.js (MIT license) | ||
|
||
const mergeTrees = require('broccoli-merge-trees'); | ||
const { WatchedDir } = require('broccoli-source'); | ||
const Plugin = require('broccoli-plugin'); | ||
|
||
class BroccoliNoOp extends Plugin { | ||
constructor(path) { | ||
super([new WatchedDir(path)]); | ||
} | ||
build() {} | ||
} | ||
|
||
/* | ||
Doesn't change your actualTree, but causes a rebuild when any of opts.watching | ||
trees change. | ||
This is helpful when your build pipeline doesn't naturally watch some | ||
dependencies that you're actively developing. For example, right now | ||
@embroider/webpack doesn't rebuild itself when non-ember libraries change. | ||
*/ | ||
module.exports = function sideWatch(actualTree, opts) { | ||
return mergeTrees([actualTree, ...opts.watching.map(w => new BroccoliNoOp(w))]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "@embroider/broccoli-side-watch", | ||
"version": "0.0.1", | ||
"description": "Watch changes in other folders to rebuild Ember app", | ||
"main": "index.js", | ||
"keywords": [ | ||
"ember" | ||
], | ||
"author": "Balint Erdi", | ||
"license": "MIT", | ||
"dependencies": { | ||
"broccoli-merge-trees": "^4.2.0", | ||
"broccoli-plugin": "^4.0.7", | ||
"broccoli-source": "^3.0.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.