Commit Graph

128 Commits

Author SHA1 Message Date
Alex Crichton
f2429be07f Bump to 0.2.43 2019-04-29 08:28:41 -07:00
Alex Crichton
ff1addbbaa Run cargo fmt 2019-04-16 10:52:27 -07:00
Alex Crichton
79f370deef Add env vars to filter wasm-bindgen-test-runner tests
This is intended to handle #1458 and #822. These issues stem from
behavior where:

    wasm-pack test --node

will actually run both Node.js and browser tests! Two new env vars are
read here, `WASM_BINDGEN_TEST_ONLY_{NODE,WEB}`, which control which
tests are executed by `wasm-bindgen-test-runner`. The intention is that
these will be set by `wasm-pack` to configure which tests are run, and
if test suites are skipped due to the env vars we'll print an
informational message indicating how they can be run.

Closes #822
Closes #1458
2019-04-16 10:42:16 -07:00
Alex Crichton
df6e15e3ab Bump to 0.2.42 2019-04-11 07:39:45 -07:00
Alex Crichton
02394724ea Bump to 0.2.41 2019-04-10 10:53:32 -07:00
Alex Crichton
a6fe0cefa8 Migrate all crates to the 2018 edition
Most of the CLI crates were already in the 2018 edition, and it turns
out that one of the macro crates was already in the 2018 edition so we
may as well move everything to the 2018 edition!

Always nice to remove those `extern crate` statements nowadays!

This commit also does a `cargo fmt --all` to make sure we're conforming
with style again.
2019-03-26 08:10:53 -07:00
Alex Crichton
362777fc75 Start implementing a test suite for the CLI
We have very few tests today so this starts to add the basics of a test
suite which compiles Cargo projects on-the-fly which will hopefully help
us bolster the amount of assertions we can make about the output.
2019-03-22 11:32:03 -07:00
Alex Crichton
6803c619bb Bump to 0.2.40 2019-03-21 17:08:48 -07:00
Alex Crichton
995be7c027 Replace target flags with --target
This commit deprecates the `--web`, `--no-modules`, and `--nodejs` flags
in favor of one `--target` flag. The motivation for this commit is to be
consistent between `wasm-bindgen` and `wasm-pack` so documentation for
one is applicable for the other (so we don't have to document everywhere
what the translation is between flags). Additionally this should make it
a bit easier to add new targets (if necessary) in the future as it won't
add to the proliferation of flags.

For now the old flags (like `--web`) continue to be accepted, but
they'll be removed during the next set of breaking changes for
`wasm-bindgen`.
2019-03-21 14:00:33 -07:00
Alex Crichton
228f58dca3 Bump to 0.2.39 2019-03-13 11:02:27 -07:00
Alex Crichton
cd3781cb73 Switch the --browser argument to --web
This commit reverts part of the implementation of [RFC 6]. That RFC
specified that the `--browser` flag was going to be repurposed for the
new "natively loadable as ES module output", but unfortunately the
breakage is far broader than initially expected. It turns out that
`wasm-pack` passes `--browser` by default which means that a change to
break `--browser` would break all historical versions of `wasm-pack`
which is a bit much for now.

To solve this the `--browser` flag is going back to what it represents
on the current released version of `wasm-bindgen` (optimize away some
node.js checks in a few places for bundler-style output) and a new
`--web` flag is being introduced as the new deployment strategy.

[RFC 6]: https://github.com/rustwasm/rfcs/pull/6

Closes #1318
2019-03-07 08:26:36 -08:00
Alex Crichton
795bf7c6b1 Update walrus to 0.5.0 2019-03-06 15:09:20 -08:00
Alex Crichton
bdcfcb49b1 Log webdriver command we execute 2019-03-05 09:33:22 -08:00
Alex Crichton
b762948456 Implement the local JS snippets RFC
This commit is an implementation of [RFC 6] which enables crates to
inline local JS snippets into the final output artifact of
`wasm-bindgen`. This is accompanied with a few minor breaking changes
which are intended to be relatively minor in practice:

* The `module` attribute disallows paths starting with `./` and `../`.
  It requires paths starting with `/` to actually exist on the filesystem.
* The `--browser` flag no longer emits bundler-compatible code, but
  rather emits an ES module that can be natively loaded into a browser.

Otherwise be sure to check out [the RFC][RFC 6] for more details, and
otherwise this should implement at least the MVP version of the RFC!
Notably at this time JS snippets with `--nodejs` or `--no-modules` are
not supported and will unconditionally generate an error.

[RFC 6]: https://github.com/rustwasm/rfcs/pull/6

