Skip to content

bundlers/obsidian-plugin-transforms

The source transforms every bundler adapter shares, so a feature compiles the same way whichever bundler runs it: Solid’s JSX, Svelte components and modules, stylesheets through PostCSS, Tailwind and CSS modules, and WebAssembly modules as bytes. The esbuild, rollup and vite adapters call them in-process; the webpack adapter through the loader it ships, and the parcel adapter through the transformers it generates.

Erasable TypeScript only (no enums, no parameter properties), so a webpack loader or a parcel worker can load this module straight from source when the toolkit runs from source.

Interface Description
LoadPostcssConfigParams Parameters for loadPostcssConfig.
PostcssConfig What loadPostcssConfig loaded.
SourceMapLike A source map, as the transforms hand it over: the decoded JSON of a version 3 source map.
TransformCssParams Parameters for transformCss.
TransformedCss The CSS transformCss produced.
TransformedModule A JavaScript module a transform produced.
TransformJsxParams Parameters for transformJsx.
TransformModuleParams Parameters of a transform that compiles one module.
Function Description
appendInlineSourceMap Appends a source map to a module’s code as an inline sourceMappingURL comment, which is how a bundler that reads a loaded file’s own source map takes it.
getCssModuleCode Builds the JavaScript module a CSS module’s import resolves to: its scoped class names, by their original ones, as the default export.
getWasmModuleCode Builds the JavaScript module a .wasm import resolves to: the WebAssembly module’s bytes as a Uint8Array default export, inlined as base64, because an Obsidian release ships main.js and nothing beside it.
loadPostcssConfig Loads the PostCSS plugins a stylesheet goes through, without the CSS-module scoping: the project’s PostCSS configuration when postcss is on, and Tailwind ahead of it when tailwind is on and the configuration does not already run it.
transformCss Runs a stylesheet through the pipeline its options ask for: the project’s PostCSS configuration, Tailwind, and the CSS-module scoping of a *.module.css file.
transformJsx Compiles a React or Preact JSX or TSX module with the automatic JSX runtime, for a bundler that does not take the runtime from the project’s tsconfig (parcel does not follow its extends).
transformSolid Compiles a Solid JSX or TSX module: esbuild strips the TypeScript and keeps the JSX, then babel-preset-solid compiles the JSX into DOM expressions.
transformSvelte Compiles a Svelte component (.svelte), with its styles injected by the component itself, or a Svelte module (.svelte.ts, .svelte.js), whose TypeScript esbuild strips first.
Type Description
TransformSolidParams Parameters for transformSolid.
TransformSvelteParams Parameters for transformSvelte.