Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
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("DependencyParser()", () => {
it("parses closure provide script", async () => {
const actual = await parseDependency(path.join(variousModulesFixturesDir, "closureprovide.js"));
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"
),
]);
});
});
generateDepFileTextFromDeps,
getClosureLibraryDependencies,
getDependencies,
restoreDepsJs,
writeCachedDepsOnDisk,
} from "../src/gendeps";
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const fixturesBaseDir = path.join(__dirname, "fixtures");
const variousModulesFixturesDir = path.join(fixturesBaseDir, "various-modules");
const variousModulesDepsJsPath = path.join(fixturesBaseDir, "various-modules-deps.js");
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"
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")],
"es6"
scriptDeps.forEach(dep => {
dep.type = depGraph.DependencyType.CLOSURE_PROVIDE;
});
const depFileText = depFile.getDepFileText(googBaseDir, dependencies);
const scriptDeps = dependencies.filter(dep => dep.type === depGraph.DependencyType.SCRIPT);
scriptDeps.forEach(dep => {