M0: WIT package, MoonBit components, JS host, docs, CI (#1)
CI / test (push) Successful in 19s
CI / test (push) Successful in 19s
This commit was merged in pull request #1.
This commit is contained in:
1 parent
e5548fc067
commit
880ecd4102
141 files changed
+9681
-1
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
/** Loader for Node: reads build/ produced by scripts/build.sh. */
|
||||
export function nodeLoader(buildDir) {
|
||||
return async (name) => {
|
||||
const meta = JSON.parse(await readFile(join(buildDir, 'components', `${name}.meta.json`), 'utf8'));
|
||||
const dir = join(buildDir, 'jco', name);
|
||||
const mod = await import(pathToFileURL(join(dir, `${name}.js`)).href);
|
||||
const getCoreModule = async (p) => WebAssembly.compile(await readFile(join(dir, p)));
|
||||
return { meta, instantiate: (imports) => mod.instantiate(getCoreModule, imports) };
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user