Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function searchRuntimeDependencies(str, module = false) {
const identifiers = new Map();
const dependencies = new Set();
let isSuspect = false;
if (str.charAt(0) === "#") {
// eslint-disable-next-line
str = str.slice(str.indexOf("\n"));
}
const { body } = meriyah.parseScript(str, { next: true, module });
walk(body, {
enter(node) {
// console.log(JSON.stringify(node, null, 2));
// console.log("-------------------------");
try {
if (!module && (helpers.isRequireStatment(node) || helpers.isRequireResolve(node))) {
const arg = node.arguments[0];
if (arg.type === "Identifier") {
if (identifiers.has(arg.name)) {
dependencies.add(identifiers.get(arg.name));
}
else {
isSuspect = true;
}
}
function parsemeriyah(str) {
return meriyah.parseModule(str);
}
module.exports = function parse (source, options) {
return meriyah.parseModule(source, options)
}
module.exports = function parse (source, options) {
return meriyah.parseModule(source, options)
}
export function parseAst(contents: string, options?: { loc: boolean }) {
let opts = { jsx: true, next: false, module: true, ...(options || {}) };
return meriyah.parse(contents, opts);
}
import React from 'react';
import defaultParserInterface from './utils/defaultESTreeParserInterface';
import pkg from 'meriyah/package.json';
const ID = pkg.name;
export default {
...defaultParserInterface,
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,
loadParser(callback) {
require(['meriyah'], callback);
},
parse(parser, code, options) {
return parser.parse(code, options);
},
nodeToRange(node) {
if (typeof node.start === 'number') {
return [node.start, node.end];
}
},
getDefaultOptions() {
renderSettings(parserSettings, onChange) {
return (
<div>
<p>
<a rel="noopener noreferrer" href="{pkg.homepage}">
Option descriptions
</a>
</p>
{defaultParserInterface.renderSettings.call(
this,
parserSettings,
onChange,
)}
</div>
);
},
};
import React from 'react';
import defaultParserInterface from './utils/defaultESTreeParserInterface';
import pkg from 'meriyah/package.json';
const ID = pkg.name;
export default {
...defaultParserInterface,
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,
loadParser(callback) {
require(['meriyah'], callback);
},
parse(parser, code, options) {
return parser.parse(code, options);
},
import React from 'react';
import defaultParserInterface from './utils/defaultESTreeParserInterface';
import pkg from 'meriyah/package.json';
const ID = pkg.name;
export default {
...defaultParserInterface,
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,
loadParser(callback) {
require(['meriyah'], callback);
},
parse(parser, code, options) {
return parser.parse(code, options);
},
nodeToRange(node) {
if (typeof node.start === 'number') {
return [node.start, node.end];
}
},