-
-
Notifications
You must be signed in to change notification settings - Fork 339
Closed
Description
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
- Install
fast-xml-parser@5.3.1 - 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 extensionShould be:
import {trim} from '../valueParsers/trim.js'; // ✅ Correct ESM syntaxImpact
- 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:
- Fix ESM imports by adding
.jsextensions to all internal imports insrc/v6/ - Update package.json to properly export v6 API modules
- 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
Labels
No labels