Skip to content

Commit 9b9a093

Browse files
committed
fix(warning): add buffer as external dependency
this will dismiss warning: ```console 'buffer' is imported but could not be resolved – treating it as an external dependency ```
1 parent 8717c44 commit 9b9a093

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ export default function(options: $Shape<Options> = {}) {
1919

2020
return {
2121
name: 'rust',
22+
options(opts: any) {
23+
let external: string[] | ((id: string) => boolean);
24+
25+
if (typeof opts.external === 'function')
26+
external = id => opts.external(id) || id.includes('buffer');
27+
28+
if (Array.isArray(opts.external))
29+
external = Array.from(new Set(opts.external.concat('buffer')));
30+
31+
return Object.assign({}, opts, { external });
32+
},
2233
async transform(code: string, id: string) {
2334
if (!extension.test(id)) return;
2435
if (!filter(id)) return;
@@ -39,7 +50,7 @@ export default function(options: $Shape<Options> = {}) {
3950
return wrap(wasmCode).asWebAssembly.Instance;
4051
case 'module':
4152
return wrap(wasmCode).asWebAssembly.Module;
42-
case 'promise' || 'async':
53+
case 'async':
4354
return wrap(wasmCode).promiseWebAssembly.Both;
4455
case 'async-instance':
4556
return wrap(wasmCode).promiseWebAssembly.Instance;

0 commit comments

Comments
 (0)