-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wasm build doesn't work on Windows #687
Comments
Ah, I think I understand why. It looks like perhaps Go's path internals are locked to Unix-style paths when using WebAssembly. Specifically, building with WebAssembly sets FWIW the WebAssembly version of esbuild is mainly intended to be used in the browser where running a native executable is impossible. The native version is intended to be used outside of the browser. The native version is around 10x faster than the WebAssembly version for various reasons. I'm not saying you have to switch away from the WebAssembly version, especially if I can figure out how to fix this problem. I'm just telling you that it'll go a lot faster if you do. |
Yep - our Webpack build was 28s, with Fwiw I'm also thinking about adding proper builtin support for multi-platform packages into Yarn - similar to what you're mimicking with the "download the right package on-demand" postinstall script, but more integrated with the package manager infrastructure. If that works out native builds could be a viable option. |
Off topic... comment from the cross linked yarn PR above:
The development iteration speed improvement is fantastic and certainly justifies the change, but I wonder what accounts for the 300KB bundle size increase with esbuild compared to webpack+terser. An optimization opportunity for esbuild perhaps? |
When I read the thread it looked like this might be more about which code was selected for bundling instead of the result of minifier optimizations: yarnpkg/berry#2362 (comment). Not sure if that's still current or not though. |
I've managed to bring the size down to 1.83MB (don't remember how), but I couldn't go lower. The size seems the same whether I have |
I took a look at fixing this and it looks like this is an inherently buggy scenario. I've been trying all day and I still haven't gotten it working yet, but I've already hit these issues:
I'm hoping that these are the main issues with the |
I seem to remember that the error is triggered by a |
I would advise against this. Native compilation defeats the purpose of using wasm on NodeJS. It doesn't work on all platforms, like the older version of Mac OS I use which cannot build fsevents natively. |
After reviewing 9ea2076 I can report that npm/esbuild-wasm/exit0/darwin-x64-LE.node works correctly on mac OS 10.9. The prebuilt zero dependency wasm-napi-exit0 dynamic libraries are a good workaround. |
I figured it's harmless if it doesn't work for whatever reason, because node is exiting anyway and any errors running the thing are ignored. Worst case node will just exit many seconds later as usual. Edit: Here are the times on my end for running the WebAssembly
|
On my Mac I see a roughly 0.4s improvement with esbuild-wasm with 9ea2076... before 9ea2076:
after 9ea2076:
|
It's hard to believe this NodeJS bug has gone unnoticed given its performance on recent OS versions. Wasm modules must not be widely used. |
Ugh, another problem: nodejs/node#24550. Unicode output doesn't work on Windows with Edit: I filed this as golang/go#43917. |
All of the fixes in this thread have now been released in version 0.8.35. There may yet be more bugs because node+Go+WASM+Windows seems to be a particularly buggy combination, but I've worked around all of the bugs I'm aware of. It's ready for another try. |
Can confirm that yarnpkg/berry#2362 builds on Windows without crashing, however the bundle it produces is broken as the output is ~800kb smaller when built on Windows compared to Ubuntu. Due to the |
You need to update your plugin to handle Windows-style paths with backslashes: diff --git a/packages/yarnpkg-builder/sources/commands/build/bundle.ts b/packages/yarnpkg-builder/sources/commands/build/bundle.ts
index 4b619f1b..224b3d69 100644
--- a/packages/yarnpkg-builder/sources/commands/build/bundle.ts
+++ b/packages/yarnpkg-builder/sources/commands/build/bundle.ts
@@ -104,7 +104,7 @@ export default class BuildBundleCommand extends Command {
const valLoader: Plugin = {
name: `val-loader`,
setup(build) {
- build.onLoad({filter: /\/getPluginConfiguration\.ts$/}, async args => ({
+ build.onLoad({filter: /[\/\\]getPluginConfiguration\.ts$/}, async args => ({
contents: valLoad(args.path, {modules, plugins}),
loader: `default`,
}));
I'm going to try hiding the |
Ah, of course, thanks 👍
I suppose you'd need to write them to a temp folder before calling |
The latest version 0.8.36 doesn't contain |
It looks like the N-API change isn't working out. I'm seeing this on the Windows tests for yarnpkg/berry#2362, which I assume is from esbuild's N-API hack:
Looks like I should revert the N-API change. No idea why this is happening but this is probably a sign that it wasn't meant to be. I really wish node's WebAssembly support wasn't so incredibly slow. I guess maybe there's nothing robust I can do to make it faster. |
It's interesting that only node 14 fails while node 12 and 15 on Windows are just fine |
Yeah that's strange. Just to check: have you ever seen this kind of error on any of your CI runs before? |
Not as far as I can remember, we're re-running the tests now to see if it was a one time thing |
A rebuild seems to have worked. I think we can try to land it and see whether it's stable. Still, I'm curious about something: why do you need |
nodejs/node#36616 (comment) mentioned:
|
Running a build on Windows doesn't work when using the
esbuild-wasm
package. It works fine when usingesbuild
(but we'd prefer to avoid that since it requires a postinstall script).Repro:
Error:
The text was updated successfully, but these errors were encountered: