diff --git a/package.json b/package.json index f42e636fb55..17a7ae983ad 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,8 @@ "minify": "terser -c -m -o src/builtins/prelude.min.js src/builtins/prelude.js && terser -c -m -o src/builtins/prelude2.min.js src/builtins/prelude2.js", "precommit": "lint-staged", "lint": "eslint . && prettier \"./{src,bin,test}/**/*.{js,json,md}\" --list-different", - "postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove Parcel? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/parcel/donate\\u001b[0m')\"" + "postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove Parcel? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/parcel/donate\\u001b[0m')\"", + "clean": "rm -rf node_modules lib && yarn" }, "bin": { "parcel": "bin/cli.js" diff --git a/src/assets/RustAsset.js b/src/assets/RustAsset.js index aaef8f61df0..2c6cfb690f3 100644 --- a/src/assets/RustAsset.js +++ b/src/assets/RustAsset.js @@ -15,7 +15,6 @@ const MAIN_FILES = ['src/lib.rs', 'src/main.rs']; // Track installation status so we don't need to check more than once let rustInstalled = false; -let wasmGCInstalled = false; class RustAsset extends Asset { constructor(name, options) { @@ -62,12 +61,6 @@ class RustAsset extends Asset { } else { await this.rustcBuild(); } - - // If this is a prod build, use wasm-gc to remove unused code - if (this.options.minify) { - await this.installWasmGC(); - await exec('wasm-gc', [this.wasmPath, this.wasmPath]); - } } async installRust() { @@ -111,24 +104,6 @@ class RustAsset extends Asset { rustInstalled = true; } - async installWasmGC() { - if (wasmGCInstalled) { - return; - } - - try { - await commandExists('wasm-gc'); - } catch (e) { - await pipeSpawn('cargo', [ - 'install', - '--git', - 'https://github.com/alexcrichton/wasm-gc' - ]); - } - - wasmGCInstalled = true; - } - async cargoBuild(cargoConfig, cargoDir) { // Ensure the cargo config has cdylib as the crate-type if (!cargoConfig.lib) { @@ -182,6 +157,7 @@ class RustAsset extends Asset { '-o', this.wasmPath ]; + await exec('rustc', args); // Run again to collect dependencies diff --git a/test/rust.js b/test/rust.js index 5467db33fcf..a6935b04c54 100644 --- a/test/rust.js +++ b/test/rust.js @@ -168,52 +168,4 @@ describe('rust', function() { var res = await run(b); assert.equal(res, 5); }); - - it('should use wasm-gc to minify output', async function() { - this.timeout(500000); - - // Store the size of not minified bundle in order to test it against - // the size of minified one. - let b = await bundle(path.join(__dirname, '/integration/rust/index.js'), { - minify: false, - sourceMaps: false - }); - const size = (await fs.stat(Array.from(b.childBundles)[0].name)).size; - - let bMinified = await bundle( - path.join(__dirname, '/integration/rust/index.js'), - { - minify: true, - sourceMaps: false - } - ); - - const bundleTree = { - name: 'index.js', - assets: [ - 'bundle-loader.js', - 'bundle-url.js', - 'index.js', - 'wasm-loader.js' - ], - childBundles: [ - { - type: 'wasm', - assets: ['add.rs'], - childBundles: [] - } - ] - }; - - await assertBundleTree(b, bundleTree); - await assertBundleTree(bMinified, bundleTree); - - var res = await run(bMinified); - assert.equal(res, 5); - - const sizeMinified = (await fs.stat( - Array.from(bMinified.childBundles)[0].name - )).size; - assert(sizeMinified < size); - }); });