watchful-cli 1.7.92 → 1.7.94
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/README.md +27 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Incremental transpilation with bundling.
|
|
4
4
|
|
|
5
|
-
Watchful leverages existing bundlers and transpilers in order to provide a straightforward build tool that supports incremental transpilation with bundling.
|
|
5
|
+
Watchful leverages existing bundlers and transpilers in order to provide a straightforward build tool that supports incremental transpilation with bundling.
|
|
6
|
+
It has a batch mode and a watch mode.
|
|
7
|
+
In the latter mode it will only transpile files that have been added or changed, improving build times considerably.
|
|
6
8
|
|
|
7
9
|
Watchful works best hand in hand with [Lively-CLI](https://github.com/djalbat/lively-cli).
|
|
8
10
|
|
|
@@ -15,7 +17,8 @@ Watchful works best hand in hand with [Lively-CLI](https://github.com/djalbat/li
|
|
|
15
17
|
|
|
16
18
|
### Projects to get you started
|
|
17
19
|
|
|
18
|
-
All of the projects below utilise Watchful and can be readily adapted to make a template for your project.
|
|
20
|
+
All of the projects below utilise Watchful and can be readily adapted to make a template for your project.
|
|
21
|
+
To see Watchful in action, clone a project, run the usual `npm install` and then `npm run watch-debug`.
|
|
19
22
|
|
|
20
23
|
* [Necessary](https://github.com/djalbat/necessary)
|
|
21
24
|
* [Sufficient](https://github.com/djalbat/necessary)
|
|
@@ -109,15 +112,25 @@ In order to build a package, you must supply source and target directories, the
|
|
|
109
112
|
|
|
110
113
|
watchful batch --source-directory=es6/ --lib-directory=./lib
|
|
111
114
|
|
|
112
|
-
This will transpile all the JavaScript files in the `es6` directory and place them in the `lib` directory while honouring sub-directories.
|
|
115
|
+
This will transpile all the JavaScript files in the `es6` directory and place them in the `lib` directory while honouring sub-directories.
|
|
116
|
+
Note that Watchful is tolerant of leading and trailing delimiters.
|
|
117
|
+
Nonetheless, it expects paths to be relative ones pointing to folders in the project directory.
|
|
118
|
+
Relative paths outside of the project directory or any absolute paths will result in errors.
|
|
113
119
|
|
|
114
|
-
In order to build a bundle, you must supply the source directory and target directories together with an entry file for the bundler.
|
|
120
|
+
In order to build a bundle, you must supply the source directory and target directories together with an entry file for the bundler.
|
|
121
|
+
The target directory can be either a temp directory or a lib directory:
|
|
115
122
|
|
|
116
123
|
watchful batch --source-directory=es6/ --temp-directory=./tmp --enty-file=main.js
|
|
117
124
|
|
|
118
|
-
The path to the entry file is taken to be relative to the target directory, not the project directory.
|
|
125
|
+
The path to the entry file is taken to be relative to the target directory, not the project directory.
|
|
126
|
+
You can also optionally supply a path to the bundle file by way of the `--bundle-file` option, otherwise the output is piped to `stdout`.
|
|
127
|
+
Either the temp or the lib directory can be given as the target directory, by the way, because there may be times when you want to both build a bundle and build a package.
|
|
119
128
|
|
|
120
|
-
Multiple processes are supported in batch mode, set the `--processes` option to a number greater than 1 to enable them. Be careful not to set this too high.
|
|
129
|
+
Multiple processes are supported in batch mode, set the `--processes` option to a number greater than 1 to enable them. Be careful not to set this too high.
|
|
130
|
+
On a modern MacBook the optimal number is only 4 processes.
|
|
131
|
+
Any more and performance actually deteriorates. Remember that multiple processes are only supported in batch mode where the gains are likely to be significant.
|
|
132
|
+
In incremental mode, the gains are likely to be in the region of a tenth of a second or even less, and therefore not worth the implementation effort.
|
|
133
|
+
Also bear in mind that there is an overhead associated with creating more than one process and therefore you will only see gains if transpiling dozens of files rather than just a few.
|
|
121
134
|
|
|
122
135
|
As already mentioned, it is recommended that you install Watchful as a project dependency rather than globally, then run it with npm scripts.
|
|
123
136
|
|
|
@@ -213,11 +226,16 @@ There are several points worth noting:
|
|
|
213
226
|
|
|
214
227
|
The number of child processes has also been set to 4 here, but remember that this only improves things for large projects with hundreds of files, otherwise it may actually have a detrimental effect.
|
|
215
228
|
|
|
216
|
-
* The `clean` script has nothing to do with Watchful.
|
|
229
|
+
* The `clean` script has nothing to do with Watchful.
|
|
230
|
+
It deletes the `tmp` directory and is used in the build scripts.
|
|
231
|
+
Note that since the watch scripts have to be killed by the user, there is no opportunity to clean up after watching and consequently the `tmp` directory will remain.
|
|
232
|
+
* It is recommended that you add it to your `.gitignore` file, therefore, or make sure to always build before deployment.
|
|
217
233
|
|
|
218
|
-
* The `watchful` script invokes Watchful with the requisite paths for the source and temp directories together with the entry and bundle files.
|
|
234
|
+
* The `watchful` script invokes Watchful with the requisite paths for the source and temp directories together with the entry and bundle files.
|
|
235
|
+
The options have been abbreviated. Using a dedicated `watchful` script means that these options only have to be specified once.
|
|
219
236
|
|
|
220
|
-
* The `batch`, `batch-debug`, `incremental` and `incremental-debug` scripts all make use of the aforementioned `watchful` script, passing it the requisite command plus additional options.
|
|
237
|
+
* The `batch`, `batch-debug`, `incremental` and `incremental-debug` scripts all make use of the aforementioned `watchful` script, passing it the requisite command plus additional options.
|
|
238
|
+
The special `--` command tells npm to pass these options verbatim. The `incremental` command is optional and can be left out.
|
|
221
239
|
|
|
222
240
|
* For a package rather than a bundle, you could remove the call to the final `clean` script from the build scripts; remove the entry and bundle file options from the `watchful` script; and change the temp directory to a lib directory.
|
|
223
241
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "watchful-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.94",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/watchful-cli",
|
|
7
7
|
"description": "Incremental transpilation with bundling.",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.46",
|
|
14
14
|
"chokidar": "^5.0.0",
|
|
15
|
-
"necessary": "^17.2.
|
|
15
|
+
"necessary": "^17.2.9"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@swc/core": "1.13.20",
|