npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@knot/compiler

v1.10.0

Published

[![npm](https://img.shields.io/npm/v/@knot/compiler?style=flat-square)](http://npm.im/@knot/compiler) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![lerna](

Downloads

15

Readme

@knot/compiler

npm code style: prettier lerna semantic-release Commitizen friendly standard-readme compliant

CircleCI

A command-line wrapper for the knot compiler. The version of this package aligns with the version of the compiler binary that is downloaded. Exports the path to the downloaded knotc binary. Currently the compiler only supports Windows and MacOS.

The Knot Language compiler can be run as both:

  • a stand-alone static compiler that scans a project directory structure and outputs
  • a server which can dynamically re-compile modules within a project, but depends on a client to control it

To get started using it in a project you will probably want to use one of the provided bundler plugins:

Or you can use the knot CLI tool (@knot/cli) to generate a new project with the minimum required boilerplate.

The source code for the compiler that is wrapped by this package can be found here;

Table of Contents

Install

npm install @knot/compiler
# or
yarn add @knot/compiler

Usage

Node.js Usage

path: string

The path to the installed binary.

import { path } from '@knot/compiler';

path; // path to the knotc binary

isKnot: (fileName: string) => boolean

Test whether a file has the file extension .kn or .knot.

import { isKnot } from '@knot/compiler';

isKnot('someFile.js'); // false
isKnot('knotFile.kn'); // true
isKnot('otherFile.knot'); // true

Compiler: class KnotCompiler

A client for connecting to and managing an instance of the knot compiler.

import Compiler from '@knot/compiler';

const compiler = new Compiler({});

// add a file to the compiler
await compiler.add('./someFile.kn');

// wait for the file to be compiled
await compiler.awaitModule('./someFile.kn');

// receive the comiled file contents
const compiled = await compiler.generate('./someFile.kn');

// kill the compiler server and end the connection
await compiler.close();

CLI Usage

If you install the package globally, you should be able to invoke the knotc binary installed by this package. If you install it locally, you can invoke it from a script in your package.json file, by running yarn exec <cmd> or in a variety of other ways.

knotc -help
# or
yarn exec knotc -- -help

CLI Arguments

  • -server: run the compiler in server mode
  • -config: specify a path to the directory containing the .knot.yml file to load
  • -port: specify a port for the compiler to run on, by default it runs on :1338
  • -debug: print verbose logs
  • -help: print usage information

Maintainers

@effervescentia

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2019 Ben Teichman