6.46.8 • Published 4 days ago

@gasket/resolve v6.46.8

Weekly downloads
45
License
MIT
Repository
github
Last release
4 days ago

@gasket/resolve

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

Guides

Installation

npm i @gasket/redux

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
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
nonegasket-preset-<name><name>Any user presets with no scope

Fallbacks

To soften the transition of existing apps and plugins using the older postfixed format, the loader supports fallbacks for short names to postfixed format, and then to the @gasket scope. For example, if a short name of example is used, the package lookup order would be as follows:

example --> gasket-plugin-example --> example-gasket-plugin --> gasket/plugin-example --> gasket/example-plugin

For project and user scoped short names, the loader will fall-back to postfixed format as well. For example, if the short name @user/example is used:

@user/example --> @user/plugin-example --> @user/example-plugin

Use with caution, and don't rely on it. Consider this behavior deprecated, which will be removed in a future major release. Short names without the @gasket scope should be presumed to resolve to the gasket-plugin-<name> format.

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

7.0.0-next.21

4 days ago

7.0.0-next.9

9 days ago

7.0.0-next.10

9 days ago

7.0.0-next.7

9 days ago

7.0.0-next.11

9 days ago

7.0.0-next.8

9 days ago

7.0.0-next.12

9 days ago

7.0.0-next.13

9 days ago

7.0.0-next.6

9 days ago

7.0.0-next.20

9 days ago

7.0.0-next.5

10 days ago

6.46.8

11 days ago

7.0.0-next.4

12 days ago

7.0.0-next.3

16 days ago

7.0.0-next.2

23 days ago

7.0.0-next.1

24 days ago

7.0.0-next.0

24 days ago

7.0.0-cli.7

2 months ago

7.0.0-cli.6

2 months ago

6.46.1-cli.0

2 months ago

7.0.0-cli.5

2 months ago

7.0.0-cli.4

2 months ago

7.0.0-cli.1

2 months ago

7.0.0-cli.0

2 months ago

7.0.0-cli.3

2 months ago

7.0.0-cli.2

2 months ago

6.46.3-cli.0

2 months ago

6.46.2

2 months ago

7.0.0-canary.1

2 months ago

6.46.2-esm.0

3 months ago

6.46.2-esm.8

2 months ago

6.45.2

3 months ago

6.45.0

4 months ago

6.44.4

4 months ago

6.44.0

5 months ago

6.43.0

7 months ago

6.43.1

6 months ago

6.41.0

10 months ago

6.39.3

11 months ago

6.39.0

12 months ago

6.38.8

12 months ago

6.38.6

1 year ago

6.38.5

1 year ago

6.38.1

1 year ago

6.36.1

1 year ago

6.38.0

1 year ago

6.34.6

2 years ago

6.35.0

1 year ago

6.36.0

1 year ago

6.34.4

2 years ago

6.34.2

2 years ago

6.30.2

2 years ago

6.29.0

2 years ago

6.21.0

2 years ago

6.24.0

2 years ago

6.20.3

2 years ago

6.20.2

2 years ago

6.17.0

2 years ago

6.15.2

2 years ago

6.10.1

2 years ago

6.10.0

2 years ago

6.14.0

2 years ago

6.3.0

3 years ago

6.0.12

3 years ago

6.0.0

3 years ago

6.0.0-canary.13

3 years ago

6.0.0-canary.9

3 years ago

6.0.0-canary.8

3 years ago

6.0.0-canary.0

4 years ago

5.6.0

4 years ago

5.3.1

4 years ago

5.1.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-canary.4

4 years ago

5.0.0-canary.3

4 years ago

5.0.0-canary.2

4 years ago

5.0.0-canary.1

4 years ago

5.0.0-canary.0

4 years ago