How to use the @embroider/core.jsHandlebarsCompile function in @embroider/core

To help you get started, we’ve selected a few @embroider/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github embroider-build / embroider / packages / compat / src / parallel-babel-shim.ts View on Github external
if (!pluginInstance.visitor) {
      return pluginInstance;
    }
    let wrappedInstance = Object.assign({}, pluginInstance);
    wrappedInstance.visitor = {};
    for (let key of Object.keys(pluginInstance.visitor)) {
      wrappedInstance.visitor[key] = function(path: any, state: any) {
        state.opts = options;
        return pluginInstance.visitor[key](path, state);
      };
    }
    return wrappedInstance;
  };
}

const template =  compile(`
const parallelBabelShim = require('{{{js-string-escape here}}}').default;;
const config = {{{json-stringify config}}};
module.exports = parallelBabelShim(config);
`);

export function synthesize(config: any) {
  return template({ here: __filename, config });
}

export function synthesizeGlobal(pluginInfo: any) {
  let g = global as any;
  if (!g.__embroiderSlowBabelPlugins__) {
    g.__embroiderSlowBabelPlugins__ = [];
  }
  let index = g.__embroiderSlowBabelPlugins__.length;