Socket
Socket
Sign inDemoInstall

@gasket/resolve

Package Overview
Dependencies
Maintainers
8
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gasket/resolve

Essential module resolution & configuration management for gasket plugins & presets.


Version published
Weekly downloads
115
increased by134.69%
Maintainers
8
Weekly downloads
 
Created
Source

@gasket/resolve

Essential module resolution and configuration management for Gasket plugins and presets.

Guides

  • API docs

Installation

npm i @gasket/resolve

Naming convention

Plugins and presets should adhere to the project-type prefixed naming convention. This formatting allows user plugins to be referenced with short names and will help avoid collisions. This convention also mimics those by other projects such a @babel and @oclif.

Plugins

scopeformatshortdescription
project@gasket/plugin-<name>@gasket/<name>Official Gasket project plugin
user@<scope>/gasket-plugin-<name>@<scope>/<name>Any user plugins with a scope
user@<scope>/gasket-plugin@<scope>Scope-only user plugins
nonegasket-plugin-<name><name>Any user plugins with no scope

Presets

scopeformatshortdescription
project@gasket/preset-<name>@gasket/<name>Official Gasket project preset
user@<scope>/gasket-preset-<name>@<scope>/<name>Any user presets with a scope
user@<scope>/gasket-preset@<scope>Scope-only user presets
nonegasket-preset-<name><name>Any user presets with no scope

Utilities

There are util functions for creating objects for working with different parts of package identifiers for plugins and presets.

const { pluginIdentifier } = require('@gasket/resolve');

// if given a raw name as full package name with version...
let identifier = pluginIdentifier('@gasket/plugin-example@^1.2.0');

console.log(identifier.longName);   // @gasket/plugin-example
console.log(identifier.shortName);  // @gasket/example
console.log(identifier.version);    // ^1.2.0

// if given a raw name as short name...
identifier = pluginIdentifier('@gasket/example');
console.log(identifier.longName);   // @gasket/plugin-example
console.log(identifier.shortName);  // @gasket/example
console.log(identifier.version);    // null

See the API docs for more details on the pluginIdentifier and presetIdentifier util functions.

Loading

While this package is mostly intended for gasket project internals, if a plugin does need to load or resolve modules, a configured Loader instance is available as gasket.loader from the engine instance passed as the first argument to all lifecycle hooks.

// @my/gasket-plugin-example.js

 module.exports = {
  hooks: {
    someLifecycleHook: async function (gasket) {
      const moduleInfo = await gasket.loader.loadModule('@some/package');
      const module = gasket.loader.tryRequire('some-other-package'); 
    }   
  }
}

License

MIT

Keywords

FAQs

Package last updated on 14 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc