Skip to content

Commit

Permalink
fix(build): Source maps would not load due to missing mappings.wasm
Browse files Browse the repository at this point in the history
… file (fixes #114) (#115)

I knew that bundling wasn't as easy as it seemed!
  • Loading branch information
JakeShirley authored Jul 31, 2024
1 parent 8deb80e commit c067632
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 12 deletions.
20 changes: 18 additions & 2 deletions esbuild.js → esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
const esbuild = require('esbuild');
import * as esbuild from 'esbuild';
import { copy } from 'esbuild-plugin-copy';

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

async function main() {
// Copy source-map wasm file to dist folder
const copySourceMapWasm = copy({
// this is equal to process.cwd(), which means we use cwd path as base path to resolve `to` path
// if not specified, this plugin uses ESBuild.build outdir/outfile options as base path.
resolveFrom: 'cwd',
assets: {
from: ['./node_modules/source-map/lib/*.wasm'],
to: ['./dist'],
},
watch: watch,
});

/**
* @type {import('esbuild').BuildOptions}
*/
const buildOptions = {
entryPoints: ['src/extension.ts'],
bundle: true,
Expand All @@ -15,7 +31,7 @@ async function main() {
outfile: 'dist/extension.js',
external: ['vscode'],
logLevel: 'silent',
plugins: [esbuildProblemMatcherPlugin],
plugins: [esbuildProblemMatcherPlugin, copySourceMapWasm],
};

if (watch) {
Expand Down
Loading

0 comments on commit c067632

Please sign in to comment.