How to use @glimmer/bundle-compiler - 10 common examples

To help you get started, we’ve selected a few @glimmer/bundle-compiler 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 glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / bundle-compiler.ts View on Github external
Object.keys(components).forEach(key => {
      assert(key.indexOf('ui/components') !== -1, `Expected component key to start with ui/components, got ${key}.`);

      let component = components[key];
      let spec = specifierFor(key, 'default');

      let block;
      let symbolTable;

      if (component.type === "Curly" || component.type === "Dynamic") {
        let block = compiler.preprocess(spec, component.template);
        let options = compiler.compileOptions(spec);
        let parsedLayout = { block, referrer: spec };
        let wrapped = new WrappedBuilder(options, parsedLayout, EMBERISH_CURLY_CAPABILITIES);
        compiler.addCustom(spec, wrapped);

        compileTimeModules.register(key, 'other', {
          default: wrapped.symbolTable
        });

        symbolTable = wrapped.symbolTable;
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / bundle-compiler.ts View on Github external
resolveComponentSpecifier(componentName: string, referrer: Specifier): Specifier {
    return specifierFor(this.modules.resolve(componentName, referrer, 'ui/components')!, 'default');
  }
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / bundle-compiler.ts View on Github external
resolveHelperSpecifier(helperName: string, referrer: Specifier): Specifier {
    let path = this.modules.resolve(helperName, referrer);
    return specifierFor(path!, 'default');
  }
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / modes / aot / delegate.ts View on Github external
function getBundleCompiler(
  registry: AotCompilerRegistry
): { compiler: BundleCompiler; constants: DebugConstants } {
  let delegate: AotCompilerDelegate = new AotCompilerDelegate(registry);
  let constants = new DebugConstants();
  let compiler = new BundleCompiler(delegate, {
    macros: new TestMacros(),
    constants,
  });
  return { constants, compiler };
}
github glimmerjs / glimmer.js / packages / @glimmer / application-test-helpers / src / app-builder.ts View on Github external
protected buildBytecodeLoader(resolver: Resolver) {
    let delegate = new CompilerDelegate(resolver);
    let compiler = new BundleCompiler(delegate);

    let mainLocator = locatorFor('template:mainTemplate', 'default');
    mainLocator.meta.module = 'template:mainTemplate';

    let block = JSON.parse(mainTemplate.block);
    let compilableTemplate = compilable({
      block,
      referrer: mainLocator.meta,
    });

    compiler.addCompilableTemplate(mainLocator, compilableTemplate);

    for (let module in this.templates) {
      compiler.addTemplateSource(locatorFor(module, 'default'), this.templates[module]);
    }
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / bundle-compiler.ts View on Github external
renderTemplate(template: string, context: Dict, element: HTMLElement): RenderResult {
    let macros = new TestMacros();
    let delegate: BundlingDelegate = new BundlingDelegate(this.components, this.modules, this.compileTimeModules, specifier => {
      return compiler.compileSpecifier(specifier);
    });
    let program = new WriteOnlyProgram(new DebugConstants());
    let compiler = new BundleCompiler(delegate, { macros, program });

    let spec = specifierFor('ui/components/main', 'default');
    compiler.add(spec, template);

    let { components, modules, compileTimeModules } = this;
    Object.keys(components).forEach(key => {
      assert(key.indexOf('ui/components') !== -1, `Expected component key to start with ui/components, got ${key}.`);

      let component = components[key];
      let spec = specifierFor(key, 'default');

      let block;
      let symbolTable;

      if (component.type === "Curly" || component.type === "Dynamic") {
        let block = compiler.preprocess(spec, component.template);
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / modes / aot / delegate.ts View on Github external
function getBundleCompiler(
  registry: AotCompilerRegistry
): { compiler: BundleCompiler; constants: DebugConstants } {
  let delegate: AotCompilerDelegate = new AotCompilerDelegate(registry);
  let constants = new DebugConstants();
  let compiler = new BundleCompiler(delegate, {
    macros: new TestMacros(),
    constants,
  });
  return { constants, compiler };
}
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / bundle-compiler.ts View on Github external
renderTemplate(template: string, context: Dict, element: HTMLElement): RenderResult {
    let macros = new TestMacros();
    let delegate: BundlingDelegate = new BundlingDelegate(this.components, this.modules, this.compileTimeModules, specifier => {
      return compiler.compileSpecifier(specifier);
    });
    let program = new WriteOnlyProgram(new DebugConstants());
    let compiler = new BundleCompiler(delegate, { macros, program });

    let spec = specifierFor('ui/components/main', 'default');
    compiler.add(spec, template);

    let { components, modules, compileTimeModules } = this;
    Object.keys(components).forEach(key => {
      assert(key.indexOf('ui/components') !== -1, `Expected component key to start with ui/components, got ${key}.`);

      let component = components[key];
      let spec = specifierFor(key, 'default');

      let block;
      let symbolTable;

      if (component.type === "Curly" || component.type === "Dynamic") {
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / modes / aot / delegate.ts View on Github external
key.indexOf('ui/components') !== -1,
        `Expected component key to start with ui/components, got ${key}.`
      );

      let { state, manager } = registry.components[key];

      let locator = locatorFor({ module: key, name: 'default' });

      let block;
      let symbolTable;

      if (state.type === 'Curly' || state.type === 'Dynamic') {
        let block = bundleCompiler.preprocess(locator, state.template!);
        let parsedLayout = { block, referrer: locator, asPartial: false };
        let wrapped = new WrappedBuilder(parsedLayout);
        bundleCompiler.addCompilableTemplate(normalizeLocator(locator), wrapped);

        compileTimeModules.register(key, 'other', {
          default: wrapped.symbolTable,
        });

        symbolTable = wrapped.symbolTable;

        this.symbolTables.set(locator, symbolTable);
      } else {
        block = bundleCompiler.addTemplateSource(
          locator,
          expect(state.template, 'expected component definition state to have template')
        );
        symbolTable = {
          hasEval: block.hasEval,
          symbols: block.symbols,
github glimmerjs / glimmer.js / packages / @glimmer / compiler-delegates / src / delegates / module-unification.ts View on Github external
constructor(protected projectPath: string, public outputFiles: OutputFiles, envBuiltIns: Builtins = {}) {
    debug('initialized MU compiler delegate; project=%s', projectPath);
    this.project = new Project(projectPath);
    let builtins = {
      main: specifierFor('main', 'mainTemplate'),
      if: specifierFor('@glimmer/application', 'ifHelper'),
      action: specifierFor('@glimmer/application', 'actionHelper'),
      ...envBuiltIns
    };

    let byName = new Map();
    let byModulePath = new Map();
    let byIdentifier = new Map();

    Object.keys(builtins).forEach(builtin => {
      let specifier = builtins[builtin];
      byName.set(specifier.name, specifier.module);
      byModulePath.set(specifier.module, specifier.name);
      byIdentifier.set(builtin, specifier);
    });

@glimmer/bundle-compiler

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis