configuration options for the npmSpecifierPluginSetup and npmSpecifierPlugin functions.

interface NpmSpecifierPluginSetupConfig {
    specifiers: string[];
    globalImportMap?: ImportMap;
    resolvePath: (...segments: string[]) => string;
    sideEffects: boolean | "auto" | "defaultFalse" | "defaultTrue";
    autoInstall: boolean;
}

Properties

specifiers: string[]

provide a list of prefix specifiers used for npm packages.

["npm:"]

globalImportMap?: ImportMap

{@inheritDoc CommonPluginResolverConfig.globalImportMap}

resolvePath: (...segments: string[]) => string

{@inheritDoc CommonPluginResolverConfig.resolvePath}

sideEffects: boolean | "auto" | "defaultFalse" | "defaultTrue"

specify the side-effects potential of all npm-packages.

  • true: this would mark all packages as having side-effects, resulting in basically no tree-shaking (large bundle size).
  • false: this would mark all packages being side-effects free, allowing for tree-shaking to take place and reducing bundle size.
  • "auto": this would let esbuild decide which packages are side-effect free, by probing into the package's package.json file and searching for the "sideEffects" field. however, since many unseasoned package authors do not know about this field (i.e. me), the lack of it makes esbuild default to false. which is in effect results in a larger bundled code size.

TODO: in the future, I would like to probe into the package.json file of the package myself (by deriving its path from the resolved_path), and then determine weather or not the "sideEffects" field is actually present. if it isn't then we will default to false if this config option is set to "defaultFalse", or default to true if this config option is set to "defaultTrue". (esbuild exhibits the "defaultTrue" behavior by default anyway, so this specific option selection will be kind of redundant). TODO: since in effect the "auto" option is equivalent to "defaultTrue", I'm uncertain whether I should even keep the "auto" option.

"auto"

autoInstall: boolean

auto install missing npm-package (the executed action/technique will vary based on the js-runtime-environment).

TODO: needs to be implemented. see details in /todo.md, under pre-version 0.2.0.

true