Commit Graph

2278 Commits

Author SHA1 Message Date
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
f161717afe Try another github connection for next release 2019-03-04 13:47:25 -08:00
Alex Crichton
3034523d39 Fix azure pipelines syntax 2019-03-04 13:39:09 -08:00
Alex Crichton
d8ac6e074b Only publish github release on tags 2019-03-04 13:38:25 -08:00
Alex Crichton
0f6e62a09b Fix publicatin to github 2019-03-04 13:12:39 -08:00
Alex Crichton
688bc29e44
Merge pull request #1310 from alexcrichton/bump
Bump to 0.2.38
2019-03-04 11:53:56 -06:00
Alex Crichton
86c6331e14 Fix a bug in azure pipelines config 2019-03-04 09:39:15 -08:00
Alex Crichton
a659f27c07 Bump to 0.2.38 2019-03-04 09:11:23 -08:00
Alex Crichton
1116af4450
Merge pull request #1309 from dlrobertson/master
Update tests after nightly fix
2019-03-04 09:52:25 -06:00
Alex Crichton
fe604d401d Remove outdated badges 2019-03-04 07:46:49 -08:00
Alex Crichton
407f4e294b
Merge pull request #1308 from johnterickson/master
Add build badge for Azure Pipelines
2019-03-04 09:46:02 -06:00
Dan Robertson
7ad5426714
Update tests after nightly fix 2019-03-04 02:14:57 +00:00
John Erickson
ea5e5269a9 Add build badge for Azure Pipelines 2019-03-01 19:56:33 -08:00
Nick Fitzgerald
ba84db5007
Merge pull request #1281 from fitzgen/new-fn-once
Add support for `FnOnce` to `Closure<T>`
2019-03-01 14:30:19 -08:00
Nick Fitzgerald
b5a8e98355 Ensure we always use a node version with Array#values 2019-03-01 14:16:03 -08:00
Nick Fitzgerald
43a05d682d Do run doctests for wasm-bindgen
We just `no_run` things, but make sure that they still compile.
2019-03-01 13:18:48 -08:00
Nick Fitzgerald
2ce57a7fa1 Add support for FnOnce to Closure 2019-03-01 13:18:48 -08:00
Alex Crichton
1299a2086f
Merge pull request #1307 from alexcrichton/fix-name
Fix name of "current thread ID" intrinsic
2019-03-01 12:48:53 -06:00
Alex Crichton
dad0de4f8b Work around a nightly regression 2019-03-01 10:48:03 -08:00
Alex Crichton
1031d9dea6 Work around rust-lang/rust#58853 2019-03-01 10:47:27 -08:00
Alex Crichton
5db467fc2d
Merge pull request #1300 from rustwasm/azure-pipelines
Switch CI to Azure Pipelines
2019-03-01 12:29:56 -06:00
Alex Crichton
9ac8a974a9 Fix name of "current thread ID" intrinsic
This was accidentally renamed in the transition to `walrus`, but
upstream rust-lang/rust still uses the old name so let's switch back to
that.
2019-03-01 09:22:30 -08:00
Nick Fitzgerald
18440a562e
Merge pull request #1306 from alexcrichton/encode-into-shared
Fix `passStringToWasm` with shared memory
2019-02-28 15:28:22 -08:00
Alex Crichton
233525d7d6 Fix passStringToWasm with shared memory
Looks like `TextEncoder#encodeInto` isn't compatible when the buffer
passed in is backed by a `SharedArrayBuffer`, so if the module has a
shared thread skip the `encodeInto` optimization entirely.
2019-02-28 14:58:10 -08:00
Alex Crichton
c62f6529d8
Merge pull request #1304 from alexcrichton/fix-init
Fix a `__wbindgen_placeholder__` module leaking through
2019-02-28 13:39:56 -06:00
Alex Crichton
da168dc7f5
Merge pull request #1302 from tyleranton/export-comments-ts
Add doc comments export for typescript
2019-02-28 09:34:11 -06:00
Alex Crichton
c4c0fea05e Fix a __wbindgen_placeholder__ module leaking through
With #1267 now fixed looks like we had an accidental regression sneak
through in the meantime!
2019-02-28 07:32:30 -08:00
Tyler Anton
59825c6d01 Add doc comments export for typescript 2019-02-27 20:09:28 +00:00
Alex Crichton
377d75c2c3 Switch CI to Azure Pipelines
This commit switches CI for the wasm-bindgen repository from a mixture
of Travis and AppVeyor to Azure Pipelines. One of the main reasons for
this was for me to personally get familiar with Azure Pipelines, but
after finishing it I think that this'd be a good transition for this
repository anyway.

With azure pipelines we're able to get more parallelism (10 vs the 3 on
Travis plus 1 on AppVeyor) as well as house all configuration in the
same location for one service (Azure Pipelines covers all 3 major
platforms).

