vaderjs 1.3.3-alpha-90 → 1.3.3-alpha-91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vader.js +9 -5
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vaderjs",
3
3
  "description": "A Reactive library aimed to helping you build reactive applications inspired by react.js",
4
4
  "module": "vader.js",
5
- "version": "1.3.3-alpha-90",
5
+ "version": "1.3.3-alpha-91",
6
6
  "bin": {
7
7
  "vader": "./vader.js"
8
8
  },
package/vader.js CHANGED
@@ -559,7 +559,9 @@ function Compiler(func, file) {
559
559
  if (line.includes('import')) {
560
560
  // Regular expression for matching import() statements
561
561
  let asyncimportMatch = line.match(/import\s*\((.*)\)/gs);
562
- let regularimportMatch = line.match(/import\s+([\w\s{},]*)\s*from\s*(['"][^'"]+['"])(?![^<]*>)/gs);
562
+ // handle named imports and unnamed import 'path'
563
+ let regularimportMatch = line.match(/import\s*([a-zA-Z0-9_-]+)?\s*from\s*('(.*)'|"(.*)")|import\s*('(.*)'|"(.*)")/gs);
564
+
563
565
 
564
566
  if (asyncimportMatch) {
565
567
  asyncimportMatch.forEach(async (match) => {
@@ -609,11 +611,13 @@ function Compiler(func, file) {
609
611
 
610
612
  if (regularimportMatch) {
611
613
  for (let match of regularimportMatch) {
612
- let beforeimport = match
613
- let path = match.split('from')[1].trim() || match.split('import')[1]
614
+ let beforeimport = match
615
+ // import {name} from 'path' or import 'path'
616
+ let path = match.split('from')[1] ? match.split('from')[1].trim() : match.split('import')[1].trim()
614
617
  let newImport = ''
615
618
  let name = match.split('import')[1].split('from')[0].trim()
616
-
619
+
620
+ path = path.replace(/'/g, '').trim().replace(/"/g, '').trim()
617
621
  switch (true) {
618
622
  case path && path.includes('json'):
619
623
  path = path.replace(';', '')
@@ -657,7 +661,7 @@ function Compiler(func, file) {
657
661
  path = path.replaceAll('.jsx', '.js');
658
662
 
659
663
 
660
- string = string.replace(beforePath, "'" + path + "'")
664
+ string = string.replace(beforePath, path)
661
665
  break;
662
666
 
663
667
  }