hypernova-plugin-server-stacktrace

Hypernova plugin for logging a stack trace when the server fails to render components

Usage no npm install needed!

<script type="module">
  import hypernovaPluginServerStacktrace from 'https://cdn.skypack.dev/hypernova-plugin-server-stacktrace';
</script>

README

hypernova-plugin-server-stacktrace

npm version Build Status Maintainability Test Coverage

hypernova-plugin-server-stacktrace is a small plugin for Hypernova especially in production. The plugin enables you to log a stack trace when the server fails to render components.

Installation

For npm:

npm install hypernova-plugin-server-stacktrace --save

Usage

Add the plugin object to plugins array of the server configuration:

const hypernova = require('hypernova/server');
const ServerStacktracePlugin = require('hypernova-plugin-server-stacktrace');

hypernova({
  plugins: [new ServerStacktracePlugin()]
});

This will output errors to STDOUT as follows:

2019-01-01T08:43:00.647Z - error: TypeError: foo.bar is not a function
    at Top (/pass/to/build/pages/webpack:/src/pages/index.tsx:16:1)
    at processChild (/pass/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:2458:14)
    at resolve (/pass/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:2384:5)
    at ReactDOMServerRenderer.render (/pass/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:2706:22)
    at ReactDOMServerRenderer.read (/pass/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:2680:23)
    at Object.renderToStaticMarkup (/pass/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:3082:25)
    at /pass/to/build/pages/webpack:/src/lib/hypernova-react.ts:48:1
    at /pass/to/node_modules/hypernova/lib/utils/BatchManager.js:190:18
    at tryCatcher (/pass/to/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/pass/to/node_modules/bluebird/js/release/promise.js:512:31)

Note that you're able to customize the log format and destination by logger or loggerInstance. For further information, please see the section on server configuration options.

Contributing

You should follow the steps below.

  1. Fork the repository
  2. Create a feature branch: git checkout -b add-new-feature
  3. Commit your changes: git commit -am 'Add new feature'
  4. Push the branch: git push origin add-new-feature
  5. Send us a pull request

License

The library is available as open source under the terms of the MIT License.