How to use the @lwc/compiler.transformSync function in @lwc/compiler

To help you get started, we’ve selected a few @lwc/compiler 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-test / packages / @lwc / jest-transformer / src / index.js View on Github external
process(src, filePath) {
        // Set default module name and namespace value for the namespace because it can't be properly guessed from the path
        const { code, map } = lwcCompiler.transformSync(src, filePath, {
            name: 'test',
            namespace: 'x',
            outputConfig: {
                sourcemap: true,
            },
        });

        // if is not .js, we add the .compiled extension in the sourcemap
        const filename = path.extname(filePath) === '.js' ? filePath : filePath + '.compiled';
        // **Note: .html and .css don't return valid sourcemaps cause they are used for rollup
        const config = map && map.version ? { inputSourceMap: map } : {};

        return babelCore.transform(code, { ...BABEL_CONFIG, ...config, filename });
    },
    getCacheKey(fileData, filePath, configStr, options) {
github salesforce / lwc / packages / @lwc / jest-transformer / src / index.js View on Github external
process(src, filePath) {
        // Set default module name and namespace value for the namespace because it can't be properly guessed from the path
        const { code, map } = lwcCompiler.transformSync(src, filePath, {
            moduleName: 'test',
            moduleNamespace: 'x',
            outputConfig: {
                sourcemap: true,
            },
        });

        // if is not .js, we add the .compiled extension in the sourcemap
        const filename = path.extname(filePath) === '.js' ? filePath : filePath + '.compiled';
        // **Note: .html and .css don't return valid sourcemaps cause they are used for rollup
        const config = map && map.version ? { inputSourceMap: map } : {};

        return babelCore.transform(code, { ...BABEL_CONFIG, ...config, filename });
    },
    getCacheKey(fileData, filePath, configStr, options) {

@lwc/compiler

LWC compiler

MIT
Latest version published 2 days ago

Package Health Score

90 / 100
Full package analysis