Rewatch: restore backward compatibility for bsconfig.json#8368
Rewatch: restore backward compatibility for bsconfig.json#8368jfrolich wants to merge 11 commits intorescript-lang:masterfrom
Conversation
Accept the legacy config file name and the old field aliases (bs-dependencies, bs-dev-dependencies, bsc-flags) so existing packages continue to build. Emit a deprecation warning on the legacy field names pointing at the modern replacements. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…egacy-config test read_package_name now also looks inside bsconfig.json if neither package.json nor rescript.json carry the package name. The warn_legacy_config build test is updated to assert the new behavior (build succeeds + deprecation warning is printed). Co-Authored-By: Claude <noreply@anthropic.com>
External packages can't fix these themselves, so the warning now fires for any package (local or external). For external packages we also look up an issue tracker URL from bugs/repository in package.json and include it so users can report the issue upstream. Co-Authored-By: Claude <noreply@anthropic.com>
|
@codex review |
…efresh snapshots Sorting the package iteration makes the warning output stable across runs (AHashMap iteration order is otherwise nondeterministic). Snapshot files are updated to reflect both the new deprecation messages (bs-dependencies/bs-dev-dependencies/bsc-flags for @testrepo/deprecated-config, and for the external rescript-nodejs + sury packages plus the bsconfig.json filename deprecation on rescript-nodejs) and the new sorted order. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eac42748b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| fn has_rescript_config(path: &Path) -> bool { | ||
| path.join("rescript.json").exists() | ||
| path.join("rescript.json").exists() || path.join("bsconfig.json").exists() |
There was a problem hiding this comment.
Trigger full rebuilds for bsconfig.json edits
has_rescript_config now recognizes bsconfig.json, but watch mode still upgrades only rescript.json events to CompileType::Full (rewatch/src/watcher.rs:259-270) and ignores non-source .json changes otherwise. In a bsconfig-only project, editing config fields (dependencies, compiler flags, sources, etc.) will not trigger recompilation, so the running watcher can keep stale build state until manually restarted.
Useful? React with 👍 / 👎.
| #[serde(alias = "bs-dependencies")] | ||
| pub dependencies: Option<Vec<String>>, | ||
| #[serde(rename = "dev-dependencies")] | ||
| #[serde(rename = "dev-dependencies", alias = "bs-dev-dependencies")] | ||
| pub dev_dependencies: Option<Vec<String>>, |
There was a problem hiding this comment.
Handle legacy alias + modern key without parse failure
Using serde aliases for legacy keys makes bs-dependencies/dependencies (and similar pairs) map to the same struct field, so configs that contain both names now deserialize as a duplicate field error. Those mixed configs were previously usable because the legacy key was treated as unknown, so this change can break migration scenarios; parsing should normalize/prefer the modern key while still emitting the deprecation warning.
Useful? React with 👍 / 👎.
Previously watch mode only upgraded rescript.json changes to a full rebuild. In a bsconfig-only project, editing config fields did not trigger recompilation, so the running watcher kept stale build state until restarted. Co-Authored-By: Claude <noreply@anthropic.com>
Previously each deprecated field/filename printed its own paragraph,
which was noisy (especially for packages with multiple legacy fields,
like rescript-nodejs). The issue-tracker URL was also repeated per
warning. Collapsed into a single block per package:
Package 'foo' uses deprecated config (support will be removed in a future version):
- field 'bs-dependencies' — use 'dependencies' instead
- filename 'bsconfig.json' — rename to 'rescript.json'
Please report this to the package maintainer: https://…/issues
Snapshots and the warn_legacy_config build test are updated to match.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5a40743a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
package-specs.module now accepts the legacy 'cjs' value (alias for 'commonjs') and emits the standard per-package deprecation warning so users know to migrate. Co-Authored-By: Claude <noreply@anthropic.com>
package-specs.module now accepts the legacy 'es6' value (alias for 'esmodule') and emits the standard per-package deprecation warning. The old test_package_specs_es6_deprecation (which asserted the value was rejected) is replaced with test_es6_module_alias. Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Restores backward compatibility that was removed in #8187 and #8196 so that existing projects using the legacy config name and field aliases continue to build under rewatch.
rewatchagain falls back tobsconfig.jsonwhenrescript.jsonis absent (read_config,has_rescript_config).bs-dependencies,bs-dev-dependencies, andbsc-flagsas aliases fordependencies,dev-dependencies, andcompiler-flags(via#[serde(alias = ...)]).cp bsconfig.json rescript.jsonworkaround inrewatch/tests/suite.sh(no longer needed now that rewatch readsbsconfig.jsondirectly).Test plan
cargo test --lib config::— 34 tests pass, including new alias/deprecation tests forbs-dependencies,bs-dev-dependencies,bsc-flagsbsconfig.jsoninnode_modulesand confirm rewatch resolves it and prints the deprecation warning🤖 Generated with Claude Code