0.1.0-alpha3 • Published 1 year ago
@rlmcneary2/weko-routing v0.1.0-alpha3
@rlmcneary2/weko-routing
Runtime usage
As part of an ES module
Use "esm.sh" and import this module into a source file where you need to use routing.
import from "https://esm.sh/@rlmcneary2/weko-routing";
As part of a bundle
If you are bundling your source code you may need to use a dynamic import
to
load the library like so:
async function main() {
await import("https://esm.sh/@rlmcneary2/weko-routing");
}
Using a script element
The script can also be loaded in an HTML file, typically as part of the <head>
element.
<head>
<script src="https://esm.sh/@rlmcneary2/weko-routing" type="module"></script>
</head>
TypeScript support
To use Typescript during development you need to do three things.
- Install the package locally from npm under devDependencies:
npm i -D @rlmcneary2/weko-routing
. - Update the tsconfig.json file's
compilerOptions.paths
with the local installation of the package.
"paths": {
"@rlmcneary2/weko-routing": ["./node_modules/@rlmcneary2/weko-routing/src/index"]
}
- Create a
.d.ts
file somewhere in a path processed by tsconfig.json that declares a module for the remote address.
// remote.d.ts
// Allow all module names starting with "https://". This will suppress TS errors.
declare module "https://*";
// Map the URL to all the exports from the locally installed package.
declare module "https://esm.sh/@rlmcneary2/weko-routing" {
export * from "@rlmcneary2/weko-routing";
}
Build-time usage
Install from npm using npm i @rlmcneary2/weko-routing
.