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

@domql/dependency-injector

v1.1.4

Published

Handle global scope in domql components

Downloads

3

Readme

Injector

Globusa exports one function, parse(), that takes a string of javascript code and returns an object that looks like this:

{
  imports: [],               // mitosis-style import objects
  declarations: [],          // strings
  exports: [],               // strings
  domqlComponents: [],       // [ { name: null/string, code: string }, ... ]
  linesExcludingImports: [], //
  identifiers: [],           // strings
}

At its core, dependency-injector handles the global scope in a javascript file that exports domql components so that the component can easily be converted to other frameworks using to-mitosis.

Basically, with the help of Globusa, Kalduna can convert something like this:

import { Text } from '@symbo.ls/atoms'
import { someFunction } from './Atoms/Flex'

const localFn = (a,b) => a + b

export const Title = {
  extend: Text,
  style: { fontSize: '55px' },
  on: { click: (ev, el) => { console.log(someFunction(ev), localFn(1, 2)) } }
}

Into this: (notice the imports and the localFn declaration)

import { Text } from '@symbo.ls/atoms' // Kalduna will include this
import { someFunction } from './Atoms/Flex' // Included by dependency-injector

const localFn = (a,b) => a + b // Copied by dependency-injector

export default function Title(props) {
  const el = {
    props: ...
    parent: ...
    ...
  }

  function Text_onClick(ev, el) {
    console.log(someFunction(ev), localFn(1, 2))
  }

  return (
    <Text
      style={`${css({ fontSize: '55px' })}`)
      onClick={(ev) => Text_onClick(ev, el)}
      ...props />
  )
}

Tests

The testing scheme is based off of Kalduna's testing scheme.

We use node's built-in assertion module instead of a separate library.

How to run tests

To run the entire test suite, do yarn test from the root of this repository.

To run only specific tests, simply pass a file name or pattern to the script:

yarn test dedup-mitosis-imports.test.js
# or
yarn test dedup*.test.js

How it works

  • tests/esbuild-tests.js compiles all the .test.js files from tests/ and puts them in tests/dist/.
  • Each compiled test suite file in tests/dist/ is run with node as a separate process so that if a crash happens in one suite, it doesn't affect the other ones.
  • If no errors show up during testing then all tests have passeed.