Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
feat(loadmodule): implement loadmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 10, 2018
1 parent 7ae4abb commit d614551
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '*/lib/libsass';
22 changes: 22 additions & 0 deletions src/loadModule.ts
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 };

0 comments on commit d614551

Please sign in to comment.