Skip to content

feat: support @ui5-ignore-import and @ui5-no-wrap pragma - #154

Merged
petermuessig merged 4 commits into
ui5-community:mainfrom
bbogovich-sap:feature/no-wrap-pragma
Aug 22, 2026
Merged

feat: support @ui5-ignore-import and @ui5-no-wrap pragma#154
petermuessig merged 4 commits into
ui5-community:mainfrom
bbogovich-sap:feature/no-wrap-pragma

Conversation

@bbogovich-sap

Copy link
Copy Markdown
Contributor

Adds support for pragma comments to allow the use of ESM imports and suppress addition of UI5 module wrappers. The purpose is to allow web workers in a UI5 project to be implemented in TypeScript, and to add support for WASM module loading.

@ui5-no-wrap

If present at the start of a file, indicates to the babel transpile that the file must not be wrapped in a sap.ui.define call. This supports the web worker use case - since worker scripts do not have access to the UI5 SDK, sap.ui.define is unsupported. This prevented workers from being implemented in TypeScript since the tooling treated them as modules.

@ui5-ignore-import

This pragma comment will cause the babel transpile to preserve an import statement on the next line instead of converting it to a sap.ui.require call. This is provided to support loading ESM modules, including web assembly code.

bbogovich-sap and others added 4 commits August 13, 2026 14:58
Extends the @ui5-ignore-import pragma to cover import() call expressions
in addition to static import declarations. A block comment placed on the
containing statement prevents the call from being rewritten to
__ui5_require_async().

The pragma check walks to the statement parent via
path.getStatementParent() because Babel attaches leading comments to the
containing statement node, not to the CallExpression itself.

Also fixes the static import handling: ignored imports are now left in
place (early return, no path.remove()) so they appear inside the define
callback body rather than being hoisted before it.
Add a README section covering the two new opt-out pragmas and a changeset
(minor) for the feature. Includes a warning that @ui5-ignore-import on a
static import only produces valid output in an unwrapped module.
docs: document @ui5-no-wrap and @ui5-ignore-import pragmas

@petermuessig petermuessig 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

@petermuessig
petermuessig merged commit f62f9fb into ui5-community:main Aug 22, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 22, 2026
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