Skip to main content

registerWebdaPackage

@webda/utils


Function: registerWebdaPackage()

registerWebdaPackage(name, url, version?): void

Defined in: packages/utils/src/packages.ts:114

Register a @webda/* package, called from the entry of each package

Webda relies on a single instance of each package: classes are used as keys (repositories) or matched with instanceof (WebdaQL expressions), so a second copy of a package breaks later in ways that do not point at the cause. Loading the same package from two different paths throws, even when both copies have the same version.

Evaluating the same path again (test runners reloading modules) is allowed. Set WEBDA_ALLOW_DUPLICATE_PACKAGES=1 to log an error instead of throwing.

Parameters​

name​

string

package name

url​

string

import.meta.url of the package entry

version?​

string

package version, read from the package.json when needed if omitted

Returns​

void

Throws​

Error if the package is already registered from a different path