diff --git a/.eslintrc.js b/.eslintrc.js index 7d1f2d453..4d1b202c7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,31 +1,33 @@ -module.exports = { - env: { - es6: true, - browser: true, - commonjs: true, - node: true - }, - extends: 'eslint:recommended', - parserOptions: { - sourceType: 'module' - }, - rules: { - indent: ['error', 4], +module.exports = { + env: { + es6: true, + browser: true, + commonjs: true, + node: true + }, + extends: 'eslint:recommended', + parserOptions: { + sourceType: 'module' + }, + rules: { + indent: ['error', 4], 'linebreak-style': [ - 'error', + 'error', 'unix' - ], + ], quotes: [ - 'error', + 'error', 'single' - ], + ], semi: [ - 'error', + 'error', 'always' - ], - 'no-console': 0, - 'no-undef': - 'warn', - 'no-unused-vars': 'warn' - } + ], + 'no-console': 0, + 'no-undef': 'warn' + }, + globals: { + BigInt64Array: true, + BigUint64Array: true + } }; diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 3a42fd2df..941d7a936 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -410,7 +410,9 @@ impl<'a> Context<'a> { .unwrap_or("wasm_bindgen"), ) } else { - let import_wasm = if self.config.nodejs { + let import_wasm = if self.globals.len() == 0 { + String::new() + } else if self.config.nodejs { self.footer .push_str(&format!("wasm = require('./{}_bg');", module_name)); format!("var wasm;") @@ -956,7 +958,6 @@ impl<'a> Context<'a> { return Ok(()); } self.require_internal_export("__wbindgen_malloc")?; - self.expose_uint64_memory(); self.global(&format!( " function {}(arg) {{ @@ -1059,7 +1060,7 @@ impl<'a> Context<'a> { if !self.exposed_globals.insert("get_array_js_value_from_wasm") { return; } - self.expose_get_array_u32_from_wasm(); + self.expose_uint32_memory(); self.expose_take_object(); self.global( " @@ -1807,8 +1808,8 @@ impl<'a, 'b> SubContext<'a, 'b> { let target = if let Some(g) = getter { if import.structural { format!( - "function(y) {{ - return this.{}; + "function() {{ + return this.{}; }}", g )