Skip to content

getParcelOptions

Builds the options handed to parcel’s Parcel class.

The one target is electron-renderer, where Obsidian runs a plugin, and CommonJS. Parcel counts that context as both a browser and a node one: node keeps process, Buffer and process.env as Obsidian’s renderer has them, rather than polyfilled or inlined from the build machine, and browser takes a package’s browser field. Its export conditions would include node too, which the generated resolver drops. includeNodeModules bundles the dependencies, which a node-flavoured context would otherwise leave as require() calls nothing installs beside a plugin, and isLibrary keeps the entry’s default export, which is how Obsidian finds the plugin class.

shouldScopeHoist is set explicitly because parcel reads it only from defaultTargetOptions for a target passed in the options, never from isLibrary as it does for one in package.json. Without it the bundle is not tree-shaken at all: Svelte’s fixture build was 224 KB with parcel against 25 KB with vite.

Import:

import { getParcelOptions } from '@mnaoumov/obsidian-dev-toolkit/bundlers/parcel';

Signature:

function getParcelOptions(params: GetParcelOptionsParams): InitialParcelOptions

Parameters:

Parameter Type Description
params GetParcelOptionsParams The GetParcelOptionsParams.

Returns: InitialParcelOptions — The parcel options.


Links to this page: