`@palamedes/transform`
@palamedes/transform exposes the low-level macro transformer used by the plugins.
Page outline
@palamedes/transform
transformPalamedesMacros() also accepts .vue source: it transforms macros
inside inline <script> and <script setup> blocks, preserving the surrounding
SFC and a source map to the original file. Setup blocks execute per component
instance, so direct setup-level macro calls are valid. Normal script blocks
retain the function-scope requirement. The shared default filter below remains
JavaScript/TypeScript; the Vite adapter additionally includes .vue files.
Exports
transformPalamedesMacros(source, filename, options?)mightContainPalamedesMacros(source)findMacroImports(program)resolveMacroRuntimeModule(runtimeModule?)mdxFrameworkFor(framework)PALAMEDES_MACRO_PACKAGESPALAMEDES_BUNDLER_TRANSFORM_INCLUDE— shared Vite/Next default covering.ts,.tsx,.js,.jsx,.mts,.cts,.mjs, and.cjsJS_MACROSJSX_MACROSTransformOptionsTransformResultSourceMapcreateCatalogLoaderResult(result, options)renderCatalogModule(messages)createCompileErrorMessage(locale, diagnostics)createDiagnosticMessage(locale, diagnostics)createMissingErrorMessage(locale, missingMessages)CatalogCompileArtifactResultCatalogDiagnosticCatalogLoaderOptionsCatalogLoaderResultCatalogSourceKeyMissingCatalogMessagePalamedesFramework
findMacroImports() expects a parsed AST program, not a source string. Use
mightContainPalamedesMacros(source) as the cheap string pre-check before
parsing.
resolveMacroRuntimeModule() selects the runtime import used by generated
macro calls (default @palamedes/runtime). PalamedesFramework is "react",
"solid", or "none"; mdxFrameworkFor() maps it to the optional React or
Solid setting understood by MDX compilation.
The @palamedes/transform/catalog-loader subpath exports compatibility helpers
for custom bundlers that already consume compiled catalog artifacts. The
first-party loaders call @palamedes/core-node directly, and
renderCatalogModule() delegates to that same native generator.
Generated catalog modules import defineCompiledCatalog() from
@palamedes/core/compiled, so custom integrations must install
@palamedes/core as a direct runtime dependency.
Most apps should use a framework plugin instead of this package directly.
Runtime fallback options
includeSourceMetadata defaults to false here. It only controls diagnostic
source metadata in generated calls. Set includeSourceMetadata: true to add
authored source text; the default keeps output compact. The v1
keepSourceFallbacks name throws a migration error.
V2 package roots and compiled aliases both throw on missing compiled entries;
retained metadata never supplies replacement message output. Valid translation
fallbacks are resolved and compiled at build time.
The v1 inverse option stripMessageField was removed and also throws a
migration error. Use includeSourceMetadata instead.