Registry /
data / prettier-plugin-pdx-script
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import prettierPluginPdxScript from 'prettier-plugin-pdx-script'
✗ const prettierPluginPdxScript = require('prettier-plugin-pdx-script')
Default import works for ESM. For CJS, use require('prettier-plugin-pdx-script'). The plugin is auto-discovered by Prettier; explicit import only needed for programmatic use.
resetParser
✓ import { resetParser } from 'prettier-plugin-pdx-script'
✗ import resetParser from 'prettier-plugin-pdx-script/resetParser'
Exported since v0.1.0-rc.5. Used to reset parser state (e.g., between files).
disposeParser
✓ import { disposeParser } from 'prettier-plugin-pdx-script'
✗ import { dispose } from 'prettier-plugin-pdx-script'
Exported since v0.1.0-rc.5. Cleanup function for parser resources.
getGrammarWasmPath
✓ import { getGrammarWasmPath } from 'prettier-plugin-pdx-script'
✗ import { getWasmPath } from 'prettier-plugin-pdx-script'
Exported since v0.1.0-rc.5. Returns path to WASM grammar file for custom loading.
PARSER_NAME
✓ import { PARSER_NAME } from 'prettier-plugin-pdx-script'
✗ const PARSER_NAME = 'pdx-script'
Exported constant with parser name, useful for language detection.
Quickstart: install, CLI usage, and programmatic formatting with Prettier and the PDXScript plugin.
// Install: npm install --save-dev prettier prettier-plugin-pdx-script
// Format via CLI:
// npx prettier --write "path/to/**/*.txt"
// Programmatic usage:
import prettier from 'prettier';
const code = `my_declaration={
key1= value1
nested={
inner_key = "hello world"
}
# a comment
}
`;
const formatted = await prettier.format(code, {
parser: 'pdx-script',
plugins: ['prettier-plugin-pdx-script'],
tabWidth: 4 // Not used; plugin uses tabs
});
console.log(formatted);
// Output:
// my_declaration = {
// \tkey1 = value1
// \tnested = {
// \t\tinner_key = "hello world"
// \t}
// \t# a comment
// }
Debug
Known issues
breakingPre-1.0 breaking changes in minor/pre-release versions. API surface may change without major version bump.fixPin exact version in package.json. Check changelog before upgrading.
affects: >=0.1.0-rc.2 <1.0.0
gotchaLarge files (2000+ AST nodes) may cause out-of-memory errors in versions prior to v0.1.0-rc.6 due to double traversal bug.fixUpgrade to v0.1.0-rc.6 or later which fixed the double map in convertTree().
affects: >=0.1.0-rc.2 <0.1.0-rc.6
deprecatedPrior to v0.1.0-rc.5, the only export was the default plugin. Utility functions (resetParser, disposeParser) were internal.fixUse default import only for plugin. Upgrade to v0.1.0-rc.5+ if programmatic parser management needed.
affects: <0.1.0-rc.5
gotchaCJS require() may load wrong entry point in older Node versions without proper 'exports' field support. Use Node 18+ or ESM import.fixUse dynamic import or upgrade Node to >=18. In tsconfig, set moduleResolution to bundler or node16.
affects: >=0.1.0-rc.2
gotchaPlugin automatically discovers .txt files; ensure they are PDXScript files, not other text formats, or Prettier may misparse.fixSpecify parser explicitly: 'prettier --parser pdx-script file.txt' or configure overrides in .prettierrc: { 'overrides': [{ 'files': '*.txt', 'options': { 'parser': 'pdx-script' } }] } affects: >=0.1.0-rc.2
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '.../node_modules/prettier-plugin-pdx-script/dist/grammar.wasm'
WASM grammar file not found or not bundled correctly; file may be missing after npm install due to npm ignore or broken build.
fixReinstall plugin: npm install prettier-plugin-pdx-script@latest. If using npm <7, ensure peer dependencies are met. Alternatively, set custom WASM path via getGrammarWasmPath().
Error: Cannot find module 'prettier-plugin-pdx-script' from '...'
Plugin not installed or Prettier not configured to resolve the plugin.
fixInstall as devDependency: npm install --save-dev prettier-plugin-pdx-script. Prettier auto-discover should work; if not, add plugins array in .prettierrc: { 'plugins': ['prettier-plugin-pdx-script'] } TypeError: Cannot read properties of undefined (reading 'children')
Invalid PDXScript syntax causing tree-sitter parser to return undefined or incomplete AST.
fixCheck input file for syntax errors (unclosed blocks, invalid keys). The plugin relies on valid PDXScript grammar.
Heap out of memory (FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory)
Likely the double traversal bug in versions <0.1.0-rc.6 causing memory explosion on files with 2000+ nodes.
fixUpgrade to v0.1.0-rc.6 or later. If already on that version, the file is extremely large; increase Node heap size: NODE_OPTIONS='--max-old-space-size=8192' prettier --write file.txt
Audit
Dependencies
prettieroptionalPeer dependency required to use the plugin; Prettier must be installed separately.