Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var detect = require('acorn-globals');
var acorn = require('acorn');
var walk = require('acorn/dist/walk');
// polyfill for https://github.com/marijnh/acorn/pull/231
walk.base.ExportNamedDeclaration = walk.base.ExportDefaultDeclaration = function (node, st, c) {
return c(node.declaration, st);
};
walk.base.ImportDefaultSpecifier = walk.base.ImportNamespaceSpecifier = function () {};
// hacky fix for https://github.com/marijnh/acorn/issues/227
function reallyParse(source) {
try {
return acorn.parse(source, {
ecmaVersion: 5,
allowReturnOutsideFunction: true
});
} catch (ex) {
if (ex.name !== 'SyntaxError') {
throw ex;
}
return acorn.parse(source, {
'use strict';
var acorn = require('acorn');
var walk = require('acorn/dist/walk');
// polyfill for https://github.com/marijnh/acorn/pull/231
walk.base.ExportNamedDeclaration = walk.base.ExportDefaultDeclaration = function (node, st, c) {
return c(node.declaration, st);
};
walk.base.ImportDefaultSpecifier = walk.base.ImportNamespaceSpecifier = function () {};
function isScope(node) {
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'Program';
}
function isBlockScope(node) {
return node.type === 'BlockStatement' || isScope(node);
}
function declaresArguments(node) {
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunction';
}
function declaresThis(node) {
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
}
function reallyParse(source) {
'use strict';
var detect = require('acorn-globals');
var acorn = require('acorn');
var walk = require('acorn/dist/walk');
// polyfill for https://github.com/marijnh/acorn/pull/231
walk.base.ExportNamedDeclaration = walk.base.ExportDefaultDeclaration = function (node, st, c) {
return c(node.declaration, st);
};
walk.base.ImportDefaultSpecifier = walk.base.ImportNamespaceSpecifier = function () {};
// hacky fix for https://github.com/marijnh/acorn/issues/227
function reallyParse(source) {
try {
return acorn.parse(source, {
ecmaVersion: 5,
allowReturnOutsideFunction: true
});
} catch (ex) {
if (ex.name !== 'SyntaxError') {
throw ex;
}
return acorn.parse(source, {
ecmaVersion: 6,
allowReturnOutsideFunction: true
});
);
},
},
};
`;
const base = {
JSXElement(node, st, c) {
node.children.forEach((n) => {
c(n, st);
});
},
JSXExpressionContainer(node, st, c) {
c(node.expression, st);
},
JSXText() {},
...walk.base,
};
function transformReactJSX() {
const helpers = {
slots: false,
transformJSXProps: false,
};
const ast = acorn.parse(content, {
sourceType: 'module',
ecmaVersion: '9',
plugins: { jsx: true },
});
function transformJSXText(node) {
const textValue = node.value.trim().split('\n').map(line => line.trim()).join(' ');
if (!textValue) {
function visit(node, st, c) {
var hasRequire = wordRe.test(src.slice(node.start, node.end));
if (!hasRequire) return;
walk.base[node.type](node, st, c);
if (node.type !== 'CallExpression') return;
if (isRequire(node)) {
if (node.arguments.length) {
var arg = node.arguments[0];
if (arg.type === 'Literal') {
modules.strings.push(arg.value);
}
else {
modules.expressions.push(src.slice(arg.start, arg.end));
}
}
if (opts.nodes) modules.nodes.push(node);
}
}
function c(node, _, override) {
if (node.end < pos) return
if (node.start >= pos && types[node.type]) {
stack.push(node)
throw new Found
}
if (!override) stack.push(node)
walk.base[override || node.type](node, null, c)
if (!override) stack.pop()
}
try {
Patcher.prototype.walk = function(ast, state, visitors) {
return acorn_dist_walk.recursive(ast, state, visitors, acorn_dist_walk.base);
};
CallExpression: (node, state, recurse) => {
Walk.base[node.type](node, state, recurse);
if (node.callee.type === 'Identifier'
&& node.callee.name === 'require'
&& node.arguments.length
&& node.arguments[0].type === 'Literal'
) {
const arg = node.arguments[0];
const spec = arg.value;
if (spec[0] === '.' || spec[0] === '/') return;
try {
require(spec);
} catch (__) {
missing.push(spec);
var xtend = require('xtend')
var walk = require('acorn/dist/walk')
var base = xtend(walk.base, {
Import: function () {}
})
function simple (node, visitors, baseVisitor, state, override) {
return walk.simple(node, visitors, baseVisitor || base, state, override)
}
function ancestor (node, visitors, baseVisitor, state) {
return walk.ancestor(node, visitors, baseVisitor || base, state)
}
function recursive (node, state, funcs, baseVisitor, override) {
return walk.recursive(node, state, funcs, baseVisitor || base, override)
}
function full (node, callback, baseVisitor, state, override) {