Skip to content

WebPack audio worklet chunk causes browser error (NextJS) #2299

Description

@Danielku15

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When bundling alphaTab with WebPack, and starting the playback, a browser error occurs:

:3001/_next/static/chunks/_app-pages-browser_node_modules_coderline_alphatab_dist_alphaTab_worklet_mjs.js:726 Uncaught ReferenceError: _N_E is not defined

Expected Behavior

No errors should occur in the alphaTab outputs using the WebPack plugin.

Steps To Reproduce

  1. https://github.com/CoderLine/alphaTabSamplesWeb/tree/main/src/webpack-nextjs-15
  2. npm install && npm run dev
  3. Hit play

Link to jsFiddle, CodePen, Project

No response

Version and Environment

[AlphaTab][VersionInfo] alphaTab 1.6.2
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] commit: 7a3395e57a19e6e78397974ab295db87b6cc7bff
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] build date: 2025-08-23T16:08:14.997Z
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] High DPI: 3
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] Platform: Browser
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] WebPack: true
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] Vite: false
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] Window Size: 1286x640
alphaTab.core.mjs:2518 [AlphaTab][VersionInfo] Screen Size: 1366x768

Platform

Web

Anything else?

The problem is:

  1. Audio worklets run in strict mode
  2. WebPack generates code which assigns the exports of this entry chunk to a global variable due to some global library settings which might be active. https://github.com/webpack/webpack/blob/main/lib/library/AssignLibraryPlugin.js#L14

We need to ensure that these Worker/Worklet output chunks do not cause such an assignment by setting the entryOptions accordingly.

Metadata

Metadata

Assignees

Labels

area-bundlersRelated to the bundler plugins like webpack and viteplatform-javascriptRelated to the JavaScript version of alphaTabstate-acceptedThis is a valid topic to work on.

Type

Fields

Priority

None yet

Effort

None yet

Area

None yet

Platform

None yet

Work State

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions