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

@syncify/acquire

v0.0.2

Published

File require and import helper with TS Transform support

Readme

@syncify/acquire

Resolves ESM and CJS config files. Based on Bundle Require by egoist, performs identical resolution with minor differences for appropriation and usage in the Syncify CLI. Supports the following extensions and file types:

  • .ts
  • .js
  • .cjs
  • .mjs

How this differs from bundle-require?

Bundle require performs some additional analysis that I did not need along with applied logic that Syncify obtains that can be used more effeciently. This variation does not perform package.json analysis, it does not provide .tsx or .jsx support and module resolution is applied on the thenable.

The return object are getters and provide access to esbuild warnings. Lastly Resolve issues throw custom errors

Installation

Peer depedency on ESBuild.

pnpm add @syncify/acquire -D

Usage

The module itself can be used in isolation in any node.js project, despite being design for usage within Syncify CLI. Similar configuration and setup bundle-require, though the following methods and options are provided.

import { acquire, $import, $tsconfig, $require } from '@syncify/acquire';

const $module = await acquire({

  file: '/path/to/syncify.config.ts',  // Required

  cwd: process.cwd(),                  // Optional
  type: 'module' | undefined,          // Optional
  named: undefined,                    // Optional
  preserve: false,                     // Optional
  tsconfig: '/path/to/tsconfig.json',  // Optional
  identifier: 'Random Name',           // Optional

  external: [],                        // Optional
  extenalNodeModules: [],              // Optional
  noExternal: [],                      // Optional

  onError: (errors) => [],             // Optional - Bundle errors (if any)
  onWarning: (errors) => [],           // Optional - Bundle warnings (if any)
  onRebuild: ($module) => $module      // Optional - Bundle Module

})

$module                               // Bundle Module

// ADDITIONAL EXPORTS

$import('id')                        // Importy CJS/ESM
$require('id')                       // Import CJS
$tsconfig('path')                    // Resolve tsconfig.json

The module is throughly typed and annotated with JSDocs comment descriptions, which will describe each option and method in good detail.

Practical Usage

The most basic usage is as follows:

import { acquire } from '@syncify/acquire';

const config = await acquire({
  file: '/path/to/syncify.config.ts',
  onError: errors => console.error(...errors)
});

config; // Returns null is errors or module itself