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 🙏

© 2025 – Pkg Stats / Ryan Hefner

domture

v1.4.1

Published

load packages and scripts on jsdom

Readme

domture

NPM version NPM downloads Build status Codecov Coverage Status

Greenkeeper Semantic Release

Visual Studio Code Wallaby.js

domture allows you to load packages and scripts directly on a jsdom instance for testing purpose.

You can load npm packages as well as local files (by default relative to current working directory .).

domture supports two loaders: systemjs and webpack.

When using systemjs, it leveages systemjs magic to load any type of module files. However, certain NodeJS resolution does not work currently, and also code coverage is not available.

When using webpack, it bundles the files you try to import with webpack and load them into jsdom through script tags. The NodeJS resolution is complete and code coverage is (will be) available. However, additional bundle time is needed and bundles management still need to be planned out and implemented in the future. You also lost the magic from systemjs.

By default, webpack will be used as the default loader.

For projects using webpack@4, please use domture@2. For webpack@3, please use domture@1

Usage

import test from 'ava' // or your favorite test runner
import { createDomture } from 'domture'

test('basic usage', async t => {
  const domture = await createDomture()

  // load package `foo`
  const foo = await domture.import('foo')

  // load by relative path
  const config = await domture.import('./config')
})

test('customize', async t => {
  const domture = await createDomture({
    // Where to resolve relative path.
    rootDir: './lib',
    // Preload some scripts ahead of time.
    preloadScripts: ['a-package', './someCode.js', './index'],
    // Able to load TypeScript code directly
    transpiler: 'typescript',
    // configure jsdom.
    // Can't set `url` and `runScripts`.
    // They are used internally.
    jsdomConstructorOptions: { ... }
  })
})
test('customize with webpack', async t => {
  const domture = await createDomture({
    /**
     * devtool, entry, and output are preserved
     */
    webpackConfig: {
      // ...
    }
  })
})

test('customize with systemjs', async t => {
  const domture = await createDomture({
    loader: 'systemjs',
    // Indicates which extension to try during `import()`
    // This is needed only if you need to do something special,
    // e.g. `allowJs` with TypeScirpt project.
    // By default, `domture` will look for 'js' and 'jsx` for JavaScript projects,
    // 'ts', 'tsx' for TypeScript projects.
    moduleFileExtensions: ['ts', 'js']
    systemjsConfig: {
      packages: {
        // This is need for some packages due to https://github.com/systemjs/systemjs/issues/1603
        'make-error': {
          main: 'index'
        }
      },
      meta: {
        // Do this if `some-global-script.js` is not detected correctly as global script when using `import()`.
        'some-global-script.js': {
          format: 'global'
        }
      }
    }
  })
})

Contribute

# right after clone
npm install

# begin making changes
git checkout -b <branch>
npm run watch

# edit `webpack.config.es5.js` and `rollup.config.es2015.js` to exclude dependencies for the bundle if needed

# after making change(s)
git commit -m "<commit message>"
git push

# create PR

Npm Commands

There are a few useful commands you can use during development.

# Run tests (and lint) automatically whenever you save a file.
npm run watch

# Run tests with coverage stats (but won't fail you if coverage does not meet criteria)
npm run test

# Manually verify the project.
# This will be ran during 'npm preversion' so you normally don't need to run this yourself.
npm run verify

# Build the project.
# You normally don't need to do this.
npm run build

# Run tslint
# You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you.
npm run lint

Generated by [email protected]