Replace Global Member Expressions Example
const replaceGlobalVariables =
require("@isomorphic/babel-preset/babel-plugin-transform-replace-global-member-expressions");
const plugins = [[replaceGlobalVariables,
{
replacements: { process: { env: { PROCESSOR_COUNT: "4" } } }
}]];
const SAMPLE_CODE =
`
const length = parseInt(process.env.PROCESSOR_COUNT, 10);
const workers = Array.from({ length }).map(() => new Worker());
`;
const babelCompile = require("@babel/core").transform(SAMPLE_CODE, { plugins }).code;
no comments