Comparing version 1.0.3 to 2.0.0
53
index.js
@@ -1,7 +0,30 @@ | ||
const esprima = require('esprima'); | ||
const parser = require('babylon'); | ||
const defaultOptions = { | ||
sourceType: 'module', | ||
jsx: true, | ||
range: true, | ||
tolerant: true | ||
plugins: [ | ||
'estree', | ||
'jsx', | ||
'flow', | ||
'typescript', | ||
'doExpressions', | ||
'objectRestSpread', | ||
'decorators', | ||
'decorators2', | ||
'classProperties', | ||
'classPrivateProperties', | ||
'classPrivateMethods', | ||
'exportExtensions', | ||
'asyncGenerators', | ||
'functionBind', | ||
'functionSent', | ||
'dynamicImport', | ||
'numericSeparator', | ||
'optionalChaining', | ||
'importMeta', | ||
'bigInt', | ||
'optionalCatchBinding', | ||
'throwExpressions', | ||
'pipelineOperator', | ||
'nullishCoalescingOperator' | ||
] | ||
}; | ||
@@ -13,6 +36,6 @@ | ||
const slice = (code, info) => code.slice(info.range[0], info.range[1]); | ||
const slice = (code, info) => code.slice(info.start, info.end); | ||
const chunk = (info, esm, cjs) => ({ | ||
start: info.range[0], | ||
end: info.range[1], | ||
start: info.start, | ||
end: info.end, | ||
esm, cjs | ||
@@ -123,6 +146,6 @@ }); | ||
const parse = (code, options) => { | ||
code = code.toString(); | ||
const out = []; | ||
const chunks = []; | ||
code = code.toString(); | ||
esprima.parse( | ||
const parsed = parser.parse( | ||
code, | ||
@@ -133,9 +156,9 @@ Object.assign( | ||
options | ||
), | ||
item => { | ||
if (replace.hasOwnProperty(item.type)) { | ||
chunks.push(replace[item.type](code, item)); | ||
} | ||
) | ||
); | ||
parsed.program.body.forEach(item => { | ||
if (replace.hasOwnProperty(item.type)) { | ||
chunks.push(replace[item.type](code, item)); | ||
} | ||
); | ||
}); | ||
const length = chunks.length; | ||
@@ -142,0 +165,0 @@ let c = 0; |
{ | ||
"name": "ascjs", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "ES2015 to CommonJS import/export transformer", | ||
@@ -30,3 +30,3 @@ "bin": "bin.js", | ||
"dependencies": { | ||
"esprima": "^4.0.0" | ||
"babylon": "^6.18.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12791
248
+ Addedbabylon@^6.18.0
+ Addedbabylon@6.18.0(transitive)
- Removedesprima@^4.0.0
- Removedesprima@4.0.1(transitive)