Open nohaapav opened 1 year ago
import { defineConfig } from 'tsup'; import { wasmLoader } from 'esbuild-plugin-wasm'; const wasmPlugin = wasmLoader({ mode: 'embedded' }); export default defineConfig(({ watch }) => ({ entry: ['src/index.ts'], format: 'esm', outDir: 'build', target: 'esnext', minify: true, clean: true, esbuildPlugins: [wasmPlugin], esbuildOptions(options, context) { context.format = 'esm'; }, outExtension({ format }) { console.log(format); const ext = format === 'esm' ? 'mjs' : 'cjs'; return { js: `.${ext}`, }; }, }));
If i use plugin directly in esbuild wasms are loaded see:
// ESM bundle esbuild .build({ entryPoints: ['src/index.ts'], outfile: 'build/index.mjs', bundle: true, minify: true, plugins: [wasmPlugin], format: 'esm', platform: 'browser', target: ['esnext'], }) .catch(() => process.exit(1));
Seems like some issue with filter, see not picking up: /\.(?:wasm)$/
/\.(?:wasm)$/
If i use plugin directly in esbuild wasms are loaded see:
Upvote & Fund