Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Parse acorn ast for AMD, CommonJS, and ES6 definitions.
The Nodes created align as closely as possible with the nodes generated for acorns ES6 import nodes. Example below
var acorn = require('acorn');
var umd = require('acorn-umd');
var code = `
import {a, b, c as d} from 'library';
import foo from 'foo-library';
let _ = require('lodash');
`;
var ast = acorn.parse(code, {ecmaVersion: 6});
var imports = umd(ast, {
es6: true, amd: false, cjs: true
});
console.log(imports);
[
{ type: 'CJSImport',
reference:
{ type: 'VariableDeclaration',
start: 87,
end: 113,
declarations: [Object],
kind: 'let' },
specifiers: [ [Object] ],
start: 87,
end: 113,
source:
{ type: 'Literal',
reference: [Object],
value: 'lodash',
raw: '\'lodash\'',
start: 103,
end: 111 }
},
{ type: 'ImportDeclaration',
start: 5,
end: 42,
specifiers: [ [Object], [Object], [Object] ],
source:
{ type: 'Literal',
start: 32,
end: 41,
value: 'library',
raw: '\'library\'' }
},
{ type: 'ImportDeclaration',
start: 47,
end: 77,
specifiers: [ [Object] ],
source:
{ type: 'Literal',
start: 63,
end: 76,
value: 'foo-library',
raw: '\'foo-library\'' }
}
]
let code = `
foo();
define(['foo', 'unused-import'], function($) {
return $();
});
`;
let ast = acorn.parse(code, {ecmaVersion: 6});
let parsed = umd(ast, {
es6: false, amd: true, cjs: false
});
console.log(parsed);
[
{
type: 'AMDImport',
reference: { DEFINE_NODE },
start: 12,
end: 81,
specifiers: [ { type: 'Identifier', start: 54, end: 55, name: '$' } ],
sources:
[ { type: 'Literal',
reference: [Object],
value: 'foo',
raw: '\'foo\'',
start: 20,
end: 25 },
{ type: 'Literal',
reference: [Object],
value: 'unused-import',
raw: '\'unused-import\'',
start: 27,
end: 42 } ],
// Grouped [source, variable] name array
imports: [ [ {SOURCE_NODE}, {VARIABLE_NODE} ], [ {SOURCE_NODE}, undefined ]
}
]
import {sample} from 'lodash'
let parsed = umd(ast, {
es6: false, amd: true, cjs: false
});
let node = sample(parsed);
let scope = node.scope; // scope is null if global otherwise a function node
FAQs
Parse acorn ast for AMD, CommonJS, and ES6 definitions
The npm package acorn-umd receives a total of 356 weekly downloads. As such, acorn-umd popularity was classified as not popular.
We found that acorn-umd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.