Skip to content

Commit 86b72f0

Browse files
committed
chore: remove terser and update build script
1 parent 76cc787 commit 86b72f0

File tree

4 files changed

+49
-57
lines changed

4 files changed

+49
-57
lines changed

.terser.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fi
2323
SMALLEST_WASM=$(ls -Sr build/clang-format-e*.wasm | head -1)
2424

2525
cp $SMALLEST_WASM pkg/clang-format.wasm
26-
npm exec terser -- src/template.js build/clang-format-esm.js --config-file .terser.json --output pkg/clang-format.js
26+
cat src/template.js build/clang-format-esm.js >pkg/clang-format.js
2727

2828
# add shebang
2929
echo '#!/usr/bin/env node' | cat - ./build/clang-format-cli.js >./pkg/clang-format-cli.cjs

src/clang-format.d.ts

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export type InitInput =
2-
| RequestInfo
3-
| URL
4-
| Response
5-
| BufferSource
6-
| WebAssembly.Module;
2+
| RequestInfo
3+
| URL
4+
| Response
5+
| BufferSource
6+
| WebAssembly.Module;
77

88
export default function init(input?: InitInput): Promise<void>;
99

@@ -22,33 +22,33 @@ export default function init(input?: InitInput): Promise<void>;
2222
*
2323
*/
2424
export type Style =
25-
| "LLVM"
26-
| "Google"
27-
| "Chromium"
28-
| "Mozilla"
29-
| "WebKit"
30-
| "Microsoft"
31-
| "GNU"
32-
| (string & {});
25+
| "LLVM"
26+
| "Google"
27+
| "Chromium"
28+
| "Mozilla"
29+
| "WebKit"
30+
| "Microsoft"
31+
| "GNU"
32+
| (string & {});
3333

3434
/**
3535
* The filename to use for determining the language.
3636
*/
3737
export type Filename =
38-
| "main.c"
39-
| "main.cc"
40-
| "main.cxx"
41-
| "main.cpp"
42-
| "main.java"
43-
| "main.js"
44-
| "main.mjs"
45-
| "main.ts"
46-
| "main.json"
47-
| "main.m"
48-
| "main.mm"
49-
| "main.proto"
50-
| "main.cs"
51-
| (string & {});
38+
| "main.c"
39+
| "main.cc"
40+
| "main.cxx"
41+
| "main.cpp"
42+
| "main.java"
43+
| "main.js"
44+
| "main.mjs"
45+
| "main.ts"
46+
| "main.json"
47+
| "main.m"
48+
| "main.mm"
49+
| "main.proto"
50+
| "main.cs"
51+
| (string & {});
5252

5353
/**
5454
* Formats the given content using the specified style.
@@ -73,9 +73,9 @@ export type Filename =
7373
* @see {@link https://clang.llvm.org/docs/ClangFormatStyleOptions.html}
7474
*/
7575
export declare function format(
76-
content: string,
77-
filename?: Filename,
78-
style?: Style,
76+
content: string,
77+
filename?: Filename,
78+
style?: Style,
7979
): string;
8080

8181
/**
@@ -91,7 +91,6 @@ export type ByteRange = [offset: number, length: number];
9191
/**
9292
* Formats the specified range of lines in the given content using the specified style.
9393
*
94-
*
9594
* @param {string} content - The content to format.
9695
* @param {LineRange[]} range - Array<[startLine, endLine]> - The range of lines to format.
9796
* Both startLine and endLine are 1-based.
@@ -115,24 +114,24 @@ export type ByteRange = [offset: number, length: number];
115114
* @see {@link https://clang.llvm.org/docs/ClangFormatStyleOptions.html}
116115
*/
117116
export declare function format_line_range(
118-
content: string,
119-
range: ByteRange[] | [[offset: number]],
120-
filename?: Filename,
121-
style?: Style,
117+
content: string,
118+
range: ByteRange[] | [[offset: number]],
119+
filename?: Filename,
120+
style?: Style,
122121
): string;
123122

124123
/**
125124
* @deprecated Use `format_line_range` instead.
126125
*/
127126
export declare function formatLineRange(
128-
content: string,
129-
range: ByteRange[] | [[offset: number]],
130-
filename?: Filename,
131-
style?: Style,
127+
content: string,
128+
range: ByteRange[] | [[offset: number]],
129+
filename?: Filename,
130+
style?: Style,
132131
): string;
133132

134133
/**
135-
* ormats the specified range of bytes in the given content using the specified style.
134+
* Formats the specified range of bytes in the given content using the specified style.
136135
*
137136
* @param {string} content - The content to format.
138137
* @param {ByteRange[]} range - Array<[offset, length]> - The range of bytes to format.
@@ -155,20 +154,20 @@ export declare function formatLineRange(
155154
* @see {@link https://clang.llvm.org/docs/ClangFormatStyleOptions.html}
156155
*/
157156
export declare function format_byte_range(
158-
content: string,
159-
range: LineRange[],
160-
filename?: Filename,
161-
style?: Style,
157+
content: string,
158+
range: LineRange[],
159+
filename?: Filename,
160+
style?: Style,
162161
): string;
163162

164163
/**
165164
* @deprecated Use `format_byte_range` instead.
166165
*/
167166
export declare function formatByteRange(
168-
content: string,
169-
range: LineRange[],
170-
filename?: Filename,
171-
style?: Style,
167+
content: string,
168+
range: LineRange[],
169+
filename?: Filename,
170+
style?: Style,
172171
): string;
173172

174173
export declare function version(): string;

src/template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* @ts-self-types="./clang-format.d.ts" */
12
async function load(module) {
23
if (typeof Response === "function" && module instanceof Response) {
34
if ("compileStreaming" in WebAssembly) {

0 commit comments

Comments
 (0)