vaderjs 1.3.3-alpha-89 → 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.
- package/package.json +1 -1
- package/vader.js +12 -6
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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(';', '')
|
|
@@ -633,8 +637,10 @@ function Compiler(func, file) {
|
|
|
633
637
|
newImport = `let ${name} = ${JSON.stringify(parse(css))}`
|
|
634
638
|
string = string.replace(beforeimport, newImport)
|
|
635
639
|
break;
|
|
636
|
-
case path && path.
|
|
640
|
+
case path && path.endsWith('.css'):
|
|
641
|
+
console.log(path)
|
|
637
642
|
string = string.replace(beforeimport, '')
|
|
643
|
+
newImport = ``
|
|
638
644
|
break;
|
|
639
645
|
default:
|
|
640
646
|
let beforePath = path
|
|
@@ -655,7 +661,7 @@ function Compiler(func, file) {
|
|
|
655
661
|
path = path.replaceAll('.jsx', '.js');
|
|
656
662
|
|
|
657
663
|
|
|
658
|
-
string = string.replace(beforePath,
|
|
664
|
+
string = string.replace(beforePath, path)
|
|
659
665
|
break;
|
|
660
666
|
|
|
661
667
|
}
|