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

voltranjs

v1.1.10

Published

<h1 align="center"> <br> <a href="http://www.hepsiburada.com"><img src="./src/assets/voltran-logo.png" alt="voltran.js" width="220"></a> <br> Micro Frontends Framework <br> </h1>

Downloads

629

Readme

Key Features

You can use Voltran if you need a micro frontend framework that provides following features:

  • Lightweight and fast API
  • Serves single and multiple components
  • Preview (to visualize components)
  • SEO friendly (if needed)
  • CSS & SCSS support
  • Supports only React (for now)

Installation

Voltran requires Node.js v10.15.0+ to run.

Install the Voltran.

Yarn

$ yarn add voltranjs

Npm

$ npm install voltranjs

Usage

This is an example component.

First of all, you should import @voltran/core.

After that we can write the component's code.

HelloWorld.js

const voltran = require('@voltran/core');

import React from 'react';

const ROUTE_PATHS = {
  HELLOWORLDPAGE: '/HelloWorld'
};

const HelloWorld = ({ initialState }) => {
  return <>Hello World!</>;
};

const component = voltran.default.withBaseComponent(HelloWorld, ROUTE_PATHS.HELLOWORLDPAGE);

export default component;

If you want to fetch data from server side, you should add getInitialState.

./conf/local.config.js

const port = 3578;

module.exports = {
  port: port,
  baseUrl: `http://localhost:${port}`,
  mediaUrl: '',
  services: {
    voltranapi: {
      clientUrl: 'http://voltran-api.qa.hepsiburada.com',
      serverUrl: 'http://voltran-api.qa.hepsiburada.com'
    }
  },
  timeouts: {
    clientApiManager: 20 * 1000,
    serverApiManager: 20 * 1000
  }
};

HelloWorld.js


const voltran = require('@voltran/core');

import React from 'react';
import appConfig from '../appConfig';

const ROUTE_PATHS = {
  HELLOWORLDPAGE: '/HelloWorld',
};

const HelloWorld = ({initialState}) => {
    HelloWorld.services = [appConfig.services.voltranApi];

    HelloWorld.getInitialState = (voltranApiClientManager, context) => {
      const config = { headers: context.headers };
      const params = {...};

      return getName({ params }, voltranApiClientManager, config);
    };

    return (
        <>
            Hello World. My name is {initialState.name}!
        </>
    );
};

const component = voltran.default.withBaseComponent(HelloWorld, ROUTE_PATHS.HELLOWORLDPAGE);

export default component;

Output For Preview

Hello World. My Name is Volkan!

Output For Api

{
    html: ...,
    scripts: [...],
    style: [...],
    activeComponent: {
        resultPath: "/HelloWorld",
        componentName: "HelloWorld",
        url: "/HelloWorld"
    },
}

Configs

Voltran requires following configurations:

| Config | Type | | --------------------------------------------- | -------------------- | | appConfigFile | Object | | dev | Boolean | | distFolder | String | | publicDistFolder | String | | inputFolder | String * required | | monitoring | Object | | port | Number - String | | prefix | String * required | | ssr | String | | styles | Array | | output | Object | | staticProps | Array | | routing | Object | | webpackConfiguration | Object | | sassResources | Array | | criticalCssDisabled | Boolean |

appConfigFile

It should contain environment specific configurations (test, production ...).

appConfigFile: {
  entry: path.resolve(__dirname, './yourConfigFolder/'),
  output: {
    path: path.resolve(__dirname, './yourOutputFolder/'),
    name: 'yourFileName',
  }
}

dev

Development mode. Set to true if you need to debug.

Default: false

distFolder

The path to the folder where bundled scripts will be placed after the build.

Default: ./dist

publicDistFolder

The path to the folder where asset files will be placed after the build.

Default: ./dist/assets

inputFolder

The path to the folder that contains script files. It's required.

Passes this config to Babel Loader where it reads all js files under this folder.

'Voltran' converts your files to the appropriate format and optimizes them.

monitoring

For now, only prometheus is supported.

monitoring: {
  prometheus: false
}

or you can set your custom js file.

monitoring: {
    prometheus: path.resolve(__dirname, './src/tools/prometheus.js')
}

port

Default: 3578

If you want to change the port you may need to change the port in appConfigFiles

prefix

It is required.

There may be different components owned by different teams using voltrans on the same page. Voltran needs to use a prefix in order to avoid conflicts issues. This prefix is prepended to initial states and CSS class names.

We recommend that each team use their own acronyms/prefixes.

ssr

Default: true Voltran supports server side rendering. Applications that need 'SEO' features needs to set this parameter to true.

styles

This field's value should be an array of strings. Array values should be the paths to the global CSS files.

styles: [
    path.resolve(__dirname, './some-css-file.scss'),
    path.resolve(__dirname, './node_modules/carousel/carousel.css')
]

output

output: {
  client: {
    path: path.resolve(__dirname, './build/public/project/assets'),
    publicPath: path.resolve(__dirname, './src/assets'),
    filename: '[name]-[contenthash].js',
    chunkFilename: '[name]-[chunkhash].js'
  },
  server: {
    path: path.resolve(__dirname, './build/server'),
    filename: '[name].js'
  },
},

staticProps

You can pass static props to all components at the same time.

staticProps: [
  {'key': value}
]

routing

Voltran need two files to set routing.

routing: {
  components: path.resolve(__dirname, './src/appRoute/components.js'),
  dictionary: path.resolve(__dirname, './src/appRoute/dictionary.js')
}

criticalCssDisabled

Set to false if don't need to critical styles.

Default: true

Example files can be found here:

webpackConfiguration

You can add your webpack configuration. They will be merged with the voltran configs.

You can access the starter kit we created from the link.

sassResources

You can add sass resources to this field as string array. sass-resource-loader gonna inject those files in every sass files so you won't need to import them.

You can check sass-resource-loader for usage.

New Relic Integration

Add newrelicEnabled: true on your config.

If you throw an error like throw new Error({message: "Service error", code: 500}) from your fragments, Voltran detects the fields and sends each field to New Relic as a custom attribute. These fields appear with _a prefix to place in the first of rows on your new relic.

Tech

Voltran uses a number of open source projects to work properly:

  • [ReactJS] - A JavaScript library for building user interfaces!
  • [Webpack] - Module bundler
  • [babel] - The compiler for next generation JavaScript.
  • [node.js] - evented I/O for the backend
  • [hiddie] - fast node.js network app framework (friendly fork of middie)
  • [Yarn] - the streaming build system

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request