PopClip JavaScript API Reference
    Preparing search index...

    Function require

    • Loads a module or data file. The argument is resolved as follows:

      • starting with ./ or ../: a path relative to the current file;
      • otherwise: a path relative to the root of the package directory;
      • failing that: the name of one of the libraries bundled with PopClip.

      Loads .js (CommonJS), .ts (ES module syntax, transpiled) and .json files. Results are cached, so requiring the same argument twice returns the same instance. Returns undefined if nothing is found. Paths beginning with /, or using .. to escape the package directory, are not valid.

      TypeScript files may use import syntax instead; it is transpiled to require() calls.

      Parameters

      • id: BundledModule

        Module name, or path to a file in the package.

      Returns any

    • Loads a module or data file. The argument is resolved as follows:

      • starting with ./ or ../: a path relative to the current file;
      • otherwise: a path relative to the root of the package directory;
      • failing that: the name of one of the libraries bundled with PopClip.

      Loads .js (CommonJS), .ts (ES module syntax, transpiled) and .json files. Results are cached, so requiring the same argument twice returns the same instance. Returns undefined if nothing is found. Paths beginning with /, or using .. to escape the package directory, are not valid.

      TypeScript files may use import syntax instead; it is transpiled to require() calls.

      Parameters

      • id: string

        Module name, or path to a file in the package.

      Returns any