I've tested this a good deal on my own personal repository as well, and
I believe that this is a lossless representation of our current CI,
releases and all!
2019-02-27 11:00:24 -08:00
Alex Crichton
cb432be5df
Merge pull request #1296 from rustwasm/dependabot/cargo/scoped-tls-1.0
Update scoped-tls requirement from 0.1 to 1.0
2019-02-27 10:45:01 -06: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
Alex Crichton
96d8dcf661
Merge pull request #1299 from fitzgen/contraction-not-acronym
"Wasm" is a contraction, not an acronym
2019-02-27 09:31:00 -06:00
Christian Legnitto
e80b0ccdc2 Fix headless test runner on macOS High Sierra 2019-02-26 21:06:45 -07:00
Nick Fitzgerald
b3f778096f "Wasm" is a contraction, not an acronym
https://webassembly.github.io/spec/core/intro/introduction.html#wasm
2019-02-26 15:55:09 -08: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
dependabot[bot]
7eb11a7faa
Update scoped-tls requirement from 0.1 to 1.0
Updates the requirements on [scoped-tls](https://github.com/alexcrichton/scoped-tls) to permit the latest version.
- [Release notes](https://github.com/alexcrichton/scoped-tls/releases)
- [Commits](https://github.com/alexcrichton/scoped-tls/compare/0.1.0...1.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-26 08:15:14 +00:00
Alex Crichton
6cabb07358
Merge pull request #1294 from tyleranton/fix-typo
Fix typo in Js Objects in Rust
2019-02-25 13:58:44 -06:00
Tyler Anton
c40f4d05b5 Fix typo in Js Objects in Rust 2019-02-24 17:13:24 -08:00
Alex Crichton
f3f709b1ee
Merge pull request #1291 from limira/patch-1
[guide] Minor fix
2019-02-23 10:10:38 -06:00
limira
de3c852c21
[guide] Minor fix 2019-02-23 15:06:16 +07:00
Alex Crichton
5788e7d2c4
Merge pull request #1285 from alexcrichton/tweak-docs
Tweak introductory and deployment documentation.
2019-02-22 09:51:07 -06:00
Alex Crichton
b71f3374c5 Tweak introductory and deployment documentation.
This commit rejiggers some documentation of `wasm-bindgen` in a few
significant ways:

* The main landing page now has text and links to the Game of Life
  tutorial and `wasm-pack`.
* The "whirlwind tour" was deleted as it wasn't really serving any
  purpose that the Game of Life plus the later references weren't already
  serving.
* The "no modules" example was renamed to "without a bundler"
* A dedicated section on "Deployment" was added which replaces the
  previous "No ES Modules" page. This is hopefully more descriptive and
  also prominently mentions the various options for deployment.
2019-02-22 07:50:32 -08:00
Alex Crichton
74a39ce618
Merge pull request #1280 from alexcrichton/rename-context
Rename test `Context` in JS
2019-02-20 11:52:51 -06: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
de85d99acd
Merge pull request #1002 from alexcrichton/reference-types
Add experimental support for the `anyref` type
2019-02-20 09:29:19 -06:00
Alex Crichton
4181fb311a Add experimental support for the anyref type
This commit adds experimental support to `wasm-bindgen` to emit and
leverage the `anyref` native wasm type. This native type is still in a
proposal status (the reference-types proposal). The intention of
`anyref` is to be able to directly hold JS values in wasm and pass the
to imported functions, namely to empower eventual host bindings (now
renamed WebIDL bindings) integration where we can skip JS shims
altogether for many imports.

This commit doesn't actually affect wasm-bindgen's behavior at all
as-is, but rather this support requires an opt-in env var to be
configured. Once the support is stable in browsers it's intended that
this will add a CLI switch for turning on this support, eventually
defaulting it to `true` in the far future.

The basic strategy here is to take the `stack` and `slab` globals in the
generated JS glue and move them into wasm using a table. This new table
in wasm is managed at the fringes via injected shims. At
`wasm-bindgen`-time the CLI will rewrite exports and imports with shims
that actually use `anyref` if needed, performing loads/stores inside the
wasm module instead of externally in the wasm module.

This should provide a boost over what we have today, but it's not a
fantastic strategy long term. We have a more grand vision for `anyref`
being a first-class type in the language, but that's on a much longer
horizon and this is currently thought to be the best we can do in terms
of integration in the near future.

The stack/heap JS tables are combined into one wasm table. The stack
starts at the end of the table and grows down with a stack pointer (also
injected). The heap starts at the end and grows up (state managed in
linear memory). The anyref transformation here will hook up various
intrinsics in wasm-bindgen to the runtime functionality if the anyref
supoprt is enabled.

The main tricky treatment here was applied to closures, where we need JS
to use a different function pointer than the one Rust gives it to use a
JS function pointer empowered with anyref. This works by switching up a
bit how descriptors work, embedding the shims to call inside descriptors
rather than communicated at runtime. This means that we're accessing
constant values in the generated JS and we can just update the constant
value accessed.
2019-02-20 07:28:54 -08:00
Alex Crichton
8f695782fb
Merge pull request #1278 from alexcrichton/examples
Update idioms of a few examples
2019-02-19 16:14:32 -06:00
Alex Crichton
e66de7b866
Merge pull request #1277 from alexcrichton/upgrade-walrus
Upgrade to walrus 0.4
2019-02-19 16:14:12 -06: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