Skip to content

Commit 01fe338

Browse files
committed
add otel
1 parent a73ed6f commit 01fe338

File tree

7 files changed

+2165
-214
lines changed

7 files changed

+2165
-214
lines changed

build.ts

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,77 @@ import esbuild from 'esbuild';
88

99
const isWatchMode = process.argv.includes('--watch');
1010
const options: BuildOptions = {
11-
color: true,
12-
logLevel: 'info',
13-
entryPoints: ['src/extension.ts'],
14-
bundle: true,
15-
metafile: process.argv.includes('--metafile'),
16-
outdir: './out/src',
17-
external: [
18-
'vscode',
19-
'typescript', // vue-component-meta
20-
],
21-
format: 'cjs',
22-
platform: 'node',
23-
target: 'ESNext',
24-
tsconfig: 'src/tsconfig.json',
25-
sourcemap: process.argv.includes('--sourcemap'),
26-
minify: process.argv.includes('--minify'),
27-
plugins: [
28-
{
29-
name: 'umd2esm',
30-
setup(build) {
31-
build.onResolve({ filter: /^(vscode-.*|estree-walker|jsonc-parser)/ }, (args) => {
32-
const pathUmdMay = require.resolve(args.path, {
33-
paths: [args.resolveDir],
34-
});
35-
// Call twice the replace is to solve the problem of the path in Windows
36-
const pathEsm = pathUmdMay
37-
.replace('/umd/', '/esm/')
38-
.replace('\\umd\\', '\\esm\\');
39-
return { path: pathEsm };
40-
});
41-
},
42-
},
43-
{
44-
name: 'meta',
45-
setup(build) {
46-
build.onEnd(async (result) => {
47-
if (result.metafile && result.errors.length === 0) {
48-
return fs.writeFile(
49-
path.resolve(__dirname, './meta.json'),
50-
JSON.stringify(result.metafile),
51-
);
52-
}
53-
});
54-
},
55-
},
56-
],
11+
color: true,
12+
logLevel: 'info',
13+
entryPoints: ['src/extension.ts'],
14+
bundle: true,
15+
metafile: process.argv.includes('--metafile'),
16+
outdir: './out/src',
17+
external: [
18+
'vscode',
19+
'typescript', // vue-component-meta
20+
],
21+
format: 'cjs',
22+
platform: 'node',
23+
target: 'ESNext',
24+
tsconfig: 'src/tsconfig.json',
25+
sourcemap: process.argv.includes('--sourcemap'),
26+
minify: process.argv.includes('--minify'),
27+
plugins: [
28+
{
29+
name: 'umd2esm',
30+
setup(build) {
31+
build.onResolve(
32+
{ filter: /^(vscode-.*|estree-walker|jsonc-parser)/ },
33+
(args) => {
34+
const pathUmdMay = require.resolve(args.path, {
35+
paths: [args.resolveDir],
36+
});
37+
// Call twice the replace is to solve the problem of the path in Windows
38+
const pathEsm = pathUmdMay
39+
.replace('/umd/', '/esm/')
40+
.replace('\\umd\\', '\\esm\\');
41+
return { path: pathEsm };
42+
}
43+
);
44+
},
45+
},
46+
{
47+
name: 'meta',
48+
setup(build) {
49+
build.onEnd(async (result) => {
50+
if (result.metafile && result.errors.length === 0) {
51+
return fs.writeFile(
52+
path.resolve(__dirname, './meta.json'),
53+
JSON.stringify(result.metafile)
54+
);
55+
}
56+
});
57+
},
58+
},
59+
],
5760
};
5861

5962
async function main() {
60-
let ctx: BuildContext | undefined;
61-
try {
62-
if (isWatchMode) {
63-
ctx = await esbuild.context(options);
64-
await ctx.watch();
65-
} else {
66-
const result = await esbuild.build(options);
63+
let ctx: BuildContext | undefined;
64+
try {
65+
if (isWatchMode) {
66+
ctx = await esbuild.context(options);
67+
await ctx.watch();
68+
} else {
69+
const result = await esbuild.build(options);
6770
if (process.argv.includes('--analyze')) {
68-
const chunksTree = await esbuild.analyzeMetafile(result.metafile!, { color: true });
69-
console.log(chunksTree);
70-
}
71-
}
72-
} catch (error) {
73-
console.error(error);
74-
ctx?.dispose();
75-
process.exit(1);
76-
}
71+
const chunksTree = await esbuild.analyzeMetafile(result.metafile!, {
72+
color: true,
73+
});
74+
console.log(chunksTree);
75+
}
76+
}
77+
} catch (error) {
78+
console.error(error);
79+
ctx?.dispose();
80+
process.exit(1);
81+
}
7782
}
7883

79-
main();
84+
main();

0 commit comments

Comments
 (0)