Skip to content

v6 API: Missing ESM exports - broken module resolution #772

@ThePlenkov

Description

@ThePlenkov

Description

The v6 API source code exists in fast-xml-parser@5.3.1 at src/v6/, but it cannot be imported due to broken ESM module resolution. The internal imports are missing .js file extensions, causing module resolution failures.

Steps to Reproduce

  1. Install fast-xml-parser@5.3.1
  2. Try to import v6 API as documented:
import XMLParser from 'fast-xml-parser/src/v6/XMLParser.js';
import OutputBuilder from 'fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js';

const parser = new XMLParser({
  OutputBuilder: new OutputBuilder()
});

Error

With Node.js:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/node_modules/fast-xml-parser/src/v6/valueParsers/trim' 
imported from /path/to/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js

With Bun:

SyntaxError: Export named 'JsObjOutputBuilder' not found in module

Root Cause

The v6 source files use imports without .js extensions:

// In src/v6/OutputBuilders/ParserOptionsBuilder.js
import {trim} from '../valueParsers/trim'; // ❌ Missing .js extension

Should be:

import {trim} from '../valueParsers/trim.js'; // ✅ Correct ESM syntax

Impact

  • v6 API documentation (getting started guide) references code that doesn't work
  • Users cannot use the v6 API features like JsObjOutputBuilder
  • Forces users to fall back to v5 API

Workaround

Currently using v5 API with configuration options:

import { XMLParser } from 'fast-xml-parser';
const parser = new XMLParser({
  ignoreAttributes: false,
  attributeNamePrefix: '@_',
  // ... other options
});

Environment

  • Package version: fast-xml-parser@5.3.1
  • Node.js: v24.10.0
  • Bun: v1.3.1
  • OS: Linux (WSL2)

Suggestion

Either:

  1. Fix ESM imports by adding .js extensions to all internal imports in src/v6/
  2. Update package.json to properly export v6 API modules
  3. Mark v6 as experimental/unstable in documentation until it's production-ready

🤖 AI-assisted via Claude Code
Generated: 2025-11-12T17:01:00Z

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