forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-driver.mjs
More file actions
executable file
·53 lines (48 loc) · 1.35 KB
/
bundle-driver.mjs
File metadata and controls
executable file
·53 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
import fs from 'node:fs/promises';
import { isBuiltin } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as esbuild from 'esbuild';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.join(__dirname, '..');
const outdir = path.join(rootDir, 'test/tools/runner/bundle/');
await fs.rm(outdir, { recursive: true, force: true });
const outputBundleFile = path.join(outdir, 'driver-bundle.js');
await esbuild.build({
entryPoints: [path.join(rootDir, 'test/mongodb_all.ts')],
bundle: true,
outfile: outputBundleFile,
platform: 'node',
format: 'cjs',
target: 'node20',
external: [
'@aws-sdk/credential-providers',
'@mongodb-js/saslprep',
'@mongodb-js/zstd',
'@napi-rs/snappy*',
'bson',
'gcp-metadata',
'kerberos',
'mongodb-client-encryption',
'mongodb-connection-string-url',
'snappy',
'socks'
],
plugins: [
{
name: 'externalize-node-builtins',
setup(build) {
build.onResolve({ filter: /.*/ }, args => {
if (isBuiltin(args.path)) {
return { path: args.path, external: true };
}
});
}
}
],
sourcemap: 'inline',
logLevel: 'info'
});
// eslint-disable-next-line no-console
console.log(`✓ Driver bundle created at ${outputBundleFile}`);