File size: 1,872 Bytes
5ed446f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import esbuild from 'esbuild';
import resolve from 'esbuild-plugin-resolve';
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import textReplace from 'esbuild-plugin-text-replace'

await esbuild.build({
    entryPoints: ['./app.js'],
    bundle: true,
    format: 'esm',
    outfile: './dist/cloudflare-workers-min.js',
    external: [],
    plugins: [
        resolve({
            crypto: 'crypto-browserify'
        }),
        NodeGlobalsPolyfillPlugin({
            process: true,
            buffer: true,
        }),
        NodeModulesPolyfillPlugin(),
    ],
    minify: true,
});

await esbuild.build({
    entryPoints: ['./app.js'],
    bundle: true,
    format: 'esm',
    outfile: './dist/cloudflare-workers.js',
    external: [],
    plugins: [
        resolve({
            crypto: 'crypto-browserify'
        }),
        NodeGlobalsPolyfillPlugin({
            process: true,
            buffer: true,
        }),
        NodeModulesPolyfillPlugin(),
    ],
});

await esbuild.build({
    entryPoints: ['./deno.js'],
    bundle: true,
    format: 'esm',
    outfile: './dist/deno.js',
    external: [],
    plugins: [
        textReplace({
            include: new RegExp("src/providers/netease/crypto\.js"),
            pattern: [
                ["import crypto from 'crypto-browserify'", "import crypto from 'https://esm.sh/crypto-browserify@3.12.0'"],
                ["import { Buffer } from 'buffer/index.js'","import { Buffer } from 'https://esm.sh/buffer@6.0.3'"]
            ]
        }),
        resolve({
            crypto: 'crypto-browserify'
        }),
        NodeGlobalsPolyfillPlugin({
            process: true,
            buffer: true,
        }),
        NodeModulesPolyfillPlugin(),

    ],
    // minify: true,
});