mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-16 06:21:22 +00:00
Speed up Travis by running Webpack in fewer tests (#381)
* Reorganize Travis configuration * Add a `JOB` env var descriptor to all matrix entries. Not used anywhere but is useful when viewing the whole build on Travis's web interface. * Reorganize where builds are located, moving slow builds first and fast ones last. * Change checking the CLI builds from `cargo build` to `cargo check` * Use YAML references to reduce some duplication * Print some more timing statistics for each test * Extract `Project` helper in tests to a module This'll help make it a bit more extensible over time. At the same time the methods are also slightly reorganized to read more clearly from top to bottom. * Migrate all tests away from Webpack Wepback can take a significant amount of time to execute and when it's multiplied by hundreds of tests that adds up really quickly! After investigating Node's `--experimental-modules` option it looks like it's suitable for our use so this switches all tests to using JS files (moving away from TypeScript as well) with `--experimental-modules` with Node. Tests will be selectively re-enabled with webpack and node.js specific output (that doesn't require `--experimental-modules`), coming in later commits. * Restore the node test for node.js output Ensures it's workable as-is * Only generate typescript with webpack * Only read wasm files for webpack * Skip package.json/node_modules for now * Only generate webpack config if needed * Start a dedicated test module for typescript Will hopefully verify the generated Typescript compiles OK. * Remove unneeded `node` method * Fixup some rebase conflicts * Don't run asmjs example on travis * Fixup generator tests * Attempt to fix windows * Comment windows fix * More test fixes * More exclusions * More test fixes * Relax eslint regex Catch mjs modules as well * Fix eslint * Speed up travis on examples slightly
This commit is contained in:
@ -60,7 +60,7 @@ impl<'a> Context<'a> {
|
||||
if let Some(ref c) = comments {
|
||||
self.globals.push_str(c);
|
||||
}
|
||||
let global = if self.config.nodejs {
|
||||
let global = if self.use_node_require() {
|
||||
if contents.starts_with("class") {
|
||||
format!("{1}\nmodule.exports.{0} = {0};\n", name, contents)
|
||||
} else {
|
||||
@ -412,12 +412,12 @@ impl<'a> Context<'a> {
|
||||
} else {
|
||||
let import_wasm = if self.globals.len() == 0 {
|
||||
String::new()
|
||||
} else if self.config.nodejs {
|
||||
} else if self.use_node_require() {
|
||||
self.footer
|
||||
.push_str(&format!("wasm = require('./{}_bg');", module_name));
|
||||
format!("var wasm;")
|
||||
} else {
|
||||
format!("import * as wasm from './{}_bg.wasm';", module_name)
|
||||
format!("import * as wasm from './{}_bg';", module_name)
|
||||
};
|
||||
|
||||
format!(
|
||||
@ -977,7 +977,9 @@ impl<'a> Context<'a> {
|
||||
if !self.exposed_globals.insert("text_encoder") {
|
||||
return;
|
||||
}
|
||||
if self.config.nodejs {
|
||||
if self.config.nodejs_experimental_modules {
|
||||
self.imports.push_str("import { TextEncoder } from 'util';\n");
|
||||
} else if self.config.nodejs {
|
||||
self.global(
|
||||
"
|
||||
const TextEncoder = require('util').TextEncoder;
|
||||
@ -1003,7 +1005,9 @@ impl<'a> Context<'a> {
|
||||
if !self.exposed_globals.insert("text_decoder") {
|
||||
return;
|
||||
}
|
||||
if self.config.nodejs {
|
||||
if self.config.nodejs_experimental_modules {
|
||||
self.imports.push_str("import { TextDecoder } from 'util';\n");
|
||||
} else if self.config.nodejs {
|
||||
self.global(
|
||||
"
|
||||
const TextDecoder = require('util').TextDecoder;
|
||||
@ -1585,6 +1589,10 @@ impl<'a> Context<'a> {
|
||||
*section.payload_mut() = contents.into_bytes();
|
||||
self.module.sections_mut().push(Section::Custom(section));
|
||||
}
|
||||
|
||||
fn use_node_require(&self) -> bool {
|
||||
self.config.nodejs && !self.config.nodejs_experimental_modules
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> SubContext<'a, 'b> {
|
||||
@ -1944,7 +1952,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
let name = import.js_namespace.as_ref().map(|s| &**s).unwrap_or(item);
|
||||
|
||||
if self.cx.imported_names.insert(name.to_string()) {
|
||||
if self.cx.config.nodejs {
|
||||
if self.cx.use_node_require() {
|
||||
self.cx.imports.push_str(&format!(
|
||||
"\
|
||||
const {} = require('{}').{};\n\
|
||||
|
Reference in New Issue
Block a user