Skip to content

[IMP] package: add exports map#1802

Merged
ged-odoo merged 1 commit intomasterfrom
master-package-exports-tso
Mar 2, 2026
Merged

[IMP] package: add exports map#1802
ged-odoo merged 1 commit intomasterfrom
master-package-exports-tso

Conversation

@ThanhDodeurOdoo
Copy link
Member

@ThanhDodeurOdoo ThanhDodeurOdoo commented Feb 21, 2026

for stable ESM/CJS resoluton

We currently have main + module but no exports map, which is the modern and compatible
way of exposing entry points in node modules.

so esm runtimes may import the wrong format from main, forcing lib consumers to understand the dist structure and import specific compatibles files or add local alias/mapping workarounds, which makes them more
sensitive to technical changes in owl.

So this commit add epxlicit package exports so resolution is determinisitic and only exposes what is intended for comsumption:

  • . -> import: ./dist/owl.es.js
  • . -> require: ./dist/owl.cjs.js
  • . -> types: ./dist/types/owl.d.ts
  • ./dist/* -> preserve deep imports (for example @odoo/owl/dist/compile_templates.mjs)
  • ./package.json -> preserve metadata access for tooling

This keeps existing public subpaths available and makes top-level @odoo/owl imports resolve to the expected format.

see:
https://nodejs.org/api/packages.html#conditional-exports
https://hirok.io/posts/package-json-exports

@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-package-exports-tso branch 3 times, most recently from e0f7bce to 6edfcee Compare February 21, 2026 10:56
for stable ESM/CJS resoluton

We currently have `main` + `module` but no `exports` map, which is the modern and compatible
way of exposing entry points in node modules.

so esm runtimes may import the wrong format from `main`, forcing lib consumers to understand the dist structure and import specific compatibles files or add local alias/mapping workarounds ([Example](https://github.com/ThanhDodeurOdoo/discuss-companion/pull/106/changes#diff-1e058ca1442e46581b13571fb8d261f9e1f5657e26c96634d4c1072f0f0347f1R10)), which makes them more
sensitive to technical changes in owl.

So this commit add epxlicit package `exports` so resolution is determinisitic and only exposes what is intended for comsumption:
- `.` -> `import: ./dist/owl.es.js`
- `.` -> `require: ./dist/owl.cjs.js`
- `.` -> `types: ./dist/types/owl.d.ts`
- `./dist/*` -> preserve deep imports (for example `@odoo/owl/dist/compile_templates.mjs`)
- `./package.json` -> preserve metadata access for tooling

This keeps existing public subpaths available and makes top-level `@odoo/owl` imports resolve to the expected format.
@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-package-exports-tso branch from 6edfcee to f2e419b Compare February 21, 2026 11:03
@ged-odoo ged-odoo marked this pull request as ready for review March 2, 2026 07:34
@ged-odoo ged-odoo merged commit 1c90d9b into master Mar 2, 2026
2 checks passed
@ged-odoo ged-odoo deleted the master-package-exports-tso branch March 2, 2026 07:34
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