All Projects → hepsiburada → Voltranjs

hepsiburada / Voltranjs

Licence: mit
Voltran is a micro frontend framework which is developed by Hepsiburada Technology Team.

Programming Languages

javascript
184084 projects - #8 most used programming language
js
455 projects

Projects that are alternatives of or similar to Voltranjs

babel-plugin-transform-html-import-to-string
Turn HTML imports (and export from) into constant strings
Stars: ✭ 22 (-91.47%)
Mutual labels:  babel
eslint-config-satya164
An ESLint config with automatic overrides for common environments such as TypeScript, Jest etc.
Stars: ✭ 45 (-82.56%)
Mutual labels:  babel
reactjs-boilerplate
Reactjs setup with babel, webpack with basic loaders, ant design, react-router and optimized for production using code splitting and lazy loading.
Stars: ✭ 40 (-84.5%)
Mutual labels:  babel
react-app-rewire-babel-loader
Rewire babel-loader loader in your create-react-app project using react-app-rewired.
Stars: ✭ 20 (-92.25%)
Mutual labels:  babel
array-mixer
Powerful, super tiny and easy to use lib to reorder your javascript arrays.
Stars: ✭ 32 (-87.6%)
Mutual labels:  babel
react-enterprise-starter-kit
Highly Scalable Awesome React Starter Kit for an enterprise application with a very easy maintainable codebase. 🔥
Stars: ✭ 55 (-78.68%)
Mutual labels:  babel
nuxt-babel
Use normal .babelrc file with your Nuxt app
Stars: ✭ 32 (-87.6%)
Mutual labels:  babel
tiny-wheels
一套基于原生JavaScript开发的组件库,无依赖、体积小、简单易用
Stars: ✭ 60 (-76.74%)
Mutual labels:  babel
create-mithril-app
Sets up a mithril.js project with webpack
Stars: ✭ 20 (-92.25%)
Mutual labels:  babel
metalsmith-babel
A Metalsmith plugin to compile JavaScript with Babel
Stars: ✭ 19 (-92.64%)
Mutual labels:  babel
starbase
⭐ Production-ready website boilerplate made with webpack 5, modern JS (via Babel 7) & Sass
Stars: ✭ 70 (-72.87%)
Mutual labels:  babel
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (-84.5%)
Mutual labels:  babel
babel-plugin-syntax-pipeline
Allow parsing of pipeline operator |>
Stars: ✭ 23 (-91.09%)
Mutual labels:  babel
snabbdom-pragma
'NotReact.createElement' jsx pragma although for snabbdom
Stars: ✭ 47 (-81.78%)
Mutual labels:  babel
react-pits
React 中的坑
Stars: ✭ 29 (-88.76%)
Mutual labels:  babel
ignite-reactjs
Projetos desenvolvidos em ReactJS durante a trilha de ReactJS do Ignite da Rocketseat. 💜🚀
Stars: ✭ 20 (-92.25%)
Mutual labels:  babel
babel-collect-imports
Recursively collect all the internal and external dependencies from an entry point
Stars: ✭ 33 (-87.21%)
Mutual labels:  babel
Hare
🐇 Application boilerplate based on Vue.js 2.x, Koa 2.x, Element-UI and Nuxt.js
Stars: ✭ 258 (+0%)
Mutual labels:  babel
NEUQ-OJ
基于 React 开发的 Online Judge 系统
Stars: ✭ 19 (-92.64%)
Mutual labels:  babel
web development and api design
Code for the PG6301 course on Web Development and API Design
Stars: ✭ 51 (-80.23%)
Mutual labels:  babel

VoltranJS

Hepsiburada Hepsitech

What is Voltran and why you should use it?

Voltran is a micro frontend framework which is developed by Hepsiburada Technology Team. Micro frontends help cross functional teams to make end-to-end and independent developments and deployments.

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

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]-[hash].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')
}

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.

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 :D
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].