watchful-cli 1.7.35 → 1.7.38

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 CHANGED
@@ -2,7 +2,7 @@
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 together with bundling. It has a batch mode and a watch mode. In the latter mode it will only transpile files that have been added or changed, improving build times considerably.
5
+ Watchful leverages existing bundlers and transpilers in order to provide a straightforward build tool that supports incremental transpilation with bundling. It has a batch mode and a watch mode. In the latter mode it will only transpile files that have been added or changed, improving build times considerably.
6
6
 
7
7
  Watchful works best hand in hand with [Lively-CLI](https://github.com/djalbat/lively-cli).
8
8
 
@@ -26,10 +26,6 @@ Both of these packages work in the browser and on Node. Necessary accomplishes t
26
26
 
27
27
  This is also a package but has a bundled example. To see the latter in action, run `npm install` and `npm watch-debug` as before along with `npm start` to kick off a small development server. The example can be viewed at http://localhost:8888 and, since the development server utilises Lively, will live reload if you make changes to the source.
28
28
 
29
- * [Muon](https://github.com/petros-ioannou1/muon)
30
-
31
- Muon is a work in progress but nonetheless is a good example of a project that leverages both Watchful and Lively. The setup instructions are the same as for With Style.
32
-
33
29
  ### Comparisons
34
30
 
35
31
  Using SWC and ESBuild in combination together with multiple processes can speed up a batch build more than fifteen times. The following metrics were gathered on a modern albeit mid-level MacBook for a project with just under four hundred files:
@@ -39,12 +35,6 @@ Using SWC and ESBuild in combination together with multiple processes can speed
39
35
  | Babel + Browserify | 8.5 seconds | 2.2 seconds | 10.7 seconds |
40
36
  | SWC + ESBuild (4 processes) | 0.42 seconds | 0.24 seconds | 0.66 seconds |
41
37
 
42
- ### Why aren't these tools included as dependencies?
43
-
44
- Babel presets and plugins require [@babel/core](https://babeljs.io/docs/en/babel-core) as a peer dependency, so you would have to include it in your project anyway. Additionally, it is a large project with many dependencies itself and since it is optional, it did not seem like a good idea to include it. Similarly, since bundling is optional, there seemed little point in including either bundler as a dependency.
45
-
46
- Watchful is designed to run in your project directory and will load the bundlers and transpilers it finds there. This gives you complete control over their versions and configuration. Aside from a `debug` and `node` options, Watchful is agnostic to both.
47
-
48
38
  ## Installation
49
39
 
50
40
  You can install Watchful via [npm](https://www.npmjs.com/):
@@ -80,22 +70,24 @@ Commands:
80
70
 
81
71
  Options:
82
72
 
83
- --help|-h Show this help
84
-
85
73
  --version|-v Show the version
86
74
 
75
+ --help|-h Show this help
76
+
87
77
  --wait|-w Wait before building incrementally
88
78
 
89
79
  --node|-n Bundle for Node rather than the browser
90
80
 
91
81
  --debug|-d Debug, that is enable source maps
92
82
 
83
+ --release|-r Release, that is enable minification
84
+
93
85
  --metrics|-m Show metrics, that is file counts and times
94
86
 
95
87
  --quietly|-q Run with almost no console logging
96
88
 
97
89
  --processes|-p The number of processes
98
-
90
+
99
91
  --bundler|-u The bundler, either `browserify` or `esbuild`
100
92
 
101
93
  --transpiler|-r The transpiler, either `babel` or `swc`
@@ -104,9 +96,9 @@ Options:
104
96
 
105
97
  --bundle-file|-b Bundle file path
106
98
 
107
- --lib-directory|-l Lib directory path
99
+ --lib-directory|-l Library directory path
108
100
 
109
- --temp-directory|-t Temp directory path
101
+ --temp-directory|-x Temporary directory path
110
102
 
111
103
  --source-directory|-s Source directory path
112
104
  ```
@@ -199,11 +191,11 @@ Now for the npm scripts:
199
191
  ```
200
192
  "scripts": {
201
193
  "clean": "rm -rf ./tmp",
202
- "watchful": "watchful -m -s=./es6 -t=./tmp -e=main.js -b=./public/lib/client.js",
203
- "batch": "npm run watchful batch --",
194
+ "watchful": "watchful -m -s=./es6 -x=./tmp -e=main.js -b=./public/lib/client.js--wait=100 ",
195
+ "batch": "npm run watchful batch -- --release",
204
196
  "batch-debug": "npm run watchful batch -- --debug",
205
- "incremental": "npm run watchful incremental -- -qm --wait=100",
206
- "incremental-debug": "npm run watchful incremental -- --debug -qm --wait=100",
197
+ "incremental": "npm run watchful incremental -- --release",
198
+ "incremental-debug": "npm run watchful incremental -- --debug",
207
199
  "build": "npm run clean && npm run batch && npm run clean",
208
200
  "build-debug": "npm run clean && npm run batch-debug && npm run clean",
209
201
  "watch": "npm run clean && npm run batch && npm run incremental",
@@ -229,7 +221,7 @@ The number of child processes has also been set to 4 here, but remember that thi
229
221
 
230
222
  * 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.
231
223
 
232
- * For incremental builds, the `wait` option has been set to 100 milliseconds. Usually this can be left at the default, which is 0 milliseconds. However, if you find that not all of the transformations are being completed before bundling starts, you may want to experiment with this option.
224
+ * The `wait` option has been set to 100 milliseconds. Usually this can be left at the default, which is 0 milliseconds. However, if you find that not all of the transformations are being completed before bundling starts, you may want to experiment with this option.
233
225
 
234
226
  ## Contact
235
227
 
@@ -4,6 +4,7 @@ const { HELP_OPTION,
4
4
  NODE_OPTION,
5
5
  WAIT_OPTION,
6
6
  DEBUG_OPTION,
7
+ RELEASE_OPTION,
7
8
  BUNDLER_OPTION,
8
9
  QUIETLY_OPTION,
9
10
  VERSION_OPTION,
@@ -20,16 +21,17 @@ const h = HELP_OPTION,
20
21
  n = NODE_OPTION,
21
22
  w = WAIT_OPTION,
22
23
  d = DEBUG_OPTION,
24
+ r = RELEASE_OPTION,
23
25
  u = BUNDLER_OPTION,
24
26
  q = QUIETLY_OPTION,
25
27
  v = VERSION_OPTION,
26
28
  m = METRICS_OPTION,
27
29
  p = PROCESSES_OPTION,
28
- r = TRANSPILER_OPTION,
30
+ t = TRANSPILER_OPTION,
29
31
  e = ENTRY_FILE_OPTION,
30
32
  b = BUNDLE_FILE_OPTION,
31
33
  l = LIB_DIRECTORY_OPTION,
32
- t = TEMP_DIRECTORY_OPTION,
34
+ x = TEMP_DIRECTORY_OPTION,
33
35
  s = SOURCE_DIRECTORY_OPTION;
34
36
 
35
37
  module.exports = {
@@ -37,15 +39,16 @@ module.exports = {
37
39
  n,
38
40
  w,
39
41
  d,
42
+ r,
40
43
  u,
41
44
  q,
42
45
  v,
43
46
  m,
44
47
  p,
45
- r,
48
+ t,
46
49
  e,
47
50
  b,
48
51
  l,
49
- t,
52
+ x,
50
53
  s
51
54
  };
@@ -10,7 +10,7 @@ const action = require("../action"),
10
10
 
11
11
  const { BATCH_BUILD_FAILED_MESSAGE } = require("../messages");
12
12
 
13
- function batchAction(wait, node, debug, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory) {
13
+ function batchAction(wait, node, debug, release, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory) {
14
14
  const operations = [
15
15
  initialiseOperation,
16
16
  createTranspileFileFunctionOperation,
@@ -23,6 +23,7 @@ function batchAction(wait, node, debug, bundler, quietly, metrics, entryFile, pr
23
23
  wait,
24
24
  node,
25
25
  debug,
26
+ release,
26
27
  bundler,
27
28
  quietly,
28
29
  metrics,
@@ -27,6 +27,8 @@ Options:
27
27
 
28
28
  --debug|-d Debug, that is enable source maps
29
29
 
30
+ --release|-r Release, that is enable minification
31
+
30
32
  --metrics|-m Show metrics, that is file counts and times
31
33
 
32
34
  --quietly|-q Run with almost no console logging
@@ -41,9 +43,9 @@ Options:
41
43
 
42
44
  --bundle-file|-b Bundle file path
43
45
 
44
- --lib-directory|-l Lib directory path
46
+ --lib-directory|-l Library directory path
45
47
 
46
- --temp-directory|-t Temp directory path
48
+ --temp-directory|-x Temporary directory path
47
49
 
48
50
  --source-directory|-s Source directory path
49
51
 
@@ -9,7 +9,7 @@ const watch = require("../watch"),
9
9
 
10
10
  const { INCREMENTAL_BUILD_FAILED_MESSAGE } = require("../messages");
11
11
 
12
- function incrementalAction(wait, node, debug, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory) {
12
+ function incrementalAction(wait, node, debug, release, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory) {
13
13
  const operations = [
14
14
  initialiseOperation,
15
15
  createTranspileFileFunctionOperation,
@@ -20,6 +20,7 @@ function incrementalAction(wait, node, debug, bundler, quietly, metrics, entryFi
20
20
  wait,
21
21
  node,
22
22
  debug,
23
+ release,
23
24
  bundler,
24
25
  quietly,
25
26
  metrics,
package/bin/actions.js CHANGED
@@ -10,8 +10,9 @@ const { HELP_COMMAND, BATCH_COMMAND, VERSION_COMMAND, INCREMENTAL_COMMAND } = re
10
10
  DEFAULT_WAIT,
11
11
  DEFAULT_NODE,
12
12
  DEFAULT_DEBUG,
13
- DEFAULT_VERSION,
13
+ DEFAULT_RELEASE,
14
14
  DEFAULT_BUNDLER,
15
+ DEFAULT_VERSION,
15
16
  DEFAULT_QUIETLY,
16
17
  DEFAULT_METRICS,
17
18
  DEFAULT_ENTRY_FILE,
@@ -28,8 +29,9 @@ function actions(command, argument, options) {
28
29
  wait = DEFAULT_WAIT,
29
30
  node = DEFAULT_NODE,
30
31
  debug = DEFAULT_DEBUG,
31
- version = DEFAULT_VERSION,
32
+ release = DEFAULT_RELEASE,
32
33
  bundler = DEFAULT_BUNDLER,
34
+ version = DEFAULT_VERSION,
33
35
  quietly = DEFAULT_QUIETLY,
34
36
  metrics = DEFAULT_METRICS,
35
37
  entryFile = DEFAULT_ENTRY_FILE,
@@ -52,9 +54,9 @@ function actions(command, argument, options) {
52
54
 
53
55
  switch (command) {
54
56
  case HELP_COMMAND: helpAction(); break;
55
- case BATCH_COMMAND: batchAction(wait, node, debug, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory); break;
57
+ case BATCH_COMMAND: batchAction(wait, node, debug, release, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory); break;
56
58
  case VERSION_COMMAND: versionAction(); break;
57
- case INCREMENTAL_COMMAND: incrementalAction(wait, node, debug, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory); break;
59
+ case INCREMENTAL_COMMAND: incrementalAction(wait, node, debug, release, bundler, quietly, metrics, entryFile, processes, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory); break;
58
60
  }
59
61
  }
60
62
 
package/bin/defaults.js CHANGED
@@ -6,8 +6,9 @@ const DEFAULT_HELP = false,
6
6
  DEFAULT_WAIT = 0,
7
7
  DEFAULT_NODE = false,
8
8
  DEFAULT_DEBUG = false,
9
- DEFAULT_VERSION = false,
9
+ DEFAULT_RELEASE = false,
10
10
  DEFAULT_BUNDLER = BROWSERIFY,
11
+ DEFAULT_VERSION = false,
11
12
  DEFAULT_QUIETLY = false,
12
13
  DEFAULT_METRICS = false,
13
14
  DEFAULT_PROCESSES = 1,
@@ -23,8 +24,9 @@ module.exports = {
23
24
  DEFAULT_WAIT,
24
25
  DEFAULT_NODE,
25
26
  DEFAULT_DEBUG,
26
- DEFAULT_VERSION,
27
+ DEFAULT_RELEASE,
27
28
  DEFAULT_BUNDLER,
29
+ DEFAULT_VERSION,
28
30
  DEFAULT_QUIETLY,
29
31
  DEFAULT_METRICS,
30
32
  DEFAULT_PROCESSES,
package/bin/messages.js CHANGED
@@ -12,6 +12,7 @@ const SWC_FAILED_MESSAGE = "swc failed:",
12
12
  BROWSERIFY_NOT_INSTALLED_MESSAGE = "Browserify is not installed.",
13
13
  NO_ENTRY_FILE_SPECIFIED_MESSAGE = "If a temp directory is specified then an entry file must also be given.",
14
14
  NO_BUNDLE_FILE_SPECIFIED_MESSAGE = "If a temp directory is specified then a bundle file must also be given.",
15
+ DEBUG_AND_RELEAES_BOTH_SET_MESSAGE = "The debug and release flags cannot both be set at the same time.",
15
16
  NO_SOURCE_DIRECTORY_SPECIFIED_MESSAGE = "The source directory has not been specified.",
16
17
  ENTRY_FILE_BUT_NO_BUNDLE_FILE_SPECIFIED_MESSAGE = "If an entry file is specified then a bundle file must also be given.",
17
18
  BUNDLE_FILE_BUT_NO_ENTRY_FILE_SPECIFIED_MESSAGE = "If a bundle file is specified then an entry file must also be given.",
@@ -37,6 +38,7 @@ module.exports = {
37
38
  BROWSERIFY_NOT_INSTALLED_MESSAGE,
38
39
  NO_ENTRY_FILE_SPECIFIED_MESSAGE,
39
40
  NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
41
+ DEBUG_AND_RELEAES_BOTH_SET_MESSAGE,
40
42
  NO_SOURCE_DIRECTORY_SPECIFIED_MESSAGE,
41
43
  ENTRY_FILE_BUT_NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
42
44
  BUNDLE_FILE_BUT_NO_ENTRY_FILE_SPECIFIED_MESSAGE,
@@ -4,6 +4,7 @@ const { pathFromOption } = require("../utilities/path"),
4
4
  { initialiseMetrics } = require("../utilities/metrics"),
5
5
  { NO_ENTRY_FILE_SPECIFIED_MESSAGE,
6
6
  NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
7
+ DEBUG_AND_RELEAES_BOTH_SET_MESSAGE,
7
8
  NO_SOURCE_DIRECTORY_SPECFIFIED_MESSAGE,
8
9
  ENTRY_FILE_BUT_NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
9
10
  BUNDLE_FILE_BUT_NO_ENTRY_FILE_SPECIFIED_MESSAGE,
@@ -19,6 +20,7 @@ function initialiseOperation(proceed, abort, context) {
19
20
  const { wait,
20
21
  node,
21
22
  debug,
23
+ release,
22
24
  bundler,
23
25
  quietly,
24
26
  metrics,
@@ -36,6 +38,14 @@ function initialiseOperation(proceed, abort, context) {
36
38
  sourceDirectoryPath = null,
37
39
  targetDirectoryPath = null;
38
40
 
41
+ if (debug && release) {
42
+ console.log(DEBUG_AND_RELEAES_BOTH_SET_MESSAGE);
43
+
44
+ abort();
45
+
46
+ return;
47
+ }
48
+
39
49
  if (sourceDirectory === null) {
40
50
  console.log(NO_SOURCE_DIRECTORY_SPECFIFIED_MESSAGE);
41
51
 
@@ -32,7 +32,7 @@ function createEsbuildBundleFilesFunction(context) {
32
32
  esbuild = require(esbuildPath);
33
33
 
34
34
  esBuildBundleFilesFunction = (entryFilePath, bundleFilePath, targetDirectoryPath, callback) => {
35
- const { node, debug } = context,
35
+ const { node, debug, release } = context,
36
36
  bundler = esbuild, ///
37
37
  targetEntryFilePath = combinePaths(targetDirectoryPath, entryFilePath),
38
38
  entryPoint = targetEntryFilePath, ///
@@ -41,10 +41,12 @@ function createEsbuildBundleFilesFunction(context) {
41
41
  ],
42
42
  outfile = bundleFilePath, ///
43
43
  bundle = true,
44
+ minify = release,
44
45
  options = {
45
46
  entryPoints,
46
47
  outfile,
47
- bundle
48
+ bundle,
49
+ minify
48
50
  };
49
51
 
50
52
  if (debug) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "watchful-cli",
3
3
  "author": "James Smith",
4
- "version": "1.7.35",
4
+ "version": "1.7.38",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/watchful-cli",
7
7
  "description": "Incremental transpilation with bundling.",