fix(hoot-dom): static/src alias file approach
This commit is contained in:
@@ -118,30 +118,59 @@ spec:
|
||||
args:
|
||||
- |
|
||||
set -eu
|
||||
mkdir -p /target/odoosky_hoot_dom_shim
|
||||
mkdir -p /target/odoosky_hoot_dom_shim/static/src
|
||||
: > /target/odoosky_hoot_dom_shim/__init__.py
|
||||
# Investigated three approaches before settling on this one:
|
||||
#
|
||||
# 1. Drop the hoot-dom lib files into web.assets_backend
|
||||
# (`web/static/lib/hoot-dom/**/*`). They got bundled
|
||||
# but the asset compiler registered them under their
|
||||
# path-based names (`@web/../lib/hoot-dom/hoot-dom`)
|
||||
# and ignored the `@odoo-module alias=@odoo/hoot-dom`
|
||||
# directive — that directive only fires for files
|
||||
# under `static/src/`, not `static/lib/`. Bundle grew,
|
||||
# `@odoo/hoot-dom` still undefined.
|
||||
# 2. Add `web/static/tests/_framework/hoot_module_loader.js`
|
||||
# on top of #1 (mirror of upstream assets_unit_tests_setup).
|
||||
# Same outcome — the loader patches `odoo.define` for
|
||||
# follow-on hoot test files but doesn't register the
|
||||
# canonical alias.
|
||||
# 3. (this) Inject a tiny alias file under our addon's
|
||||
# `static/src/` that bridges the two names with a
|
||||
# plain `odoo.define` call. The lib files are already
|
||||
# in the prod bundle (the broken manifest puts them
|
||||
# only in unit_tests_setup, but Odoo's barcode/tour
|
||||
# code in static/src/ references them so they get
|
||||
# pulled in transitively); the alias file just
|
||||
# re-exports them under the canonical name production
|
||||
# code asks for.
|
||||
cat > /target/odoosky_hoot_dom_shim/static/src/hoot_dom_alias.js <<'JSEOF'
|
||||
/** @odoo-module ignore */
|
||||
// OdooSky platform shim: register `@odoo/hoot-dom` as an
|
||||
// alias for the path-based module the asset compiler
|
||||
// produces from web/static/lib/hoot-dom/hoot-dom.js.
|
||||
// Without this, prod source files in barcodes / sale /
|
||||
// web_tour that `import '@odoo/hoot-dom'` fail to bootstrap
|
||||
// because no module is registered under that name in the
|
||||
// production bundle.
|
||||
odoo.define(
|
||||
"@odoo/hoot-dom",
|
||||
["@web/../lib/hoot-dom/hoot-dom"],
|
||||
function (require) {
|
||||
return require("@web/../lib/hoot-dom/hoot-dom");
|
||||
}
|
||||
);
|
||||
JSEOF
|
||||
cat > /target/odoosky_hoot_dom_shim/__manifest__.py <<'PYEOF'
|
||||
{
|
||||
'name': 'OdooSky hoot-dom backend shim',
|
||||
'version': '18.0.1.0.1',
|
||||
'version': '18.0.1.0.2',
|
||||
'category': 'Hidden',
|
||||
'summary': 'Inject hoot/hoot-dom + module loader into web.assets_backend (workaround for upstream manifest bug)',
|
||||
'summary': 'Register @odoo/hoot-dom alias in web.assets_backend (workaround for upstream alias-not-honored bug)',
|
||||
'depends': ['web'],
|
||||
# Mirror the asset list from web.__manifest__.py's
|
||||
# assets_unit_tests_setup bundle. The loader at the
|
||||
# end registers each lib file as an `@odoo/hoot-dom`
|
||||
# module — without it, the bare lib files don't
|
||||
# define themselves as the dependency name production
|
||||
# code references. We exclude the same test artifacts
|
||||
# the upstream bundle excludes (hoot_style.css +
|
||||
# hoot/tests).
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
'web/static/lib/hoot/**/*',
|
||||
'web/static/lib/hoot-dom/**/*',
|
||||
('remove', 'web/static/lib/hoot/ui/hoot_style.css'),
|
||||
('remove', 'web/static/lib/hoot/tests/**/*'),
|
||||
'web/static/tests/_framework/hoot_module_loader.js',
|
||||
'odoosky_hoot_dom_shim/static/src/hoot_dom_alias.js',
|
||||
],
|
||||
},
|
||||
'installable': True,
|
||||
|
||||
Reference in New Issue
Block a user