How to use the @embroider/core.explicitRelative 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 / dependency-rules.ts View on Github external
let found = resolver.resolveImport(path, absPath);
      if (!found) {
        throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);
      }
      output.push({
        absPath,
        target: explicitRelative(dirname(absPath), found.absPath),
        runtimeName: found.runtimeName,
      });
    }
  }
  if (moduleRules.dependsOnComponents) {
    for (let snippet of moduleRules.dependsOnComponents) {
      let found = resolver.resolveComponentSnippet(snippet, moduleRules);
      for (let { absPath: target, runtimeName } of found.modules) {
        output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });
      }
    }
  }
  return output;
}
github embroider-build / embroider / packages / compat / src / dependency-rules.ts View on Github external
export function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {
  let output: { absPath: string; target: string; runtimeName: string }[] = [];
  if (moduleRules.dependsOnModules) {
    for (let path of moduleRules.dependsOnModules) {
      let found = resolver.resolveImport(path, absPath);
      if (!found) {
        throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);
      }
      output.push({
        absPath,
        target: explicitRelative(dirname(absPath), found.absPath),
        runtimeName: found.runtimeName,
      });
    }
  }
  if (moduleRules.dependsOnComponents) {
    for (let snippet of moduleRules.dependsOnComponents) {
      let found = resolver.resolveComponentSnippet(snippet, moduleRules);
      for (let { absPath: target, runtimeName } of found.modules) {
        output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });
      }
    }
  }
  return output;
}
github embroider-build / embroider / packages / compat / src / resolver.ts View on Github external
modules: componentModules.map(p => ({
          path: explicitRelative(dirname(from), p.absPath),
          absPath: p.absPath,
          runtimeName: p.runtimeName,
        })),
        yieldsComponents: componentRules ? componentRules.yieldsSafeComponents : [],
github embroider-build / embroider / packages / compat / src / resolver.ts View on Github external
private tryHelper(path: string, from: string): Resolution | null {
    for (let extension of this.params.resolvableExtensions) {
      let absPath = join(this.params.root, 'helpers', path) + extension;
      if (pathExistsSync(absPath)) {
        return {
          type: 'helper',
          modules: [
            {
              runtimeName: `${this.params.modulePrefix}/helpers/${path}`,
              path: explicitRelative(dirname(from), absPath),
              absPath,
            },
          ],
        };
      }
    }
    return null;
  }