forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
56 lines (47 loc) · 1.62 KB
/
Copy pathesbuild.js
File metadata and controls
56 lines (47 loc) · 1.62 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
54
55
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
let wasmPlugin = {
name: 'wasm',
setup(build) {
let path = require('path')
let fs = require('fs')
// Resolve ".wasm" files to a path with a namespace
build.onResolve({ filter: /\.wasm$/ }, args => {
return {
path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),
namespace: 'wasm-binary',
}
})
// Virtual modules in the "wasm-binary" namespace contain the
// actual bytes of the WebAssembly file. This uses esbuild's
// built-in "binary" loader instead of manually embedding the
// binary data inside JavaScript code ourselves.
build.onLoad({ filter: /.*/, namespace: 'wasm-binary' }, async (args) => {
return ({
contents: await fs.promises.readFile(args.path),
loader: 'binary',
});
})
},
}
let esbuild = require('esbuild')
esbuild.build({
entryPoints: ['src/browser.ts'],
bundle: true,
external: ['vscode'],
outfile: 'out/browser.js',
format: 'cjs',
}).catch(() => process.exit(1))
esbuild.build({
entryPoints: ['browser-language-server/browserServerMain.ts'],
bundle: true,
outfile: 'out/browserServerMain.js',
format: 'iife',
plugins: [wasmPlugin],
}).catch(() => process.exit(1))
esbuild.build({
entryPoints: ['src/extension.ts'],
bundle: false,
outfile: 'out/extension.js',
format: 'cjs',
}).catch(() => process.exit(1))