Necessary Pigeonholing Mechanism

    @americanexpress/holocron-dev-server

    0.1.5 • Public • Published

    @americanexpress/holocron-dev-server

    @americanexpress/holocron-dev-server is an experimental development server made for One App Holocron modules designed for enabling fast refresh and reloading of assets while creating web experiences.

    ⚠️ holocron-dev-server is a client-side only development server and does not run Holocron modules as One App would normally. Holocron modules are not loaded into memory on the server, nor does it server side render (only client side). There are other key differences, and as such, holocron-dev-server does not behave the same as One App server. If you are looking for a production-like environment to run One App Holocron modules, @americanexpress/one-app-runner would be the right tool of choice. This is because holocron-dev-server only provides a faster developer experience on the client side only, without the actual One App server.

    📖 Table of Contents

    Features

    • Runs One App Holocron modules on an experimental development server
    • Fast refresh for Holocron modules, React components and styles are all hot loaded in the browser
    • Zero-config start up with pre-existing "one-amex" configuration in the package.json
    • Hot reload parrot scenarios and watch for changes
    • Hot reload language packs and watch for changes from the local modules
    • Combines the remote module if provided with the local module map remote module map with the universal map
    • Local Holocron modules bundles/externals analyzed and reported using webpack bundle analyzer

    Differences with One App

    • Only works client side
    • Does not server side render

    Server Spec

    🤹‍ Usage

    Prerequisites

    Installation

    npm install -D @americanexpress/holocron-dev-server
    
    # or
    
    yarn add -D @americanexpress/holocron-dev-server

    Start Up

    add the script in the package.json of your Holocron module:

    {
      "scripts": {
        "dev": "holocron-dev-server"
      }
    }

    then run to start the development server:

    npm run dev
    
    # or
    
    yarn dev

    Once the command runs, the sandbox Holocron module reload server will start up using the configuration found in the modules package.json.

    Zero-Config

    holocron-dev-server uses existing configurations from "one-amex" to source what modules, externals and other configuration like rootModuleName are used.

    The config uses one-amex.runner (modules, rootModuleName, moduleMapUrl, dockerImage, envVars) and one-amex.bundler (providedExternals, requiredExternals) to set up the HMR environment for your Holocron module.

    Default Values

    In the case that certain configuration options are not present in the Holocron module config, there are default values that are used in its place.

    • the root module name (rootModuleName) will use the current module if it is not defined.
    • the docker image (dockerImage) will default to oneamex/one-app-dev:latest if not defined.

    Parrot Scenarios

    If a mock/scenarios.js exists in your module, the parrot scenarios will be watched for changes and updated, please note that the parrot browser extension will need to be changed to refer to the port used by the holocron development server.

    Language Packs

    The same applies if locale/* folder exists in your Holocron module. When a given locale gets modified, the holocron dev server will notify the client and will load the language pack into state. Please note that if default fallback for loading the language pack is en-US, if any issue occurs while trying to load it.

    🎛️ API

    The API is subject to change

    holocron-dev-server

    Command line tool usage.

    Usage

    npx -p @americanexpress/holocron-dev-server -- holocron-dev-server

    Configuration

    hmr Options

    Use the one-amex.hmr config for more advanced configurations. The experimental hmr config is subject to change. The options supported are:

    name type required default value
    logLevel Number or String false 4 or "info" "info" or 4, "log" or 3, "warn" or 2, "error" or 1, 0 for silent
    sourceMap [Boolean, String] false "source-map" value passed to webpack's devtool configuration (eg inline-cheap-source-map, false)
    clientConfig Object false {} the One App configuration in the store (store.get('config'))
    port Number false 4000 the port that holocron-dev-server binds to
    openWhenReady Boolean false false Set to true to enable opening your default browser when ready
    {
      "one-amex": {
        "hmr": {
          "logLevel": "info",
          "port": 4000,
          "openWhenReady": false,
          "sourceMap": "inline-cheap-source-map",
          "clientConfig": {
            "myClientSideConfig": "https://url"
          }
        }
      }
    }

    Troubleshooting

    There may be instances where fast refresh may stop working for various reasons, check out the troubleshooting guide from @pmmmwh/react-refresh-webpack-plugin react-refresh for debugging tips.

    If any issues persist, try removing the static directory generated and run the development server again.

    Install

    npm i @americanexpress/holocron-dev-server

    DownloadsWeekly Downloads

    19

    Version

    0.1.5

    License

    Apache-2.0

    Unpacked Size

    100 kB

    Total Files

    35

    Last publish

    Collaborators

    • pixnbits
    • jsmartfo
    • tklever
    • bharatsurya
    • amexopensource
    • william-mcmillian
    • jadshead
    • francois.esquire
    • 10xlacroixdrinker