From 35abc178f3f948648997318e9b131a72e45bb3e5 Mon Sep 17 00:00:00 2001 From: Potseluyko Vyacheslav Date: Thu, 17 Aug 2017 13:40:52 +0300 Subject: [PATCH 1/3] Add \" support --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 791265b..ee53d90 100644 --- a/index.js +++ b/index.js @@ -6,10 +6,10 @@ hook.hook('.js', (src, name) => { src = src.replace(/export (var|let|const) ([a-zA-Z0-9_$]*)/g, '$1 $2 = module.exports.$2'); 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) => { + src = src.replace(/import {(.*?)} from ['"](.*?)['"]/g, (all, $1, $2) => { return $1.split(",") .map(part => 'var ' + part + '= require("' + $2 + '").' + part.trim() + ';') .join(''); }); return src; -}); \ No newline at end of file +}); From 0cd26f8b6aa7683bb8f2a74ba218cfe854c05791 Mon Sep 17 00:00:00 2001 From: Potseluyko Vyacheslav Date: Thu, 17 Aug 2017 13:41:47 +0300 Subject: [PATCH 2/3] Add \" support --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ee53d90..dd2d192 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ var hook = require('node-hook'); hook.hook('.js', (src, name) => { - src = src.replace(/import ([^{]*?) from '(.*?)'/g, 'const $1 = require("$2")'); + src = src.replace(/import ([^{]*?) from ['"](.*?)['"]/g, 'const $1 = require("$2")'); 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 function ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = function'); From a15316702028af72146eab8c0f035b14ca7aa8a3 Mon Sep 17 00:00:00 2001 From: Potseluyko Vyacheslav Date: Thu, 17 Aug 2017 14:34:54 +0300 Subject: [PATCH 3/3] Add async functions support --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index dd2d192..e915601 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ hook.hook('.js', (src, name) => { 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 function ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = function'); + src = src.replace(/export async function ([a-zA-Z0-9_$]*)/g, 'var $1 = module.exports.$1 = async 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) => { return $1.split(",")