Registry / data / prettier-plugin-pdx-script

prettier-plugin-pdx-script

JSON →
library0.1.0-rc.6jsnpmunverified

A Prettier plugin for formatting PDXScript files used by Paradox Interactive games (Victoria 3, Hearts of Iron IV, Stellaris, etc.). v0.1.0-rc.6, pre-release with pre-1.0 API. Uses tree-sitter WASM parser for reliable parsing and applies opinionated formatting rules (tab indentation, operator preservation, comment handling). Ships dual CJS/ESM builds and TypeScript types. Differentiates from manual formatting by providing automated, consistent formatting via Prettier ecosystem. Key design: converts tree-sitter AST to plain objects for Prettier traversal.

npm install prettier-plugin-pdx-script
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-PD
P
prettier-plugin-pdx-script
datajavascriptv0.1.0-rc.6
harness data pending
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.
fix
Pin 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.
fix
Upgrade 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.
fix
Use 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.
fix
Use 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.
fix
Specify 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.
fix
Reinstall 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.
fix
Install 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.
fix
Check 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.
fix
Upgrade 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
Upgrade
Version history
0.1.0-rc.6latest on npm
Audit
Dependencies
prettieroptionalPeer dependency required to use the plugin; Prettier must be installed separately.
Agent activity
2 hits · last 30 days
node
2
Resources
prettier-plugin-pdx-script — npm install prettier-plugin-pdx-script · libregistry