Skip to content

[IMP] owl: let Odoo override Owl without modifying it - #2075

Merged
mcm-odoo merged 2 commits into
masterfrom
master-patchable-owl-ged
Nov 24, 2026
Merged

mcm-odoo merged 2 commits into
masterfrom
master-patchable-owl-ged

Conversation

@ged-odoo

Copy link
Copy Markdown
Contributor

Odoo carries two modifications of Owl (on its migration branch) so that it can override parts of it. This PR makes them unnecessary.

Scheduler.processTasks can be patched. Each scheduler binds processTasks in its constructor and gives that bound function to requestAnimationFrame, so a patch of Scheduler.prototype.processTasks made after the scheduler was created is never called. Odoo patches it in its waitUntilIdle test helper. processTasks is now looked up at each frame.

The exports of the iife bundle can be overridden. The owl global defined by owl.iife.js and owl.iife.min.js holds the exports as getters generated by esbuild: assigning one is silently ignored (or throws in strict code). Odoo uses Owl through this global and overrides some of them. The build now replaces the global with a plain copy of the exports (owl = { ...owl }; as a footer).

Notes:

  • The scheduler change has a test, which fails without the fix.
  • The bundles are not covered by the test suite. Checked by loading the built owl.iife.js and owl.iife.min.js as scripts in jsdom: before, owl.onWillStart is a getter and assigning it has no effect; after, it is a writable value, all 57 exports are there, and a component still mounts and updates through the global.
  • Copying freezes the values of the exports, which is fine as no export is a live binding (export let). The ESM and CJS bundles are unchanged.
  • Compared to the commits on the migration branch, the bind in the Scheduler constructor is removed instead of commented out, and the two iife variants share the same footer.

Before this commit, each scheduler binds processTasks in its constructor
and gives that bound function to requestAnimationFrame, so a patch of
Scheduler.prototype.processTasks made after the scheduler was created is
never called. Odoo patches it in its waitUntilIdle test helper, and has
to modify Owl for that.

This commit looks processTasks up at each frame instead.
Before this commit, the `owl` global defined by the iife bundles holds
the exports as getters generated by esbuild: assigning one is silently
ignored (or throws in strict code). Odoo, which uses Owl through this
global, overrides some of them, and has to modify the build for that.

This commit replaces the global with a plain copy of the exports.
@mcm-odoo
mcm-odoo merged commit a12dbf5 into master Nov 24, 2026
2 checks passed
@mcm-odoo
mcm-odoo deleted the master-patchable-owl-ged branch November 24, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants