How to use babel-plugin-transform-proxy-compat - 1 common examples

To help you get started, we’ve selected a few babel-plugin-transform-proxy-compat 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 / proxy-compat-build / scripts / build.js View on Github external
const mkdirp = require('mkdirp');
const babel = require('babel-core');
const UglifyJS = require("uglify-es");
const compatPlugin = require('babel-plugin-transform-proxy-compat');
const PolyfillBuilder = require('./polyfill-builder');

// -- File source dependencies ----------
const proxyCompat = fs.readFileSync(require.resolve('proxy-compat/dist/umd/proxy-compat.js'), 'utf8');
const babelHelpers = fs.readFileSync(require.resolve('babel-helpers-lwc/dist/engine-helpers.js'), 'utf8');
const polyfillsDir = path.resolve(__dirname, '../src/polyfills');
const polyfillList = fs.readdirSync(polyfillsDir);
const downgradeSrc = fs.readFileSync(path.resolve(__dirname, '../src/downgrade.js'));
const polyfillSources = polyfillList.reduce((src, p) => src + fs.readFileSync(path.join(polyfillsDir, p), 'utf8'), '');

// -- Config -----------------------------
const compatKeys = Object.values(compatPlugin.keys);
const compatOverrides = compatKeys.reduce((str, key) => `${str} var __${key} = window.Proxy.${key};`, '');
const dest = path.join(__dirname, '../dist/umd');

const babelConfig = {
    babelrc: false,
    plugins: [[compatPlugin, { resolveProxyCompat: { global: 'window.Proxy' } }]]
};

// -- Build -----------------------------
PolyfillBuilder()
.then(ecmaPolyfills => {
    const { code : babelHelpersCompat } = babel.transform(babelHelpers, babelConfig);
    const compatArtifactsSource = polyfillSources + ecmaPolyfills + babelHelpersCompat;

    const compatSrc = [
        '/* proxy-compat */',

babel-plugin-transform-proxy-compat

Babel plugin to transform code to COMPAT mode

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis

Popular babel-plugin-transform-proxy-compat functions