Another variant of import added - import * from "x.js"
This commit is contained in:
parent
5dea52266b
commit
c5bf0f0075
|
|
@ -1233,17 +1233,21 @@ function OutputStream(options) {
|
||||||
output.space();
|
output.space();
|
||||||
}
|
}
|
||||||
if (self.imported_names) {
|
if (self.imported_names) {
|
||||||
output.print("{");
|
if (self.imported_names.length === 1 && self.imported_names[0].name.name === "*") {
|
||||||
self.imported_names.forEach(function(name_import, i) {
|
self.imported_names[0].print(output);
|
||||||
output.space();
|
} else {
|
||||||
name_import.print(output);
|
output.print("{");
|
||||||
if (i < self.imported_names.length - 1) {
|
self.imported_names.forEach(function (name_import, i) {
|
||||||
output.print(",");
|
|
||||||
output.space();
|
output.space();
|
||||||
}
|
name_import.print(output);
|
||||||
});
|
if (i < self.imported_names.length - 1) {
|
||||||
output.space();
|
output.print(",");
|
||||||
output.print("}");
|
output.space();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
output.space();
|
||||||
|
output.print("}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (self.imported_name || self.imported_names) {
|
if (self.imported_name || self.imported_names) {
|
||||||
output.space();
|
output.space();
|
||||||
|
|
|
||||||
45
lib/parse.js
45
lib/parse.js
|
|
@ -2176,17 +2176,7 @@ function parse($TEXT, options) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is("punc", "{")) {
|
imported_names = import_names();
|
||||||
next();
|
|
||||||
imported_names = [];
|
|
||||||
while (!is("punc", "}")) {
|
|
||||||
imported_names.push(import_name());
|
|
||||||
if (is("punc", ",")) {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imported_names || imported_name) {
|
if (imported_names || imported_name) {
|
||||||
expect_token("name", "from");
|
expect_token("name", "from");
|
||||||
|
|
@ -2266,6 +2256,24 @@ function parse($TEXT, options) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function import_names() {
|
||||||
|
var names;
|
||||||
|
if (is("punc", "{")) {
|
||||||
|
next();
|
||||||
|
names = [];
|
||||||
|
while (!is("punc", "}")) {
|
||||||
|
names.push(import_name());
|
||||||
|
if (is("punc", ",")) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
} else if (is("operator", "*")) {
|
||||||
|
var st = prev();
|
||||||
|
names = [import_nameAsterisk()];
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
function export_() {
|
function export_() {
|
||||||
var start = S.token;
|
var start = S.token;
|
||||||
var is_default;
|
var is_default;
|
||||||
|
|
@ -2278,20 +2286,7 @@ function parse($TEXT, options) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is("punc", "{")) {
|
exported_names = import_names();
|
||||||
next();
|
|
||||||
exported_names = [];
|
|
||||||
while (!is("punc", "}")) {
|
|
||||||
exported_names.push(import_name());
|
|
||||||
if (is("punc", ",")) {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
} else if (is("operator", "*")) {
|
|
||||||
var st = prev();
|
|
||||||
exported_names = [import_nameAsterisk()];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exported_names) {
|
if (exported_names) {
|
||||||
expect_token("name", "from");
|
expect_token("name", "from");
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,9 @@ import_statement: {
|
||||||
import { Bar, Baz } from 'lel';
|
import { Bar, Baz } from 'lel';
|
||||||
import Bar, { Foo } from 'lel';
|
import Bar, { Foo } from 'lel';
|
||||||
import { Bar as kex, Baz as food } from 'lel';
|
import { Bar as kex, Baz as food } from 'lel';
|
||||||
|
import * from 'lel';
|
||||||
}
|
}
|
||||||
expect_exact: "import\"mod-name\";import Foo from\"bar\";import{Bar,Baz}from\"lel\";import Bar,{Foo}from\"lel\";import{Bar as kex,Baz as food}from\"lel\";"
|
expect_exact: "import\"mod-name\";import Foo from\"bar\";import{Bar,Baz}from\"lel\";import Bar,{Foo}from\"lel\";import{Bar as kex,Baz as food}from\"lel\";import*from\"lel\";"
|
||||||
}
|
}
|
||||||
|
|
||||||
export_statement: {
|
export_statement: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user