UNPKG

event-target-shim-es5

Version:

[![npm version](https://img.shields.io/npm/v/event-target-shim-es5.svg)](https://www.npmjs.com/package/event-target-shim-es5) ![Node.js CI](https://github.com/compulim/event-target-shim-es5/workflows/Node.js%20CI/badge.svg)

33 lines (27 loc) 1.04 kB
import { createRequire } from 'module'; import { dirname } from 'path'; import { readPackageUpAsync } from 'read-pkg-up'; import esbuild from 'esbuild'; // The purpose of bundling using esbuild is to walk from the entrypoint and gather all source code in the target package. // We will bundle all gathered source code together and transpile it at once. // We should not need to bundle transient dependencies, they should already in ES5. (async function () { const [packageName, entryPoint, format, outfile] = process.argv.slice(2); const { packageJson: { dependencies = {} } } = await readPackageUpAsync({ cwd: dirname(createRequire(import.meta.url).resolve(packageName)) }); const external = Object.keys(dependencies); external.length && console.log(`Excluding the following dependencies:\n\n${external.map(name => `- ${name}`).join('\n')}`); esbuild .build({ bundle: true, entryPoints: [entryPoint], external, format, outfile }) .catch(() => process.exit(1)); })();