How to use the @lwc/errors.normalizeToCompilerError function in @lwc/errors

To help you get started, we’ve selected a few @lwc/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / lwc / packages / @lwc / template-compiler / src / codegen / styles.ts View on Github external
export default function parseInlineStyles(
    src: string,
    stylesheetConfig: StylesheetConfig
): Statement[] {
    let result;
    try {
        result = styleCompiler.transform(src, 'template_inline_styles', stylesheetConfig);
    } catch (e) {
        throw normalizeToCompilerError(TransformerErrors.CSS_IN_HTML_ERROR, e);
    }
    // The style compiler produces a module string
    const { code } = result;
    // Convert it to an AST
    const parsed = babylon.parse(code, { sourceType: 'module' });

    // Return the body of the module
    return parsed.program.body;
}
github salesforce / lwc / packages / @lwc / compiler / src / transformers / javascript.ts View on Github external
): FileTransformerResult {
    const { isExplicitImport, experimentalDynamicComponent: dynamicImports } = options;
    const config = Object.assign({}, BABEL_CONFIG_BASE, {
        plugins: [
            [lwcClassTransformPlugin, { isExplicitImport, dynamicImports }],
            ...BABEL_PLUGINS_BASE,
        ],
        filename,
        sourceMaps: options.outputConfig.sourcemap,
    });

    let result;
    try {
        result = babel.transform(code, config);
    } catch (e) {
        throw normalizeToCompilerError(TransformerErrors.JS_TRANSFORMER_ERROR, e, { filename });
    }

    return {
        code: result.code,
        map: result.map,
    };
}
github salesforce / lwc / packages / @lwc / compiler / src / transformers / javascript.ts View on Github external
): FileTransformerResult {
    const { isExplicitImport, experimentalDynamicComponent: dynamicImports } = options;
    const config = Object.assign({}, BABEL_CONFIG_BASE, {
        plugins: [
            [lwcClassTransformPlugin, { isExplicitImport, dynamicImports }],
            ...BABEL_PLUGINS_BASE,
        ],
        filename,
        sourceMaps: options.outputConfig.sourcemap,
    });

    let result;
    try {
        result = babel.transform(code, config);
    } catch (e) {
        throw normalizeToCompilerError(TransformerErrors.JS_TRANSFORMER_ERROR, e, { filename });
    }

    return {
        code: result.code,
        map: result.map,
    };
}