Closes #1311
2019-03-05 08:00:47 -08:00
Alex Crichton
a659f27c07 Bump to 0.2.38 2019-03-04 09:11:23 -08:00
Alex Crichton
46955735d9
Merge pull request #1298 from LegNeato/fix_high_sierra
Fix headless test runner on macOS High Sierra
2019-02-27 09:32:42 -06:00
Christian Legnitto
e80b0ccdc2 Fix headless test runner on macOS High Sierra 2019-02-26 21:06:45 -07:00
Alex Crichton
860612485d
Merge pull request #1279 from alexcrichton/encode-into
Add support for `TextEncoder#encodeInto`
2019-02-26 12:29:56 -06:00
Alex Crichton
745b16e3d2 Add support for TextEncoder#encodeInto
This commit adds support for the recently implemented standard of
[`TextEncoder#encodeInto`][standard]. This new function is a "bring your
own buffer" style function where we can avoid an intermediate allocation
and copy by encoding strings directly into wasm's memory.

Currently we feature-detect whether `encodeInto` exists as it is only
implemented in recent browsers and not in all browsers. Additionally
this commit emits the binding using `encodeInto` by default, but this
requires `realloc` functionality to be exposed by the wasm module.
Measured locally an empty binary which takes `&str` previously took
7.6k, but after this commit takes 8.7k due to the extra code needed for
`realloc`.

[standard]: https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto

Closes #1172
2019-02-26 10:29:39 -08:00
Alex Crichton
7fbe0210dc Rename test Context in JS
This will hopefully help avoid symbol collisions with other projects
that have a struct named `Context`
2019-02-20 09:23:00 -08:00
Alex Crichton
8fb705a1ef Upgrade to walrus 0.4
Also be sure to have an explicit GC pass!
2019-02-19 14:14:01 -08:00
Alex Crichton
e9f423d57e Bump to 0.2.37 2019-02-15 08:16:24 -08:00
Alex Crichton
5e3cedfaf2 Add a flag to remove producers section
This should help handle instances like the recent Webpack bug and is
also a useful flag in its own right. For now it's set to `false`, but if
the Webpack bug persists through to tomorrow we likely want to publish a
version of `wasm-bindgen` with it default set to `true`.
2019-02-14 10:08:24 -08:00
Nick Fitzgerald
17dc79e4c5 Configure walrus to generate DWARF/names at the right times
Fixes ##1254
2019-02-14 07:20:43 -08:00
Nick Fitzgerald
802cfedcbd Bump to 0.2.36 2019-02-12 13:19:02 -08:00
Nick Fitzgerald
d9cf9b3735 Bump to version 0.2.35 2019-02-12 11:36:19 -08:00
Alex Crichton
894b479213 Migrate wasm-bindgen to using walrus
This commit moves `wasm-bindgen` the CLI tool from internally using
`parity-wasm` for wasm parsing/serialization to instead use `walrus`.
The `walrus` crate is something we've been working on recently with an
aim to replace the usage of `parity-wasm` in `wasm-bindgen` to make the
current CLI tool more maintainable as well as more future-proof.

The `walrus` crate provides a much nicer AST to work with as well as a
structured `Module`, whereas `parity-wasm` provides a very raw interface
to the wasm module which isn't really appropriate for our use case. The
many transformations and tweaks that wasm-bindgen does have a huge
amount of ad-hoc index management to carefully craft a final wasm
binary, but this is all entirely taken care for us with the `walrus`
crate.

Additionally, `wasm-bindgen` will ingest and rewrite the wasm file,
often changing the binary offsets of functions. Eventually with DWARF
debug information we'll need to be sure to preserve the debug
information throughout the transformations that `wasm-bindgen` does
today. This is practically impossible to do with the `parity-wasm`
architecture, but `walrus` was designed from the get-go to solve this
problem transparently in the `walrus` crate itself. (it doesn't today,
but this is planned work)

It is the intention that this does not end up regressing any
`wasm-bindgen` use cases, neither in functionality or in speed. As a
large change and refactoring, however, it's likely that at least
something will arise! We'll want to continue to remain vigilant to any
issues that come up with this commit.

Note that the `gc` crate has been deleted as part of this change, as the
`gc` crate is no longer necessary since `walrus` does it automatically.
Additionally the `gc` crate was one of the main problems with preserving
debug information as it often deletes wasm items!

Finally, this also starts moving crates to the 2018 edition where
necessary since `walrus` requires the 2018 edition, and in general it's
more pleasant to work within the 2018 edition!
2019-02-12 07:25:53 -08:00
Nick Fitzgerald
078257943d Bump to 0.2.34 2019-02-11 18:58:54 -08:00
Nick Fitzgerald
11eeeb8fc8 Use textContent instead of innerHTML for extracting logs from headless browser tests
Easier to maintain fidelity and less likely to be sabotaged by XSS and
`<script>` tags.

