This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loadmodule): implement loadmodule
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '*/lib/libsass'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getModuleLoader } from 'emscripten-wasm-loader'; | ||
import { SassAsmModule } from './SassAsmModule'; | ||
import { SassFactory } from './SassFactory'; | ||
import { sassLoader } from './sassLoader'; | ||
import { log } from './util/logger'; | ||
|
||
/** | ||
* Load, initialize wasm binary to use actual sass instance. | ||
* | ||
* @returns {Promise<SassFactory>} Function to load module | ||
*/ | ||
const loadModule = async (): Promise<SassFactory> => { | ||
log(`loadModule: loading libsass module`); | ||
|
||
//imports MODULARIZED emscripten preamble | ||
const runtimeModule = await import('./lib/libsass'); | ||
const moduleLoader = await getModuleLoader<SassFactory, SassAsmModule>(sassLoader, runtimeModule); | ||
|
||
return moduleLoader(); | ||
}; | ||
|
||
export { loadModule }; |