Comments (12)
Yep totally want to support wasm. I did some initial experiments with this a while ago, and it should be pretty easy. I think WASM should definitely be supported in parcel core. Less sure about languages that compile to WASM like Rust since they usually depend on large toolchains, but perhaps it could work assuming installation instructions are documented well.
from parcel.
You know, support for different file types besides just js should probably be discussed. This might be a major infrastructure change and decision that this library might want to make now. We're already talking about supporting at least ts files here: #3
from parcel.
And I am pleased to find out that this was already thought of, and parcel is file-type agnostic. Perfect. Then, let's support C/C++/Rust/wasm files. How do we do this?
from parcel.
I can take a look at the implementation of rust, but yes, I agree with @devongovett, this shouldn't come out of the box, maybe a plugin?
from parcel.
@albizures I think you misread/miss-interpreted what Devon said. He said that it should be part of parcel core!
Parcel is trying to stay away from plugins, and trying to add all essential stuff directly to the core, to avoid the configuration mess of other tools like webpack.
from parcel.
@davidnagli 👍, I already made some progress but I have some problems...
I already upload it and I created the PR although it is not completed, maybe someone has an idea :)
PR: #312
from parcel.
Progress: just merged #312 into the wasm
branch!
I think we should go for a few milestones here.
- First, let's get a
WASMAsset
merged that supports only precompiled.wasm
files. This will be the base for other languages (e.g. rust) that compile to wasm. - Work on adding Rust support. Either autoinstall or warn if the proper toolchain isn't installed (rustc,
wasm32-unknown-unknown
,wasm-gc
, etc.). - Add a
WASMPackager
that can combine multiple.wasm
files together into a single one. Maybe we can use wasm-merge from binaryen to do that?
See also, my comment here about some details.
from parcel.
hey @devongovett, responding your points:
- I created
WASMAsset
but I couldn't make it work withRustAsset
without creating the wasm file alongside the rust file, so I ended up sending directly the wasm file to the dist folder usingrustc
. I don't think this is the best way to do this but I prefer this way rather than create the wasm file in the source code. - we could install
wasm32-unknown-unknown
andwasm-gc
but forrustc
I think it's better if we keep it as a warning - I'm not sure if it's a good idea make a wasm-merge at least for now
also, I already tried with --emit dep-info
and it works great but now I'm creating a .d file alongside the source code. I read that with ReasonAsset
is happening something similar this too, so I think this is something that we have to figure out how to manage this kind of temp files.
from parcel.
Cool, I've been working on WASMAsset
a bit myself, esp some changes that will allow us to preload external modules (that live in separate files) prior to executing the JS bundle. This will allow us to e.g. import {add} from './add.wasm'
synchronously, without inlining into the JS. Instead, the JSPackager will add some code to the JS bundle to preload the WASM file prior to running the bundle.
This also involves some changes to allow registering custom bundle loaders for dynamic imports, e.g. extracting the existing support for JS and CSS, and adding a WASM file loader. So you'll be able to bundler.addBundleLoader('wasm', '/path/to/my/loader.js')
for custom formats in plugins too.
I'm not sure if it's a good idea make a wasm-merge at least for now
Yeah, I realized that it isn't even possible to do what I wanted in the WASM format for now. A .wasm
file consists of only a single module, so if you merge them you actually end up with a single module containing all of the exports rather than one file with multiple separate modules. Let's ignore that for now.
r.e. --emit dep-info
, maybe we could ask the Rust people to make it possible to output this to stdout instead of a file...
from parcel.
esp some changes that will allow us to preload external modules (that live in separate files) prior to executing the JS bundle.
😲 this sounds really cool!
maybe we could ask the Rust people to make it possible to output this to stdout instead of a file...
yes, good idea! maybe even a json output 🤷♂️
from parcel.
See here: #473
from parcel.
Done in v1.5.0!
from parcel.
Related Issues (20)
- Parcel build fails consistently with 10:SIGBUS and SIGSEGV
- Parcel fetching configs from where it's installed instead of where the process is running
- watch causes web extension background script to reload when tab with active content script is closed
- Importing D3 is causing TheLayout to produce invalid unicode escape sequence on D3.random HOT 4
- Parcel dev server randomly crashes when trying to unlink a file in the dist directory. HOT 1
- This experimental syntax requires enabling the parser plugin: 'optionalChaining' HOT 2
- Object spread operator causes build error HOT 1
- No import() polyfill available for context 'node'
- Parcel not minifying by default even when it says it does HOT 2
- Images are not created in the dist folder HOT 7
- Non-ASCII characters in identifiers result in invalid escape sequences
- parcel/svgo optimiser not working consistently for all packages
- `@parcel/packager-js: Got unexpected null` with CSS module composes
- Support for Typescript Proxies
- "@parcel/packager-css: Unsupported layer combination in @import"
- @parcel/rust package should only install binaries for the host platform HOT 2
- "process is not defined", when using Typescript (MRE included) HOT 2
- Panic in SWC on `1 / {2}`
- Use v4 of actions/upload-artifact or actions/download-artifact
- Parcel and Redux Toolkit Query: import of api created with createApi crash the app HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parcel.