mirror of
https://github.com/swc-project/swc.git
synced 2024-12-01 01:13:56 +03:00
feat(es/ast): Add EsNext
to EsVersion
(#6816)
This commit is contained in:
parent
4ea0e20ded
commit
ff78b8f7e0
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"jsc": {
|
|
||||||
"parser": {
|
|
||||||
"syntax": "typescript",
|
|
||||||
"dynamicImport": true
|
|
||||||
},
|
|
||||||
"externalHelpers": true,
|
|
||||||
"target": "esnext"
|
|
||||||
},
|
|
||||||
"sourceMaps": true
|
|
||||||
}
|
|
@ -21,14 +21,6 @@ fn issue_4390() {
|
|||||||
dbg!(&rc);
|
dbg!(&rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn issue_1532() {
|
|
||||||
let res = serde_json::from_str::<Options>(include_str!("issue-1532.json"));
|
|
||||||
|
|
||||||
let err = res.expect_err("should fail");
|
|
||||||
assert!(err.to_string().contains("unknown variant `esnext`"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn jsonc() {
|
fn jsonc() {
|
||||||
let rc = parse_swcrc(include_str!("jsonc.json")).expect("failed to parse");
|
let rc = parse_swcrc(include_str!("jsonc.json")).expect("failed to parse");
|
||||||
|
@ -40,14 +40,6 @@ fn swcrc_simple() {
|
|||||||
println!("{}", f);
|
println!("{}", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn issue_1532() {
|
|
||||||
let f = file("tests/swcrc_errors/issue-1532/index.js");
|
|
||||||
println!("{}", f);
|
|
||||||
|
|
||||||
assert!(f.contains("unknown variant `esnext`"))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[testing::fixture("tests/errors/**/input.js")]
|
#[testing::fixture("tests/errors/**/input.js")]
|
||||||
#[testing::fixture("tests/errors/**/input.ts")]
|
#[testing::fixture("tests/errors/**/input.ts")]
|
||||||
fn fixture(input: PathBuf) {
|
fn fixture(input: PathBuf) {
|
||||||
|
@ -126,6 +126,8 @@ pub enum EsVersion {
|
|||||||
Es2021,
|
Es2021,
|
||||||
#[serde(rename = "es2022")]
|
#[serde(rename = "es2022")]
|
||||||
Es2022,
|
Es2022,
|
||||||
|
#[serde(rename = "esnext")]
|
||||||
|
EsNext,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EsVersion {
|
impl EsVersion {
|
||||||
|
@ -10,34 +10,6 @@ it("should work", () => {
|
|||||||
}).toThrow("jsc");
|
}).toThrow("jsc");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("should work", () => {
|
|
||||||
expect(() => {
|
|
||||||
const filename = 'index.ts';
|
|
||||||
|
|
||||||
const code = `
|
|
||||||
export async function getDependency(): Promise<any> {
|
|
||||||
return import('./dep').then(({dependency}) => dependency);
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
jsc: {
|
|
||||||
parser: {
|
|
||||||
syntax: 'typescript',
|
|
||||||
dynamicImport: true
|
|
||||||
},
|
|
||||||
externalHelpers: true,
|
|
||||||
target: 'esnext'
|
|
||||||
},
|
|
||||||
sourceMaps: true,
|
|
||||||
filename
|
|
||||||
}
|
|
||||||
|
|
||||||
swc.transformSync(code, options)
|
|
||||||
}).toThrow("unknown variant `esnext`");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should report good error", () => {
|
it("should report good error", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
swc.transformFileSync(__dirname + "/../tests/error/simple.js");
|
swc.transformFileSync(__dirname + "/../tests/error/simple.js");
|
||||||
|
Loading…
Reference in New Issue
Block a user