aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-01-24 20:04:55 +0100
committerGitHub <[email protected]>2022-01-24 20:04:55 +0100
commit12e33654d183889459d51e9f44c39e51cf7c3bb3 (patch)
tree4d55ef5c8fd444f1575baf73028bdecce84497c5 /scripts
parenta3792251766ed9a87a59c760ea87f64792e54caa (diff)
downloadfaker-12e33654d183889459d51e9f44c39e51cf7c3bb3.tar.xz
faker-12e33654d183889459d51e9f44c39e51cf7c3bb3.zip
build: bundle with esbuild (#257)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bundle.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/bundle.ts b/scripts/bundle.ts
new file mode 100644
index 00000000..793f27a1
--- /dev/null
+++ b/scripts/bundle.ts
@@ -0,0 +1,40 @@
+import { buildSync } from 'esbuild';
+import { sync as globSync } from 'glob';
+import locales from '../src/locales';
+
+console.log('Building dist for node (cjs)...');
+buildSync({
+ entryPoints: globSync('./src/**/*.ts'),
+ // We can use the following entry points when esbuild supports cjs+splitting
+ // entryPoints: [
+ // './src/index.ts',
+ // ...Object.keys(locales).map((locale) => `./src/locale/${locale}.ts`),
+ // './src/iban.ts',
+ // './src/mersenne.ts',
+ // ],
+ outdir: './dist/cjs',
+ bundle: false, // Creates 390MiB bundle ...
+ sourcemap: false,
+ minify: true,
+ // splitting: true, // Doesn't work with cjs
+ format: 'cjs',
+ platform: 'node',
+ target: 'node12',
+});
+
+console.log('Building dist for node type=module (esm)...');
+buildSync({
+ entryPoints: [
+ './src/index.ts',
+ ...Object.keys(locales).map((locale) => `./src/locale/${locale}.ts`),
+ './src/iban.ts',
+ './src/mersenne.ts',
+ ],
+ outdir: './dist/esm',
+ bundle: true,
+ sourcemap: false,
+ minify: true,
+ splitting: true,
+ format: 'esm',
+ target: 'node12.20',
+});