Skip to content

Watch mode will not be settable from command-line after npm 12 flag parsing changes #1346

@aomarks

Description

@aomarks

According to npm/cli#8071 (which adds a warning), npm will change the way arguments are parsed in a way that will break the way wireit looks for the --watch environment variable.

Previously, npm run build --foo would set the npm_config_foo environment variable, and we relied upon that fact for detecting when the --watch flag had been sent.

In npm 12, this will be an error about "watch" being an unrecognized npm argument. This seems like a good change for npm (silently eating arguments does seem bad), but I don't believe we currently have another way to enable wireit watch mode.

Proposals:

  1. Add a WIREIT_WATCH=1 environment variable.
  2. Special case --wireit-watch (and perhaps reserve --wireit- prefixed flag) to be extracted from the additional arguments that are usually passed down to the actual command (e.g. npm run build -- --wireit-watch --flag-for-build)
  3. Solve for [discussion] add —watch to the wireit command as an option #553 to allow a script to be configured as intrinsically watching (e.g. a {"watch":true} config setting), so that people can easily define e.g. build:watch scripts instead of using flags in the first place.

I'm leaning towards doing 1 in the short term, because we already handle all other runtime wireit settings with WIREIT_ environment variables and it's very easy, and 3 as a followup.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions