chore: update node babel/mocha envs#10477
Conversation
…-mocha 1.0.1, core-aspect-env 1.0.1)
PR Summary by Qodochore: pin updated Bit env versions in .bitmap
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Lockfile env version drift
|
…breaks TS compile)
|
Code review by qodo was updated up to the latest commit 8fa4087 |
… & react-env@1.2.7 bumps (TS5095 in preview/compile)
|
Code review by qodo was updated up to the latest commit 99762e8 |
|
Code review by qodo was updated up to the latest commit 9b3cd66 |
| "rootDir": "components/legacy/analytics", | ||
| "config": { | ||
| "teambit.node/envs/node-babel-mocha@1.0.2": {} | ||
| } |
There was a problem hiding this comment.
1. Lockfile env version drift 🐞 Bug ☼ Reliability
.bitmap now pins components to node-babel-mocha@1.0.2 / node-typescript-mocha@1.0.1, but pnpm-lock.yaml still resolves @teambit/node.envs.node-babel-mocha@1.0.1 and @teambit/node.envs.node-typescript-mocha@1.0.0. This makes installs non-reproducible and can lead to builds/capsules using the old env (or failing to resolve the intended env version).
Agent Prompt
### Issue description
`.bitmap` references `teambit.node/envs/node-babel-mocha@1.0.2` and `teambit.node/envs/node-typescript-mocha@1.0.1`, but `pnpm-lock.yaml` still resolves the previous env package versions (babel: 1.0.1, typescript: 1.0.0). This can cause CI/local installs to not actually use the updated environments, and may trigger resolution/runtime errors when Bit expects the newer env artifacts.
### Issue Context
These envs are installed as `.bit_roots` packages, so the lockfile must include the updated `.bit_roots/...@<version>` entries and the corresponding `@teambit/node.envs.*@<version>` entries.
### Fix Focus Areas
- .bitmap[12-21]
- .bitmap[550-558]
- pnpm-lock.yaml[9499-9506]
- pnpm-lock.yaml[10501-10506]
- pnpm-lock.yaml[36232-36236]
### Suggested fix
1. Regenerate the lockfile by running the repo’s standard install flow after the env update (commonly `bit install` and/or `pnpm install` depending on how this workspace manages `.bit_roots`).
2. Verify `pnpm-lock.yaml` includes:
- `.bit_roots/teambit.node_envs_node-babel-mocha@1.0.2`
- `.bit_roots/teambit.node_envs_node-typescript-mocha@1.0.1`
- `@teambit/node.envs.node-babel-mocha@1.0.2`
- `@teambit/node.envs.node-typescript-mocha@1.0.1`
3. Commit the updated `pnpm-lock.yaml`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "rootDir": "scopes/cloud/hooks/use-current-user", | ||
| "config": { | ||
| "teambit.node/envs/node-babel-mocha@1.0.2": {} | ||
| } |
There was a problem hiding this comment.
2. Window access during render 🐞 Bug ≡ Correctness
useCurrentUser() reads window.location.href in the effect dependency array, which is evaluated during render and will throw when window is undefined (Node/SSR/tests). This becomes more likely to break builds/tests now that the component is explicitly configured in .bitmap with the node-babel-mocha@1.0.2 environment.
Agent Prompt
### Issue description
`scopes/cloud/hooks/use-current-user/use-current-user.ts` evaluates `window.location.href` during render time via the effect dependency array (`[window.location.href]`). In non-browser contexts, this throws `ReferenceError: window is not defined`.
### Issue Context
This component is explicitly configured in `.bitmap` to use `teambit.node/envs/node-babel-mocha@1.0.2`, increasing the likelihood it will be executed in Node-based contexts (capsule tests/build tooling).
### Fix Focus Areas
- .bitmap[887-896]
- scopes/cloud/hooks/use-current-user/use-current-user.ts[24-39]
### Suggested fix
Refactor to avoid reading `window` during render:
- Compute a safe dependency value:
- `const href = typeof window === 'undefined' ? '' : window.location.href;`
- Use `href` in the dependency array.
Or, if you only need to set redirect once:
- Guard and run once:
- `React.useEffect(() => { if (typeof window === 'undefined') return; ... }, []);`
(Choose the behavior that matches the intended redirect-update semantics.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit b25c4be |
|
Code review by qodo was updated up to the latest commit f1525bd |
|
Code review by qodo was updated up to the latest commit abe353e |
… duplicate module copies in capsules
| static get workspaceConfigLoadingRegistry(): WorkspaceConfigLoadFunction | undefined { | ||
| return (globalThis as any)[workspaceConfigLoadingRegistryKey]; | ||
| } | ||
| static set workspaceConfigLoadingRegistry(func: WorkspaceConfigLoadFunction | undefined) { | ||
| (globalThis as any)[workspaceConfigLoadingRegistryKey] = func; | ||
| } |
There was a problem hiding this comment.
1. Stale global loader registry 🐞 Bug ☼ Reliability
WorkspaceConfig.workspaceConfigLoadingRegistry is now stored on globalThis, but loadBit.clearGlobalsIfNeeded() can early-return without clearing it; this allows a loader function bound to an older ConfigMain instance to persist and be used by Consumer.load() / LegacyWorkspaceConfig.loadIfExist(), returning cached/stale legacy workspace config for the same workspace path.
Agent Prompt
### Issue description
`workspaceConfigLoadingRegistry` is now persisted on `globalThis`, so it can survive module duplication (intended), but it also becomes a true process-global that can survive between multiple in-process `loadBit()` calls when `clearGlobalsIfNeeded()` returns early. When this happens, `LegacyWorkspaceConfig.loadIfExist()` can invoke a loader closure bound to a previous `ConfigMain`, which may return cached config for matching paths.
### Issue Context
- The loader is registered from `ConfigMain.provider()` and may return the already-loaded legacy config for the same `dirPath` (without re-reading files).
- `Consumer.load()` depends on `LegacyWorkspaceConfig.loadIfExist()`.
- `loadBit.clearGlobalsIfNeeded()` currently decides whether to clear global registries based only on `loadConsumer.cache` and `PackageJsonTransformer.packageJsonTransformersRegistry.length`.
### Fix Focus Areas
- scopes/harmony/bit/load-bit.ts[343-353]
- scopes/harmony/config/config.main.runtime.ts[126-151]
- components/legacy/consumer-config/workspace-config.ts[32-52]
- components/legacy/consumer/consumer.ts[487-505]
### Suggested fix
1) Update `clearGlobalsIfNeeded()` to also consider (and clear) `LegacyWorkspaceConfig.workspaceConfigLoadingRegistry` (and/or remove the early-return and always clear the snapshot list).
2) Optionally, when clearing the registry, delete the `globalThis` key (not just set it to `undefined`) to avoid lingering global properties and to allow GC of the old closure.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit b55288e |
Updates the node envs to their latest versions via
bit env update, scoped to just these two:@mdx-js/reactv3)