trucks-resolver-npm

HTML import resolver for the npm: protocol

Usage no npm install needed!

<script type="module">
  import trucksResolverNpm from 'https://cdn.skypack.dev/trucks-resolver-npm';
</script>

README

NPM Resolver

HTML import resolver for the npm: scheme

Resolves HTML imports using the npm: scheme.

<link rel="import" href="npm://@ui/components@1.0.0">

Install

npm i trucks-resolver-npm --save-dev

For the command line interface see trucks-cli.



Usage

Register the npm protocol plugin:

const options {
  files: ['npm://@ui/components@1.0.0'],
  protocols: ['npm']
}

API

NpmResolver

Resolve npm: protocols.

NpmResolver

public NpmResolver()

Create an npm resolver.

resolve

public resolve(cb)

Resolve web component HTML imports from npm packages.

  • cb Function callback function.

getCanonicalPath

public getCanonicalPath()

Compute the canonical path for the file.

Returns an absolute file system path.

npm

public npm(state, conf)

Plugin for the npm resolver.

Registers the resolver class for the npm: protocol.

  • state Object compiler state.
  • conf Object plugin configuration object.

License

MIT


Created by mkdoc on July 22, 2016