@@ -223,6 +223,15 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||||||
}));
|
}));
|
||||||
node.thedef = sym;
|
node.thedef = sym;
|
||||||
}
|
}
|
||||||
|
if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
|
||||||
|
js_error(
|
||||||
|
node.TYPE + " statement may only appear at top level",
|
||||||
|
node.start.file,
|
||||||
|
node.start.line,
|
||||||
|
node.start.col,
|
||||||
|
node.start.pos
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function mark_export(def, level) {
|
function mark_export(def, level) {
|
||||||
var node = tw.parent(level);
|
var node = tw.parent(level);
|
||||||
|
|||||||
@@ -40,34 +40,6 @@ issue_2038_2: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_2124: {
|
|
||||||
options = {
|
|
||||||
unused: true,
|
|
||||||
}
|
|
||||||
input: {
|
|
||||||
{
|
|
||||||
export var V = 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
export let L = 2;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
export const C = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expect: {
|
|
||||||
{
|
|
||||||
export var V = 1;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
export let L = 2;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
export const C = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
issue_2126: {
|
issue_2126: {
|
||||||
mangle = {
|
mangle = {
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
|
|||||||
3
test/input/invalid/export.js
Normal file
3
test/input/invalid/export.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
export var V = 1;
|
||||||
|
}
|
||||||
3
test/input/invalid/import.js
Normal file
3
test/input/invalid/import.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
import A from "B";
|
||||||
|
}
|
||||||
@@ -533,6 +533,36 @@ describe("bin/uglifyjs", function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("Should throw syntax error (block-level export)", function(done) {
|
||||||
|
var command = uglifyjscmd + ' test/input/invalid/export.js -m';
|
||||||
|
|
||||||
|
exec(command, function (err, stdout, stderr) {
|
||||||
|
assert.ok(err);
|
||||||
|
assert.strictEqual(stdout, "");
|
||||||
|
assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [
|
||||||
|
"Parse error at test/input/invalid/export.js:2,4",
|
||||||
|
" export var V = 1;",
|
||||||
|
" ^",
|
||||||
|
"ERROR: Export statement may only appear at top level"
|
||||||
|
].join("\n"));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("Should throw syntax error (block-level import)", function(done) {
|
||||||
|
var command = uglifyjscmd + ' test/input/invalid/import.js -m';
|
||||||
|
|
||||||
|
exec(command, function (err, stdout, stderr) {
|
||||||
|
assert.ok(err);
|
||||||
|
assert.strictEqual(stdout, "");
|
||||||
|
assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [
|
||||||
|
"Parse error at test/input/invalid/import.js:2,4",
|
||||||
|
' import A from "B";',
|
||||||
|
" ^",
|
||||||
|
"ERROR: Import statement may only appear at top level"
|
||||||
|
].join("\n"));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
it("Should handle literal string as source map input", function(done) {
|
it("Should handle literal string as source map input", function(done) {
|
||||||
var command = [
|
var command = [
|
||||||
uglifyjscmd,
|
uglifyjscmd,
|
||||||
|
|||||||
Reference in New Issue
Block a user