Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// mark this file as checked
checked.push(file);
const ext = (path.extname(file) || '').toLowerCase();
if (!extensions.includes(ext)) {
return;
}
if (typeof src === 'undefined') {
src = await readFile(file, 'utf-8');
}
const basedir = path.dirname(file);
let deps;
try {
const babelResult = babel.transform(src, {
ast: true,
babelrc: true,
plugins: [
pluginSyntaxRestSpread,
pluginSyntaxGenerator,
pluginDynamicImport,
pluginCJS
],
filename: file,
sourceFileName: file,
highlightCode: true
});
const result = konan(babelResult.ast);
deps = result.strings;
} catch (err) {
throw err;
it('should sort entries by msgid', () => {
const expectedPath = 'tests/fixtures/expected_sort.pot';
const input = `
t\`bbbb\`;
t\`aaaaa\`;
t\`ccccc\`;
t\`fffff\`;
t\`eeeee\`;
`;
babel.transform(input, options);
const result = fs.readFileSync(output).toString();
const expected = fs.readFileSync(expectedPath).toString();
expect(result).to.eql(expected);
});
});
function loader(source) {
let options = loaderUtils.getOptions(this);
let cb = this.async();
babel.transform(source, {
...options,
filename: this.resourcePath.split('/').pop(),
sourceMaps: true
}, (err, result) => {
cb(null, result.code, result.map);
})
}
console.log()
console.log(`${binding.kind} ${name}`)
console.log(` referencese: ${binding.references}`)
binding.referencePaths.forEach(refPath => {
console.log(` ${refPath.parentPath.getSource()}`)
})
console.log(` constantViolations: ${binding.constantViolations.length}`)
binding.constantViolations.forEach(vPath => {
console.log(` ${vPath.getSource()}`)
})
}
}
}
}
transform(src, {plugins: [plugin]})
function transformSjsToWxs (code) {
return babel.transform(code, {
"presets": [
[
babelPreset
]
],
plugins: [
[
require('@babel/plugin-transform-modules-commonjs'),
{
allowTopLevelThis: true,
loose: true,
strict: true
}
]
]
}).code;
const sourceMaps = !shouldPrintCode;
const sourceMapsFile = shouldPrintCode
? path.join(path.dirname(filePath), "readme.md.js")
: filePath;
req.forEach(f => {
require(require.resolve(f, { paths: [process.cwd()] }));
});
const mdDirname = path.dirname(filePath);
process.chdir(mdDirname);
const mdText = read(filePath);
const rootPkg = pkgUp.sync();
const pkg = JSON.parse(read(rootPkg));
const { code, hasTypescript } = extract(mdText, { auto, all });
const transformed = babel.transform(code, {
babelrc,
sourceMaps,
plugins: [
...(hasTypescript ? [typescriptTransform] : []),
commentPlugin,
rootPkg
? [
importPlugin,
{ replacement: main || process.cwd(), original: pkg.name }
]
: undefined
],
presets: [presetEnv],
filename: sourceMapsFile
});
function typescriptPrep(fname, src) {
return babel.transform(src, {
presets: ["@babel/preset-typescript"],
plugins: ["@babel/plugin-proposal-class-properties"],
filename: fname,
retainLines: true,
parserOpts: {strictMode: false}
}).code;
}
export function compileSync(code, extraBabelOptions = {}, url = "/no_url.js") {
code = removeSourceMapIfAny(code);
const babelResult = babel.transform(
code,
getBabelOptions(plugin, extraBabelOptions, url)
);
return {
map: babelResult.map,
code: babelResult.code + "\n//# sourceMappingURL=" + url + ".map",
locs: getAndResetLocs()
};
}
loadSync(id) {
const content = require('@babel/core').transform(readFileSync(id, 'utf8'), {
babelrc: false,
configFile: false,
filename: id,
presets: [
[
require('@babel/preset-env'),
{
targets: {
node: 'current'
}
}
],
id.endsWith('.ts') && require('@babel/preset-typescript')
].filter(Boolean)
});
const m = requireFromString(content && content.code ? content.code : '', id);
function tryParseCjs (source) {
const requires = new Set();
let hasProcess, hasBuffer;
const { ast } = babel.transform(source, {
ast: true,
babelrc: false,
babelrcRoots: false,
configFile: false,
highlightCode: false,
compact: false,
sourceType: 'script',
parserOpts: {
allowReturnOutsideFunction: true,
plugins: stage3Syntax
},
plugins: [({ types: t }) => {
function resolvePartialWildcardString (node, lastIsWildcard) {
if (t.isStringLiteral(node))
return node.value;
if (t.isTemplateLiteral(node)) {