How to use the builtin-modules.reduce function in builtin-modules

To help you get started, we’ve selected a few builtin-modules 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 VirgilSecurity / virgil-crypto-c / wrappers / wasm / rollup.config.js View on Github external
const fs = require('fs');
const path = require('path');

const builtinModules = require('builtin-modules');
const commonjs = require('rollup-plugin-commonjs');
const copy = require('rollup-plugin-copy');
const nodeResolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const { terser } = require('rollup-plugin-terser');

const builtinModulesMap = builtinModules.reduce((result, item) => {
  result[item] = item;
  return result;
}, {});

const formats = ['cjs', 'es'];

const project = process.env.PROJECT;
if (typeof project !== 'string') {
  throw new TypeError(`'${project}' is not a valid project`);
}

const sourcePath = path.join(__dirname, project);
const outputPath = path.join(__dirname, 'dist', project);

const createEntry = (inputFilePath, libraryFilePath, format, outputFilePath) => ({
  input: inputFilePath,
github VirgilSecurity / virgil-crypto-c / wrappers / wasm / foundation_demo / rollup.config.js View on Github external
const path = require('path');

const builtinModules = require('builtin-modules');
const commonjs = require('rollup-plugin-commonjs');
const copy = require('rollup-plugin-copy');
const nodeResolve = require('rollup-plugin-node-resolve');
const { terser } = require('rollup-plugin-terser');

const UMD_NAME = 'Foundation';

const wasmBuildRoot = path.join(__dirname, '..', '..', '..', 'build', 'wrappers', 'wasm', 'foundation');
const sourceRoot = path.join(__dirname, 'src');
const outputFolder = path.join(__dirname, 'dist');

const builtinModulesMap = builtinModules.reduce((result, item) => {
  result[item] = item;
  return result;
}, {});

const format = process.env.FORMAT;
const formats = {
  cjs: 'cjs',
  es: 'es',
  umd: 'umd',
};
if (!formats[format]) {
  throw new TypeError(`'${format}' is not a valid format`);
}

module.exports = {
  input: path.join(sourceRoot, 'index.js'),

builtin-modules

A static list of the Node.js builtin modules from the latest Node.js version

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis