Skip to content

Commit c067632

Browse files
authored
fix(build): Source maps would not load due to missing mappings.wasm file (fixes #114) (#115)
I knew that bundling wasn't as easy as it seemed!
1 parent 8deb80e commit c067632

File tree

4 files changed

+420
-12
lines changed

4 files changed

+420
-12
lines changed

esbuild.js renamed to esbuild.mjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
const esbuild = require('esbuild');
1+
import * as esbuild from 'esbuild';
2+
import { copy } from 'esbuild-plugin-copy';
23

34
const production = process.argv.includes('--production');
45
const watch = process.argv.includes('--watch');
56

67
async function main() {
8+
// Copy source-map wasm file to dist folder
9+
const copySourceMapWasm = copy({
10+
// this is equal to process.cwd(), which means we use cwd path as base path to resolve `to` path
11+
// if not specified, this plugin uses ESBuild.build outdir/outfile options as base path.
12+
resolveFrom: 'cwd',
13+
assets: {
14+
from: ['./node_modules/source-map/lib/*.wasm'],
15+
to: ['./dist'],
16+
},
17+
watch: watch,
18+
});
19+
20+
/**
21+
* @type {import('esbuild').BuildOptions}
22+
*/
723
const buildOptions = {
824
entryPoints: ['src/extension.ts'],
925
bundle: true,
@@ -15,7 +31,7 @@ async function main() {
1531
outfile: 'dist/extension.js',
1632
external: ['vscode'],
1733
logLevel: 'silent',
18-
plugins: [esbuildProblemMatcherPlugin],
34+
plugins: [esbuildProblemMatcherPlugin, copySourceMapWasm],
1935
};
2036

2137
if (watch) {

0 commit comments

Comments
 (0)