Replace Global Member Expressions Example

node v10.24.1
version: 1.0.0
endpointsharetweet
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;
Loading…

no comments

    sign in to comment