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

cja-phoenix

v0.19.17

Published

<p align="center"> <img width="200" src="https://github.com/comparaja/phoenix/assets/55537456/04320341-7b33-4331-b041-c0da0306e54c"> </p>

Downloads

1,673

Readme

CJA Phoenix

Setup

# install dependencies
npm install

# start the doc app, great for testing components
npm run story:dev

# build the doc app for deployment
npm run story:build

# build the library, available under dist
npm run build

# build the library for use with npm link
npm run build:link

# builds the library for publishing, requires a version bump
npm run publish:lib

Develop and test locally

The best way to develop and test your component is by creating stories in src/histoire folder.

If you want to test the library in your Vue3 app locally:

  • In the root folder of this library, run npm run build:link. This will build the library for development and create a symbolic link to the library.
  • In the package.json of the client app add the script: reload: npm link cja-phoenix && npm run serve, this will grab the symbolic link created by running npm run build:link.
  • You can now import cja-phoenix in your client app.
  • The library can be installed on your app with the App.use() function

If you made changes to the library, you will need to run npm run build:link on Phoenix's side and npm run reload on the client app's side.

It is advised to add the script "reset:packages": "npm unlink cja-phoenix && npm i cja-phoenix@latest"to the client app in order to make the process of clearing the npm link and updating the cja-phoenix version easier. Simply run it after you have made your changes and published them, the script will automatically clean up the package lock file and reinstall the latest cja-phoenix version.

Publishing

After testing your developments and updating the documentation app, bump the version in package.json and run npm run publish

How it works

Components

The library is a Vue plugin. The install function in index.ts registers all components under components to Vue globaly.

The doc app itself is a client app of the library.

Utilities and constants

The library includes example utilities and constants. They are also exported in index.ts. The client app may use them as below:

<script lang="ts">
import { MyConstants, MyUtil } from 'cja-phoenix'

export default {
  data () {
    return {
      magicNum: MyConstants.MAGIC_NUM
    }
  },
  methods: {
    add (a:number, b:number) {
      return MyUtil.add(a, b)
    }
  }
}
</script>

Styling

Individual components have styles defined in its .vue file. They will be processed, combined and minified into dist/style.css, which is included in the exports list in package.json.

If you have library level styles shared by all components in the library, you may add them to src/assets/main.scss. This file is imported in index.ts, the processed styles are also included into dist/style.css.

The client app must import style.css in its entry file:

import "cja-phoenix/style";

Iconia

In order to edit the Iconia font access Icomoon and perform the required adaptations. If the current Iconia project is not loaded, use the import project tool with the assets/iconia/selection.json file. In order to properly generate the font svg file inputs should have outlined strokes. General rule, icons should have their size scaled up to the canvas and color removed through the edit function.

After editing the font, the types/Icon.ts file should be updated to include the new icon class names.

Third-party dependencies

Third-party libraries used by you library may bloat up the size of your library, if you simply add them to the dependencies in package.json.

The following are some strategies to reduce the size of your library:

Externalization

If you expect the client app of your library may also need the same dependency, you can externalize the dependency. For example, to exclude Vue from your library build artifact, in vite.config.ts, you can have

module.exports = defineConfig({
    rollupOptions: {
      external: ['vue']
    }
  }
})

The dependency to be externalized can be declared as a peer dependency in your library.

Nuxt Apps

The library is specially adapted to be used with nuxt apps and as such requires specific configurations.

Library Initialization

When attaching the library to the app, you must provide the use function with an options object containing urls for the image cdn, api url and if needed provider image url.

Standard Vue Apps

As development on the library progresses, the code has been adapted to cater to nuxt requirements and specific patterns. Nevertheless, if the library must be used on standalone vue apps, additional steps must be taken.

Importing SCSS variables

Add the following code to vue.config in order to import the library SCSS variables

css: {
  loaderOptions: {
    scss: {
      additionalData: `@use "cja-phoenix/variables" as *;`,
    },
  },
}

Type generation

In tsconfig.json, the following options instructs tsc to emit declaration (.d.ts files) only, as vite build handles the .js file generation. The generated .d.ts files are sent to dist/types folder.

"compilerOptions": {
  "declaration": true,
  "emitDeclarationOnly": true,
  "declarationDir": "./dist/types"
}

In package.json, the line below locates the generated types for library client.

"types": "./dist/types/index.d.ts",

In vite.config.ts, build.emptyOutDir is set to false and rimraf is used instead to remove the dist folder before the build. This is to avoid the dist/types folder generated by tsc being deleted when running vite build.

Configuration

TypeScript

In tsconfig.json, set the following as recommended by Vite (since esbuild is used). However, enabling this option leads to https://github.com/vitejs/vite/issues/5814. The workaround is to also enable compilerOptions.skipLibCheck.

"compilerOptions": {
  "isolatedModules": true
}

In tsconfig.json, set the following to address Issue #32. The solution is from https://github.com/johnsoncodehk/volar/discussions/592.

"compilerOptions": {
  "types": [
    "vite/client"
  ]
}

Dependencies

In package.json, Vue is declared in both peerDependencies and devDependencies. The former requires the client app to add these dependencies, and the later makes it easier to setup this library by simply running npm install.