JSPM

react-native-source-maps

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 59
    • Score
      100M100P100Q72333F
    • License MIT

    Utilities to easily add support of Source Maps to your React Native project

    Package Exports

    • react-native-source-maps

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-source-maps) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    react-native-source-maps

    Utilities to easily add support of Source Maps to your React Native project


    Usage:

    1. Add sourcemaps generation to your build script (or customize default one)
      ...
      --sourcemap-output "$DEST/main.jsbundle.map"
    1. Initialise at the app start with source map bundle file and other options
    import {initSourceMaps} from 'react-native-source-maps';
    initSourceMaps({sourceMapBundle: "main.jsbundle.map", collapseInLine: true});
    1. Use it with your logging utilities Example:
    const stack = !__DEV__ && await getStackTrace(error);
    if (stack) {
        error.stack = stack;
    }
    log.error({message: 'Error (' + error.message + ')', error});
    1. To caught all uncaught errors in app you can add global error handler:
    import log from "../log";
    import {getStackTrace} from 'react-native-source-maps';
    import ErrorUtils from "ErrorUtils";
    
    (async function initUncaughtErrorHandler() {
        const defaultGlobalHandler = ErrorUtils.getGlobalHandler();
    
        ErrorUtils.setGlobalHandler(async(error, isFatal) => {
            try {
                if (!__DEV__) {
                    error.stack = await getStackTrace(error);
                }
                log.error({message: 'Uncaught error (' + error.message + ')', error, isFatal});
            }
            catch (error) {
                log.error({message: 'Unable to setup global handler', error});
            }
    
            if (__DEV__ && defaultGlobalHandler) {
                defaultGlobalHandler(error, isFatal);
            }
        });
    })();