Fixes #1232
2019-02-08 10:35:19 +01:00
dependabot[bot]
4a50d7b71c
Update parity-wasm requirement from 0.35 to 0.36
Updates the requirements on [parity-wasm](https://github.com/paritytech/parity-wasm) to permit the latest version.
- [Release notes](https://github.com/paritytech/parity-wasm/releases)
- [Commits](https://github.com/paritytech/parity-wasm/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-04 08:30:40 +00:00
Alex Crichton
78c4075e40 Bump to 0.2.33 2019-01-18 15:32:17 -08:00
Nick Fitzgerald
31fdede9fc Bump to 0.2.32 2019-01-16 13:11:13 -08:00
Nick Fitzgerald
41eefa7425 wasm-bindgen-test: Capture more console logging methods' output
Fixes #1183
2019-01-15 14:05:22 -08:00
Nick Fitzgerald
56c4385f42 wasm-bindgen-test: Rename console_*_redirect to on_console_*
Since we are no longer redirecting all console logs, and are instead just
observing them.
2019-01-14 14:51:28 -08:00
Nick Fitzgerald
a94f3f4403 wasm-bindgen-test: Have the test runner JS call the original console.log
This makes control flow a little easier to follow and avoids wasm->js->wasm
re-entrancy.
2019-01-14 14:51:28 -08:00
Nick Fitzgerald
51ef19b85f wasm-bindgen-test: Use spread array arguments instead of arguments objects
Our testing runtime tries to call `Array.prototype.forEach` on this object, so
it had damn well better be a proper array!

Fixes #1167
2019-01-14 14:51:28 -08:00
Alex Crichton
b04f60cf2b Bump to 0.2.31 2019-01-09 09:17:50 -08:00
Alex Crichton
fbf000a508 Bump to 0.2.30 2019-01-07 07:47:07 -08:00
dependabot[bot]
1610d199e3
Update rouille requirement from 2.1.0 to 3.0.0
Updates the requirements on [rouille](https://github.com/tomaka/rouille) to permit the latest version.
- [Release notes](https://github.com/tomaka/rouille/releases)
- [Changelog](https://github.com/tomaka/rouille/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tomaka/rouille/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-10 08:16:06 +00:00
DavidOConnor
a4bc5049c6 Added an --out-name param to the CLI, to allow custom output file names 2018-12-04 21:35:05 -05:00
Alex Crichton
63e3ba722d Bump to 0.2.29 2018-12-04 06:04:47 -08:00
Alex Crichton
29531c0abf Run rustfmt 2018-11-30 13:04:27 -08:00
Alex Crichton
5f966c5a8f
Merge pull request #1063 from alexcrichton/wasm2es6js-start
wasm2es6js: Fix handling of start function
2018-11-29 17:30:24 -06:00
Alex Crichton
430fce7a8b Enable env_logger for the wasm-bindgen CLI tool
This was intended earlier, but fogotten! Found during work on #1002
2018-11-29 12:25:24 -08:00
Alex Crichton
82bfbf9d20 Add more context to a wasm-bindgen-test-runner error
Minor cleanup I found during #1002
2018-11-29 12:25:10 -08:00
Alex Crichton
522e973694 wasm2es6js: Fix handling of start function
This is split out from #1002 and is intended to fix the tool's handling
of the `start` function. For the most accurate emulation of the wasm ESM
spec I believe we need to defer execution of the start function until
all our exports are wired up which should allow valid cyclical
references during instantiation.

The fix here is to remove the start function, if one is present, and
inject an invocation of it at the end of initialization (after our
exports are wired up). This fixes tests on #1002, but doesn't have any
direct analogue for tests here just yet.

Along the way because multiple files now come out of `wasm2es6js` by
default I've added an `--out-dir` argument as well as `-o` to ensure
that a folder for all outputs can be specified.
2018-11-29 11:52:23 -08:00
Alex Crichton
a2aa28e4d3 Add a #[wasm_bindgen(start)] attribute
This commit adds a new attribute to `#[wasm_bindgen]`: `start`. The
`start` attribute can be used to indicate that a function should be
executed when the module is loaded, configuring the `start` function of
the wasm executable. While this doesn't necessarily literally configure
the `start` section, it does its best!

Only one crate in a crate graph may indicate `#[wasm_bindgen(start)]`,
so it's not recommended to be used in libraries but only end-user
applications. Currently this still must be used with the `crate-type =
["cdylib"]` annotation in `Cargo.toml`.

The implementation here is somewhat tricky because of the circular
dependency between our generated JS and the wasm file that we emit. This
circular dependency makes running initialization routines (like the
`start` shim) particularly fraught with complications because one may
need to run before the other but bundlers may not necessarily respect
it. Workarounds have been implemented for various emission strategies,
for example calling the start function directly after exports are wired
up with `--no-modules` and otherwise working around what appears to be
a Webpack bug with initializers running in a different order than we'd
like. In any case, this in theory doesn't show up to the end user!

Closes #74
2018-11-28 22:11:15 -08:00
Alex Crichton
48f4adfa8c Run rustfmt over everything 2018-11-27 12:07:59 -08:00
Alex Crichton
22ca15f81e Bump to 0.2.28 2018-11-12 09:28:01 -08:00
Alex Crichton
dc4e78550a
Merge pull request #1019 from alexcrichton/rfc-5
Implement rustwasm/rfcs#5, implement `Deref` for imports and `structural` by default
2018-11-12 10:59:46 -06:00