Skip to content

Broken internal import (require("src/exposure/exposure")) fails with esbuild / Angular 21 #62

@igor-stasiv

Description

@igor-stasiv

Expected Behavior

The package should build successfully in modern bundlers (esbuild, Vite, Angular 21) without module resolution errors.
All internal imports in the published build output should resolve correctly using valid relative paths.

Current Behavior

The build fails with the following error:

Could not resolve "src/exposure/exposure"

node_modules/@amplitude/experiment-node-server/dist/src/local/client.js:81:27
  81 │ const exposure_1 = require("src/exposure/exposure");

The compiled file contains an invalid internal imports:

require("src/exposure/exposure");
require("src/exposure/exposure-filter");
require("src/exposure/exposure-service");

The issue appeared after upgrading build tooling to Angular 21 (esbuild-based).

Possible Solution

Fix the internal imports in the compiled output to use a valid relative path, for example:

require("../exposure/exposure");

This issue is exposed by stricter, spec-compliant bundlers and affects any esbuild-based setup.

Steps to Reproduce

  1. Create a project using Angular 21 (or any esbuild-based bundler)
  2. Install @amplitude/experiment-node-server
  3. Import the package (directly or transitively) in the project
  4. Run the build
    The build fails during module resolution.

Environment

  • JS Server SDK Version: latest at time of writing (also reproducible with previous versions)
  • Installation Method: npm
  • Browser and Version: N/A (build-time error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions