diff --git a/index.js b/index.js index 791265b..59466c8 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,10 @@ var hook = require('node-hook'); hook.hook('.js', (src, name) => { src = src.replace(/import ([^{]*?) from '(.*?)'/g, 'const $1 = require("$2")'); + src = src.replace(/import ([^{]*?);/g, 'const $1 = require("$1")'); src = src.replace(/export default ([^ ]*)/g, 'module.exports = $1'); src = src.replace(/export (var|let|const) ([a-zA-Z0-9_$]*)/g, '$1 $2 = module.exports.$2'); + src = src.replace(/export async function ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = async function'); src = src.replace(/export function ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = function'); src = src.replace(/export class ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = class'); src = src.replace(/import {(.*?)} from '(.*?)'/g, (all, $1, $2) => { @@ -12,4 +14,4 @@ hook.hook('.js', (src, name) => { .join(''); }); return src; -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 4cb2529..8aa88db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "import-export", - "version": "1.0.1", + "version": "1.0.2", "description": "Use ECMA6 import/export syntax from within NodeJS (simply require this module)", "main": "index.js", "dependencies": {