Skip to content

fix(builder): Improve error ESM handling#1374

Merged
RandomByte merged 3 commits into
mainfrom
lbt-improvements-upport
May 8, 2026
Merged

fix(builder): Improve error ESM handling#1374
RandomByte merged 3 commits into
mainfrom
lbt-improvements-upport

Conversation

@RandomByte

@RandomByte RandomByte commented May 8, 2026

Copy link
Copy Markdown
Member

Up-port of SAP/ui5-builder#1203

  • fix(builder): Reduce noise from ESM parse errors
  • fix(builder): Skip ESM modules during bundling and log errors
  • fix(builder): Also detect import.meta as ESM indicator

@RandomByte RandomByte changed the title lbt improvements upport [FIX] Bundler: Improve error ESM handling May 8, 2026
matz3 added 3 commits May 8, 2026 14:55
Change the log level for JS parse failures in determineDependencyInfo
from error to verbose. These parse errors occur frequently when a
library contains third-party ESM code (using import/export), which the
LBT bundler does not support. Since these modules are typically not
included in custom bundles, logging at error level creates unnecessary
noise for users.

Errors during actual bundling (e.g. writePreloadModule) are still
reported at the appropriate level.
ESM modules (using import/export) cannot be bundled with the
LBT bundler. Previously, including an ESM module in a preload
section caused the bundle to contain a literal "undefined" string
due to rewriteDefine() returning {} instead of null on parse error.

- Add Format.ESM to ModuleInfo and detect ESM in ResourcePool
  during dependency analysis
- Filter out ESM modules during bundle resolution in Resolver,
  so they are excluded from all section types
- Exclude ESM modules from bundle subModule metadata
- Fix rewriteDefine() to return null on parse error (safety fix)
Modules using import.meta (e.g. import.meta.url, import.meta.resolve)
were not detected as ESM because only the 'import'/'export' parse error
was checked. Now also handle the 'Cannot use import.meta outside a
module' error from espree.
@RandomByte RandomByte force-pushed the lbt-improvements-upport branch from b2992cf to b312316 Compare May 8, 2026 12:58
@RandomByte RandomByte changed the title [FIX] Bundler: Improve error ESM handling fix(Bundler): Improve error ESM handling May 8, 2026
@RandomByte RandomByte requested a review from matz3 May 8, 2026 13:14
@matz3 matz3 changed the title fix(Bundler): Improve error ESM handling fix(builder): Improve error ESM handling May 8, 2026

@matz3 matz3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I updated the PR title and commit messages in the PR body.

@RandomByte RandomByte merged commit 5d1dcb7 into main May 8, 2026
30 checks passed
@RandomByte RandomByte deleted the lbt-improvements-upport branch May 8, 2026 15:08
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