Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function traverseEntry(entryPath, visitors, { pattern, visited = [] } = {}) {
const entryAST = parseFile(entryPath);
visited.push(entryPath);
precinct(entryAST, { type: 'es6', es6: { mixedImports: true } }).forEach(
dependency => {
// NOTE: only internal dependencies
// TODO: allow path alias aka webpack alias https://webpack.js.org/configuration/resolve/#resolve-alias
// https://github.com/dependents/node-filing-cabinet#usage
if (!dependency.startsWith('.')) {
return;
}
const dependencyPath = resolveDependencyPath({
dependency,
entryPath,
entryAST,
});
if (!dependencyPath) {
// NOTE: don't warn if dependency is not `js` or `ts`
function resolveDependencies({ entryAST, entryPath, pattern }) {
const relativeDependencies = precinct(entryAST, {
type: 'es6',
es6: { mixedImports: true },
});
return relativeDependencies
.map(dependency => {
// NOTE: only internal dependencies
// TODO: allow path alias aka webpack alias https://webpack.js.org/configuration/resolve/#resolve-alias
// https://github.com/dependents/node-filing-cabinet#usage
if (!dependency.startsWith('.')) {
return;
}
// convert relative path to absolute
const dependencyPath = resolveDependencyPath({
dependency,
function traverseEntry(entryPath, visitors, { pattern, visited = [] } = {}) {
const entryAST = parseFile(entryPath);
visited.push(entryPath);
precinct(entryAST, { type: 'es6', es6: { mixedImports: true } }).forEach(
dependency => {
// NOTE: only internal dependencies
// TODO: allow path alias aka webpack alias https://webpack.js.org/configuration/resolve/#resolve-alias
// https://github.com/dependents/node-filing-cabinet#usage
if (!dependency.startsWith('.')) {
return;
}
const dependencyPath = resolveDependencyPath({
dependency,
entryPath,
entryAST,
});
if (!dependencyPath) {
// NOTE: don't warn if dependency is not `js` or `ts`
function walk(file, apply) {
const pool = uniqByPath(flatten(file.dependencies));
const source =
typeof file.buffer === "string"
? file.buffer
: file.buffer.toString("utf-8");
const id = md5(source);
stash[id] = stash[id] || precinct(source);
stash[id]
.map(localName => (file.dependencies[localName] || {}).path)
.filter(Boolean)
.map(dependencyPath => pool.find(dep => dep.path === dependencyPath))
.filter(Boolean)
.forEach(dependency => {
dependency.buffer = apply(dependency).buffer;
walk(dependency, apply);
});
}
const nameAndContent = files.map(async name => {
const content = await fs.readFile(path.join('public', name), 'utf-8');
const depTree = precinct(content, {type: 'es6'});
return ['/'+name, depTree];
});