UNPKG

908 BJavaScriptView Raw
1const esbuild = require('esbuild')
2// tiny glob is a dependency of `esbuild-plugin-glob`.
3// For this build however we need to filter out some extra files
4// that are used for nodejs, but not in browsers, so we use the
5// library directly instead of using `esbuild-plugin-glob` as a plugin
6const glob = require('tiny-glob');
7
8async function main() {
9 const results = await glob('src/**/**.js')
10 // we remove node specific files here, with the assumption that
11 // the common use case is bundling into browser based web apps
12 const justBrowserCompatibleFiles = results.filter(filepath => !filepath.endsWith('node.js'))
13
14 esbuild.build({
15 entryPoints: justBrowserCompatibleFiles,
16 bundle: false,
17 minify: false,
18 sourcemap: false,
19 target: ['chrome58', 'firefox57', 'safari11', 'edge18', 'esnext'],
20 outdir: 'dist/esm',
21 outExtension: { '.js': '.js' },
22 format: 'esm'
23 })
24}
25main()