Skip to content

Commit

Permalink
fix(cli): only show webpack options for dev if bundler = "webpack" (#…
Browse files Browse the repository at this point in the history
…10359)

> This is breaking because it would mean that `yarn rw dev --fwd="..."`
would fail instead of no-op like it does now with Vite. (To be clear the
current behavior is that it no-ops, as in it doesn't work.)

Right now `yarn rw dev --fwd="..."` doesn't work (but doesn't fail) with
Vite because it's not wired up. Wiring it up is nontrivial. It's a flag
that was used fairly regularly with webpack I think, mostly just to stop
the browser from opening. It's been broken since we switched to Vite so
a while now, and with no timetable on when it'll be fixed it feels more
honest to just not advertise it.

We should at least stop showing the other flag which is webpack
specific, but yeah.
  • Loading branch information
jtoar authored Apr 10, 2024
1 parent 174daba commit 07361ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changesets/10359.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- fix(cli): only show webpack options for dev if `bundler = "webpack"` (#10359) by @jtoar

A few flags for `yarn rw dev` don't apply to Vite but are shown nevertheless. One of them, `watchNodeModules`, is legacy at this point. It's only useful for testing out framework changes on a project using webpack. It makes the webpack dev server reload on changes to node_modules. The other, `forward` (aliased `fwd`) isn't fundamentally Webpack specific, but has been broken for quite a while because the fix is nontrivial. It seems better to hide these flags for now, otherwise we're just advertising broken or no-op behavior.
9 changes: 9 additions & 0 deletions packages/cli/src/commands/dev.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import terminalLink from 'terminal-link'

import { getConfig } from '../lib'
import c from '../lib/colors'
import { checkNodeVersion } from '../middleware/checkNodeVersion'

export const command = 'dev [side..]'
export const description = 'Start development servers for api, and web'

export const builder = (yargs) => {
// We hide some options based on the bundler being used.
// Note that `watchNodeModules` is webpack specific, but `forward` isn't.
// The reason it's also hidden is that it's been broken with Vite
// and it's not clear how to fix it.
const isUsingWebpack = getConfig().web.bundler === 'webpack'

yargs
.positional('side', {
choices: ['api', 'web'],
Expand All @@ -19,6 +26,7 @@ export const builder = (yargs) => {
description:
'String of one or more Webpack DevServer config options, for example: `--fwd="--port=1234 --no-open"`',
type: 'string',
hidden: !isUsingWebpack,
})
.option('generate', {
type: 'boolean',
Expand All @@ -28,6 +36,7 @@ export const builder = (yargs) => {
.option('watchNodeModules', {
type: 'boolean',
description: 'Reload on changes to node_modules',
hidden: !isUsingWebpack,
})
.option('apiDebugPort', {
type: 'number',
Expand Down

0 comments on commit 07361ec

Please sign in to comment.