Skip to content

fix: load factory synth presets without CommonJS require in the browser #1815

Description

@beejsbj

Description

Selecting a factory synth preset in the browser throws before the preset can be applied. loadSynthPreset calls CommonJS require("./uiStore") from the browser bundle, where require is not defined. Legacy preset identifiers such as piano, lead, strings, pad, and bass work because they bypass this action.

Tested commit: 2bebdd2cbaaef1092a06ff613c7868c9f3bd4b6c.

Steps to Reproduce

  1. Start the web app and create or select a piano-roll track.
  2. Open the synth preset browser.
  3. Select the factory preset Sub Bass (factory-sub-bass), or call:
window.__store.getState().loadSynthPreset(trackId, "factory-sub-bass")
  1. Inspect the console and the track state.

Expected Behavior

The selected factory preset is applied to the track and updates its instrument/preset fields without a runtime error.

Actual Behavior

The action throws:

ReferenceError: require is not defined

No factory preset is applied.

Environment

  • Browser: Google Chrome 147.0.7727.101 (headless Playwright)
  • OS: Ubuntu 24.04.3 LTS
  • Node version: 24.13.0
  • Audio path: web / Tone.js

Screenshots / Logs

loadSynthPreset invokes require("./uiStore") despite the project being ESM/browser code. The factory preset ID is defined in synthPresets.ts.

Acceptance Criteria

  • Selecting factory-sub-bass from the preset browser applies it without ReferenceError.
  • Calling loadSynthPreset(trackId, "factory-sub-bass") from the exposed store action updates the track deterministically.
  • Factory and user preset lookup still works in the browser build.
  • A browser-facing regression test covers loading at least one factory preset.
  • Fix passes all quality gates.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions