-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
CI/CD + cargo workspace #8
Comments
about cargo workspace: I'm using yarn workspace btw, so if I add |
Does // vite.config.ts
// ...
ViteRsw({
root: 'custom/path', // rust crates
mode: "release",
// support two ways at the same time
crates: [
'rsw-hey', // way 1
// outDir: --out-dir
// name: npm package
+ { outDir: 'custom/path', name: 'rsw-hello' }, // way 2
// ...
],
}) |
umm kinda... but specifying outDir manually for multiple wasm crates would be a bit of pain I guess |
Support two ways at the same time. |
As a workaround in CI/CD, you can build the package yourself. See here. Not ideal, but does the trick for now. |
using yarn workspace + cargo workspace + a bit of scripting(in rust for fun) to run wasm-pack on all wasm crates https://github.com/audacioustux/audacioustux/blob/main/crates/scripts/src/main.rs |
Great! Will give it a try and let you know the results. |
You can use the For example: {
"root": ".", // project root path
"crate:": [
"@rsw/hello", // ✅
{"name": "rsw-hello", "outDir": "custom/path"} // ✅
]
} https://github.com/lencx/vite-plugin-rsw#remote-deployment-project |
I have followed all instructions, however when do Thanks |
@husayt Please make sure you have installed rsw-node and configured Can refer to this project: https://github.com/lencx/learn-wasm |
@lencx yes, I have done that as well. In dev all works. But when I build there are no wasm files in dist folder. |
@husayt Can you take a screenshot of |
@husayt Please provide the following screenshot, this screenshot seems to be ok. vite v2.3.8 building for production...
# output: screenshot |
@husayt Can you send the file |
here it is: @rsw/hey/pkg/rsw~hey.js let wasm;
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8');
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length);
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
/**
* @param {string} name
*/
export function greet(name) {
var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
wasm.greet(ptr0, len0);
}
async function load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
if (module.headers.get('Content-Type') != 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
}
async function init(input) {
if (typeof input === 'undefined') {
input = new URL('rsw~hey_bg.wasm', import.meta.url);
}
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_alert_36567ccdaebdf23d = function(arg0, arg1) {
alert(getStringFromWasm0(arg0, arg1));
};
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
input = fetch(input);
}
const { instance, module } = await load(await input, imports);
wasm = instance.exports;
init.__wbindgen_wasm_module = module;
return wasm;
}
export default init;
|
Let's discuss it here.
#5 (comment)
#3 (comment)
The text was updated successfully, but these errors were encountered: