MCPcopy Index your code
hub / github.com/messageformat/messageformat / getModule

Function getModule

test/build-module.js:17–31  ·  view source on GitHub ↗
(mf, messages)

Source from the content-addressed store, hash-verified

15
16const write = promisify(fs.write);
17async function getModule(mf, messages) {
18 const src = compileModule(mf, messages);
19 const options = { plugins: ['@babel/plugin-transform-modules-commonjs'] };
20 const { code } = await babel.transformAsync(src, options);
21 const { cleanup, fd, path } = await tmp.file({
22 dir: __dirname,
23 postfix: '.js'
24 });
25 await write(fd, code, 0, 'utf8');
26 try {
27 return require(path).default;
28 } finally {
29 cleanup();
30 }
31}
32
33describe('compileModule()', function () {
34 it('can compile an object of messages', async function () {

Callers 2

build-module.jsFile · 0.85
messages.jsFile · 0.85

Calls 1

compileModuleFunction · 0.85

Tested by

no test coverage detected