Coder Social home page Coder Social logo

americanexpress / holocron Goto Github PK

View Code? Open in Web Editor NEW
80.0 20.0 23.0 1.91 MB

✨Set of packages that are used to compose and load React components, enabling the updating and launching of server side rendered user experiences without server restarts

License: Apache License 2.0

JavaScript 100.00%
one-app

holocron's Introduction

lerna

Holocron contains a set of packages that are used to compose and load React components, enabling the updating and launching of server side rendered user experiences without server restarts. This repository is a monorepo managed using Yarn Workspaces & Lerna.

📖 Table of Contents

📦 Packages

This codebase has the following packages:

Name Description
holocron This is used for composing and loading your application modules.
holocron-module-register-webpack-plugin This plugin adds the module to registry once its loaded on the page.
holocron-module-route This uses @americanexpress/one-app-router which is a fork of react-router@3. It extends its Route component which uses holocron's loadModule to dynamically load modules for specified routes.

🏆 Contributing

We welcome Your interest in the American Express Open Source Community on Github. Any Contributor to any Open Source Project managed by the American Express Open Source Community must accept and sign an Agreement indicating agreement to the terms below. Except for the rights granted in this Agreement to American Express and to recipients of software distributed by American Express, You reserve all right, title, and interest, if any, in and to Your Contributions. Please fill out the Agreement.

Please feel free to open pull requests and see CONTRIBUTING.md for commit formatting details.

🗝️ License

Any contributions made under this project will be governed by the Apache License 2.0.

🗣️ Code of Conduct

This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.

holocron's People

Contributors

10xlacroixdrinker avatar adamfoskit avatar asutedja avatar benmclees avatar bishnubista avatar code-forger avatar dependabot[bot] avatar dogpatch626 avatar drewcur avatar francois-esquire avatar giulianok avatar infoxicator avatar jadshead avatar jsmartfo avatar kandykad avatar matthew-mallimo avatar narmeennaveedahmed avatar nellyk avatar oneamexbot avatar pixnbits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

holocron's Issues

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

shouldModuleReload does not receive mapped props from Redux state

🐞 Bug Report

Describe the bug

shouldModuleReload does not receive mapped props from Redux state or any other HoCs.

The current setup of HolocronModule wrapper (internal HoC) does not allow for any additional prop, unless injected from the top.

This makes impossible to reload the module's data with any prop coming from other HoCs.

To Reproduce

Any root module that need to reload when injected props change (e.g. mapped from Redux state).

Expected behavior

A root module should be able to inject props to itself via any HoCs and be able to determine its reloading by using such props (e.g. mapped from Redux state).

If loadModuleData is not passed to Module.holocron, then moduleLoadStatus is always 'loading'

🐞 Bug Report

Describe the bug

If neither 'load' nor 'loadModuleData' are passed to [Module].holocron, the module's 'moduleLoadStatus' is 'loading'.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Run the one-app generator command: npx -p yo -p @americanexpress/generator-one-app-module -- yo @americanexpress/one-app-module
  2. Edit the generated function in the src/components/[name].jsx file to deconstruct 'moduleLoadStatus' from the arguments.
  3. Display/console.log the moduleLoadStatus (it will be loading)

Expected behavior

If there is no asynchronous data to load, 'moduleLoadStatus' should be 'loaded'.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Windows (64-bit)
  • Browser: N/A
  • Version of holocron: ^1.1.0
  • Node version: 12.18.1

Additional context

You can copy/paste this code into the .jsx to easily reproduce:

import React from 'react';
import PropTypes from 'prop-types';
import childRoutes from '../childRoutes';

const HelloWorld = ({ moduleLoadStatus }) => {
  if (moduleLoadStatus === 'loading') return <h1>Loading...</h1>; // <-- This will always be returned!
  if (moduleLoadStatus === 'error') return <h1>Error!</h1>;
  return <h1>Hello World!</h1>;
};

HelloWorld.childRoutes = childRoutes;

HelloWorld.propTypes = {
  moduleLoadStatus: PropTypes.oneOf(['loading', 'loaded', 'error']),
};

HelloWorld.holocron = {
  name: 'hello-world',
};

if (!global.BROWSER) {
  // eslint-disable-next-line global-require
  HelloWorld.appConfig = require('../appConfig').default;
}

export default HelloWorld;

Commiting changes from a Windows machine

💡 Feature request

Is your feature request related to a problem? Please describe

The test command declared in package.json does not work for Windows' cmd.

Example

Have a separate test command for Windows machines.

Describe the solution you'd like

"test:unit": "SET NODE_ENV=development jest"

Describe alternatives you've considered

The developer could just locally change the command before committing changes or running tests.

ownProps not passed to loadModuleData on initial server and client renders

🐞 Bug Report

Describe the bug

Two related issues:

When passing props to RenderModule, the props are not available to loadModuleData during server-side render or during the initial client-side render. On the second client-side render, the props are available along with moduleState.

When passing the same props through composeModules, the props are available on the server-side and the initial client-side render.

To Reproduce

const MyModule = () => {
  <div>example</div>
};

MyModule.holocron = {
   name: 'my-module',
   loadModuleData: ({ ownProps }) => {
      console.log('ownProps', ownProps);
      // `ownProps {}` (on server)
      // `ownProps {}` (client initial render)
      // `ownProps { foo: 'foo', moduleState: {...} }`  (client subsequent renders)
  },
};

const RootModule = ({ moduleLoadStatus }) => (
  <React.Fragment>
    {moduleLoadStatus === 'loaded' && (
      <RenderModule moduleName="my-module" props={{ foo: 'foo' }} />
    )}
  </React.Fragment>
);

RootModule.holocron = {
  name: 'root-module',
  loadModuleData: async ({ store: { dispatch } }) => {
    await dispatch(composeModules([{ name: 'my-module' }]));
  },
};

System information

  • OS: macOS
  • Browser: chrome
  • Version of holocron: 1.1.0
  • Node version: 12.17.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.