Comparing version 3.1.2 to 4.0.0
51
index.js
'use strict'; | ||
const parser = require('babylon'); | ||
const parser = require('@babel/parser'); | ||
const defaultOptions = { | ||
allowAwaitOutsideFunction: true, | ||
sourceType: 'module', | ||
@@ -8,24 +9,27 @@ plugins: [ | ||
'jsx', | ||
'flow', | ||
'typescript', | ||
'doExpressions', | ||
'objectRestSpread', | ||
'decorators', | ||
'decorators2', | ||
'exportExtensions', | ||
'exportDefaultFrom', | ||
'exportNamespaceFrom', | ||
'dynamicImport', | ||
'importMeta', | ||
'asyncGenerators', | ||
'bigInt', | ||
'classProperties', | ||
'classPrivateProperties', | ||
'classPrivateMethods', | ||
'exportExtensions', | ||
'asyncGenerators', | ||
['decorators', {decoratorsBeforeExport: true}], | ||
'doExpressions', | ||
'functionBind', | ||
'functionSent', | ||
'dynamicImport', | ||
'logicalAssignment', | ||
'nullishCoalescingOperator', | ||
'numericSeparator', | ||
'objectRestSpread', | ||
'optionalCatchBinding', | ||
'optionalChaining', | ||
'importMeta', | ||
'bigInt', | ||
'optionalCatchBinding', | ||
'partialApplication', | ||
['pipelineOperator', {proposal: 'minimal'}], | ||
'throwExpressions', | ||
'pipelineOperator', | ||
'nullishCoalescingOperator' | ||
'topLevelAwait' | ||
] | ||
@@ -151,2 +155,7 @@ }; | ||
if (!options) options = {}; | ||
const parserOptions = Object.assign( | ||
{}, | ||
defaultOptions, | ||
options | ||
); | ||
parse.info = { | ||
@@ -161,10 +170,3 @@ EXPORT: options.EXPORT || EXPORT, | ||
const chunks = []; | ||
const parsed = parser.parse( | ||
code, | ||
Object.assign( | ||
{}, | ||
defaultOptions, | ||
options | ||
) | ||
); | ||
const parsed = parser.parse(code, parserOptions); | ||
parsed.program.body.forEach(item => { | ||
@@ -185,3 +187,6 @@ if (replace.hasOwnProperty(item.type)) { | ||
out.push(length ? code.slice(c) : code); | ||
const result = out.join(''); | ||
let result = out.join('').replace( | ||
/\bimport\.meta\b/g, | ||
"({url: require('url').pathToFileURL(__filename).href})" | ||
); | ||
return /^(?:#!|['"]use strict['"])/.test(result.trim()) ? | ||
@@ -188,0 +193,0 @@ result : |
{ | ||
"name": "ascjs", | ||
"version": "3.1.2", | ||
"version": "4.0.0", | ||
"description": "ES2015 to CommonJS import/export transformer", | ||
@@ -30,8 +30,8 @@ "bin": "bin.js", | ||
"dependencies": { | ||
"babylon": "^6.18.0" | ||
"@babel/parser": "^7.9.4" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.0.8", | ||
"coveralls": "^3.0.11", | ||
"istanbul": "^0.4.5" | ||
} | ||
} |
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
15110
309
+ Added@babel/parser@^7.9.4
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
- Removedbabylon@^6.18.0
- Removedbabylon@6.18.0(transitive)