From 2636b89a66bd1d6920eb91af37381be834b29e16 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Tue, 19 May 2020 04:33:48 -0500 Subject: [PATCH] examples: checkpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mostly for record keeping; me vs javascript tooling round 5000 tried to drop the preprocessing in parcel-plugin-wasm.rs by going with --target web turns out that doesn't make any sense didn't realize this until _after_ writing it though; i've now seen way more parcel innards than i ever thought i'd need too (somehow the actual type of the generated field for assets is just not documented — reading the other assets to figure it out actually hurts more than it helps) ((also, parcel uses flow but not for these parts)) import.meta also made things pretty irritating (babel/babel#11364) went on an hour long detour through all the wasm-pack/wasm-bindgen options and how to best expose/use them through the plugin tried to use the bundler option (when not running on Node) also explodes in spectacular fashion; somehow parcel's wasm load just doesn't pass in imports I'm actually starting to think the find and replace scheme that's used right now is actually optimal.. So, really, it's parcel's fault. Webpack does the right thing here: parcel-bundler/parcel#647 I was going to say that this plugin (parcel-plugin-wasm-pack) manages to do better but really they do the exact same thing in a slightly less clumsy way: https://github.com/mysterycommand/parcel-plugin-wasm-pack/blob/f204a708d964127aaa1e5d278f41a44f5d76393b/src/WasmPackAsset.js#L174-L179 They do have tests though which is commendable --- examples/package.json | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/package.json b/examples/package.json index c48f1a7..1696104 100644 --- a/examples/package.json +++ b/examples/package.json @@ -6,7 +6,8 @@ "license": "MIT", "scripts": { "watch": "parcel index.html", - "release": "WASM_PACK_PROFILE=release parcel build index.html" + "release": "WASM_PACK_PROFILE=release NODE_ENV=production parcel build index.html", + "//": "drop WASM_PACK_PROFILE=release when (if) things get merged" }, "dependencies": { "xterm": "^4.5.0", @@ -14,8 +15,18 @@ "xterm-addon-web-links": "^0.3.0" }, "devDependencies": { + "@babel/core": "^7.9.6", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", "parcel-bundler": "^1.12.4", - "parcel-plugin-wasm.rs": "^1.2.15", + "parcel-plugin-wasm.rs": "rrbutani/parcel-plugin-wasm.rs", + "//": "^ should be switched back if/when the PR gets merged..", + "//parcel-plugin-wasm.rs": "file:../../../../../JS/parcel-plugin-wasm.rs", "typescript": "^3.8.3" + }, + "babel": { + "plugins": [ + "@babel/plugin-syntax-import-meta" + ] } }