How to use the google-closure-deps.depGraph.Dependency function in google-closure-deps

To help you get started, we’ve selected a few google-closure-deps 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 teppeis / duck / test / gendeps.ts View on Github external
it("outputs SCRIPT type dep", async () => {
      const dep = new depGraph.Dependency(
        depGraph.DependencyType.SCRIPT,
        "/app/foo.js",
        [],
        [new depGraph.GoogRequire("goog.array")]
      );
      const text = await generateDepFileTextFromDeps([dep], "/closure/goog");
      assert.equal(text, "goog.addDependency('../../app/foo.js', [], ['goog.array'], {});\n");
      assert.equal(dep.type, depGraph.DependencyType.SCRIPT, "dep.type should not be changed");
    });
    it("does not output imported `goog`", async () => {
github teppeis / duck / test / gendeps.ts View on Github external
function createScriptDependency(filepath: string): any {
      return new depGraph.Dependency(
        depGraph.DependencyType.SCRIPT,
        path.join(fixturesDir, filepath),
        [],
        []
      );
    }
    it("loads all js files in paths", async () => {
github teppeis / duck / test / gendeps.ts View on Github external
it("loads deps of closure-library from the deps.js", async () => {
      const closureLib1 = path.resolve(fixturesBaseDir, "closure-lib1");
      const deps = await getClosureLibraryDependencies(closureLib1);
      deps.sort((a, b) => a.path.localeCompare(b.path));
      assertDependenciesEqual(deps, [
        new depGraph.Dependency(
          depGraph.DependencyType.CLOSURE_PROVIDE,
          `${closureLib1}/closure/goog/a11y/aria/aria.js`,
          ["goog.a11y.aria"],
          [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.a11y.aria.Role")]
        ),
        new depGraph.Dependency(
          depGraph.DependencyType.CLOSURE_MODULE,
          `${closureLib1}/closure/goog/collections/sets.js`,
          ["goog.collections.sets"],
          [new depGraph.GoogRequire("goog")],
          "es6"
        ),
      ]);
    });
  });
github teppeis / duck / test / gendeps.ts View on Github external
it("does not output imported `goog`", async () => {
      const dep = new depGraph.Dependency(
        depGraph.DependencyType.SCRIPT,
        "/app/foo.js",
        [],
        [new depGraph.GoogRequire("goog")]
      );
      const result = await generateDepFileTextFromDeps([dep], "/closure/goog");
      assert.equal(result, "goog.addDependency('../../app/foo.js', [], [], {});\n");
    });
  });
github teppeis / duck / test / gendeps.ts View on Github external
),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm-moduleid.js`,
    ["esm"],
    [new depGraph.Es6Import("./foo.js"), new depGraph.GoogRequire("goog")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm.js`,
    [],
    [new depGraph.Es6Import("./foo.js")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.SCRIPT,
    `${variousModulesFixturesDir}/script.js`,
    [],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
] as const;

describe("gendeps", () => {
  beforeEach(() => {
    clearDepCache();
  });
  describe("generateDepFileText()", () => {
    it("returns correct relative path", async () => {
      const inputsRoot = path.join(fixturesBaseDir, "generateDepFileText");
      const closureDir = path.join(inputsRoot, "closure");
      const entryConfig = {
github teppeis / duck / test / gendeps.ts View on Github external
[new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.CLOSURE_PROVIDE,
    `${variousModulesFixturesDir}/closureprovide.js`,
    ["closureprovide"],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm-moduleid.js`,
    ["esm"],
    [new depGraph.Es6Import("./foo.js"), new depGraph.GoogRequire("goog")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm.js`,
    [],
    [new depGraph.Es6Import("./foo.js")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.SCRIPT,
    `${variousModulesFixturesDir}/script.js`,
    [],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
] as const;

describe("gendeps", () => {
  beforeEach(() => {
github teppeis / duck / test / dependency-parser.ts View on Github external
import assert = require("assert");
import { depGraph } from "google-closure-deps";
import path from "path";
import { parseDependency } from "../src/dependency-parser";
import { DependencyParserWithWorkers } from "../src/dependency-parser-wrapper";

const fixturesBaseDir = path.join(__dirname, "fixtures");

const variousModulesFixturesDir = path.join(fixturesBaseDir, "various-modules");
const expectedVariousModulesDeps = [
  new depGraph.Dependency(
    depGraph.DependencyType.CLOSURE_MODULE,
    `${variousModulesFixturesDir}/closuremodule.js`,
    ["closuremodule"],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.CLOSURE_PROVIDE,
    `${variousModulesFixturesDir}/closureprovide.js`,
    ["closureprovide"],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm-moduleid.js`,
    ["esm"],
    [new depGraph.Es6Import("./foo.js"), new depGraph.GoogRequire("goog")],
github teppeis / duck / test / dependency-parser.ts View on Github external
const variousModulesFixturesDir = path.join(fixturesBaseDir, "various-modules");
const expectedVariousModulesDeps = [
  new depGraph.Dependency(
    depGraph.DependencyType.CLOSURE_MODULE,
    `${variousModulesFixturesDir}/closuremodule.js`,
    ["closuremodule"],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.CLOSURE_PROVIDE,
    `${variousModulesFixturesDir}/closureprovide.js`,
    ["closureprovide"],
    [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")]
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm-moduleid.js`,
    ["esm"],
    [new depGraph.Es6Import("./foo.js"), new depGraph.GoogRequire("goog")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.ES6_MODULE,
    `${variousModulesFixturesDir}/esm.js`,
    [],
    [new depGraph.Es6Import("./foo.js")],
    "es6"
  ),
  new depGraph.Dependency(
    depGraph.DependencyType.SCRIPT,
    `${variousModulesFixturesDir}/script.js`,
github teppeis / duck / src / dependency-parser-wrapper.ts View on Github external
private deserialize(depData: DependencyTransferData): depGraph.Dependency {
    const imports = depData.imports.map(i => {
      if (i.isEs6Import && !i.isGoogRequire) {
        return new depGraph.Es6Import(i.symOrPath);
      } else if (!i.isEs6Import && i.isGoogRequire) {
        return new depGraph.GoogRequire(i.symOrPath);
      } else {
        throw new TypeError(`Unexpected import: ${i}`);
      }
    });
    return new depGraph.Dependency(
      depData.type,
      depData.path,
      depData.closureSymbols,
      imports,
      depData.language
    );
  }