mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
Reproduce bug
This commit is contained in:
parent
9b629eef2e
commit
bb4ae8e82d
@ -27,21 +27,29 @@ type StrategyReturnType = [
|
|||||||
export const loadMarineDeps = async (
|
export const loadMarineDeps = async (
|
||||||
CDNUrl: string,
|
CDNUrl: string,
|
||||||
): Promise<StrategyReturnType> => {
|
): Promise<StrategyReturnType> => {
|
||||||
const [marineJsWasm, avmWasm] = await Promise.all([
|
const timeout = new Promise((resolve) => {
|
||||||
fetchResource(
|
setTimeout(resolve, 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [marineJsWasm, avmWasm, worker] = await Promise.all([
|
||||||
|
timeout.then(() => {
|
||||||
|
return fetchResource(
|
||||||
"@fluencelabs/marine-js",
|
"@fluencelabs/marine-js",
|
||||||
"/dist/marine-js.wasm",
|
"/dist/marine-js.wasm",
|
||||||
CDNUrl,
|
CDNUrl,
|
||||||
).then((res) => {
|
).then((res) => {
|
||||||
return res.arrayBuffer();
|
return res.arrayBuffer();
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
fetchResource("@fluencelabs/avm", "/dist/avm.wasm", CDNUrl).then((res) => {
|
timeout.then(() => {
|
||||||
|
return fetchResource("@fluencelabs/avm", "/dist/avm.wasm", CDNUrl).then(
|
||||||
|
(res) => {
|
||||||
return res.arrayBuffer();
|
return res.arrayBuffer();
|
||||||
|
},
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
|
getWorker("@fluencelabs/marine-worker", CDNUrl),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// TODO: load worker in parallel with avm and marine, test that it works
|
|
||||||
const worker = await getWorker("@fluencelabs/marine-worker", CDNUrl);
|
|
||||||
|
|
||||||
return [marineJsWasm, avmWasm, worker];
|
return [marineJsWasm, avmWasm, worker];
|
||||||
};
|
};
|
||||||
|
@ -14,16 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createRequire } from "module";
|
|
||||||
|
|
||||||
import inject from "@rollup/plugin-inject";
|
|
||||||
import { transform } from "esbuild";
|
import { transform } from "esbuild";
|
||||||
import { PluginOption, UserConfig } from "vite";
|
import { PluginOption, UserConfig } from "vite";
|
||||||
import tsconfigPaths from "vite-tsconfig-paths";
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
const esbuildShim = require.resolve("node-stdlib-browser/helpers/esbuild/shim");
|
|
||||||
|
|
||||||
function minifyEs(): PluginOption {
|
function minifyEs(): PluginOption {
|
||||||
return {
|
return {
|
||||||
name: "minifyEs",
|
name: "minifyEs",
|
||||||
@ -56,15 +50,6 @@ const config: UserConfig = {
|
|||||||
formats: ["es"],
|
formats: ["es"],
|
||||||
},
|
},
|
||||||
outDir: "./dist/browser",
|
outDir: "./dist/browser",
|
||||||
rollupOptions: {
|
|
||||||
plugins: [
|
|
||||||
inject({
|
|
||||||
global: [esbuildShim, "global"],
|
|
||||||
process: [esbuildShim, "process"],
|
|
||||||
Buffer: [esbuildShim, "Buffer"],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
plugins: [tsconfigPaths(), minifyEs()],
|
plugins: [tsconfigPaths(), minifyEs()],
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
|
Loading…
Reference in New Issue
Block a user