mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
test(es): Add tests for fixed issues (#3875)
**Description:** Adds tests for fixed issues. This commit modifies one type because the previous type makes transform flaky. **BREAKING CHANGE:** To preserve order, the type `swc::Paths` is now `IndexMap` instead of `HashMap`.
This commit is contained in:
parent
d524cc3c5b
commit
8d3c9d39f0
@ -1054,7 +1054,7 @@ impl Merge for JscExperimental {
|
||||
}
|
||||
|
||||
/// `paths` section of `tsconfig.json`.
|
||||
pub type Paths = AHashMap<String, Vec<String>>;
|
||||
pub type Paths = IndexMap<String, Vec<String>, ahash::RandomState>;
|
||||
pub(crate) type CompiledPaths = Vec<(String, Vec<String>)>;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -1558,6 +1558,19 @@ impl Merge for JscConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, S> Merge for IndexMap<K, V, S>
|
||||
where
|
||||
K: Clone + Eq + std::hash::Hash,
|
||||
V: Clone,
|
||||
S: Clone + BuildHasher,
|
||||
{
|
||||
fn merge(&mut self, from: &Self) {
|
||||
if self.is_empty() {
|
||||
*self = (*from).clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, S> Merge for HashMap<K, V, S>
|
||||
where
|
||||
K: Clone + Eq + std::hash::Hash,
|
||||
|
21
crates/swc/tests/fixture/parser/issue-2844/input/.swcrc
Normal file
21
crates/swc/tests/fixture/parser/issue-2844/input/.swcrc
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript",
|
||||
"jsx": false,
|
||||
"dynamicImport": false,
|
||||
"privateMethod": false,
|
||||
"functionBind": false,
|
||||
"exportDefaultFrom": false,
|
||||
"exportNamespaceFrom": false,
|
||||
"decorators": false,
|
||||
"decoratorsBeforeExport": false,
|
||||
"topLevelAwait": false,
|
||||
"importMeta": false
|
||||
},
|
||||
"transform": null,
|
||||
"target": "es5",
|
||||
"loose": false,
|
||||
"externalHelpers": false
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
class X { st\u0061tic y() { } }
|
14
crates/swc/tests/fixture/parser/issue-2844/output/index.js
Normal file
14
crates/swc/tests/fixture/parser/issue-2844/output/index.js
Normal file
@ -0,0 +1,14 @@
|
||||
import * as swcHelpers from "@swc/helpers";
|
||||
var X = /*#__PURE__*/ function() {
|
||||
"use strict";
|
||||
function X() {
|
||||
swcHelpers.classCallCheck(this, X);
|
||||
}
|
||||
swcHelpers.createClass(X, null, [
|
||||
{
|
||||
key: "y",
|
||||
value: function y() {}
|
||||
}
|
||||
]);
|
||||
return X;
|
||||
}();
|
26
crates/swc/tests/fixture/paths/issue-2844/input/.swcrc
Normal file
26
crates/swc/tests/fixture/paths/issue-2844/input/.swcrc
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"target": "es2019",
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"core/*": [
|
||||
"core/*"
|
||||
],
|
||||
"utils/*": [
|
||||
"utils/*"
|
||||
],
|
||||
"core": [
|
||||
"core"
|
||||
],
|
||||
"utils": [
|
||||
"utils"
|
||||
]
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
import * as utilFile from 'core/utils/utilFile'
|
||||
import * as utils from 'utils'
|
@ -0,0 +1 @@
|
||||
export function test() {}
|
@ -0,0 +1,6 @@
|
||||
import 'core/module/moduleFile'
|
||||
import 'core/utils'
|
||||
import 'core/utilFile'
|
||||
import 'utils'
|
||||
|
||||
console.log('SUCCESS');
|
@ -0,0 +1,3 @@
|
||||
import { test } from 'core/utils/utilFile'
|
||||
test();
|
||||
export function utilFn() {}
|
@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
@ -0,0 +1 @@
|
||||
"use strict";
|
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.test = test;
|
||||
function test() {}
|
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
require("./core/module/moduleFile");
|
||||
require("./core/utils/index");
|
||||
require("./core/utilFile");
|
||||
require("./utils");
|
||||
console.log('SUCCESS');
|
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.utilFn = utilFn;
|
||||
var _utilFile = require("../core/utils/utilFile");
|
||||
(0, _utilFile).test();
|
||||
function utilFn() {}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceMaps": true
|
||||
}
|
@ -0,0 +1 @@
|
||||
if(true){var h=Symbol.for;}
|
@ -0,0 +1,3 @@
|
||||
if (true) {
|
||||
var h = Symbol.for;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"mappings": "AAAA,EAAE,EAAC,IAAI,EAAC,CAAC;IAAA,GAAG,CAACA,CAAC,GAACC,MAAM,CAACC,GAAG;AAAC,CAAC",
|
||||
"names": [
|
||||
"h",
|
||||
"Symbol",
|
||||
"for"
|
||||
],
|
||||
"sources": [
|
||||
"../../input/index.js"
|
||||
],
|
||||
"sourcesContent": [
|
||||
"if(true){var h=Symbol.for;}"
|
||||
],
|
||||
"version": 3
|
||||
}
|
@ -0,0 +1 @@
|
||||
const [...rest,] = a
|
@ -0,0 +1,6 @@
|
||||
error: Expected ']', got ','
|
||||
--> $DIR/tests/typescript-errors/issue-3676/input.ts:1:15
|
||||
|
|
||||
1 | const [...rest,] = a
|
||||
| ^
|
||||
|
@ -0,0 +1,14 @@
|
||||
/** @jsx h */
|
||||
/** @jsxFrag Fragment */
|
||||
|
||||
import { h, jsx, Fragment} from 'https://deno.land/x/sift@0.4.3/mod.ts';
|
||||
|
||||
export const pageLayout = ()=>jsx(
|
||||
<>
|
||||
< !doctype html >
|
||||
<html lang='en-US' charSet='UTF-8'>
|
||||
<Head/>
|
||||
<Body/>
|
||||
</html>,
|
||||
</>
|
||||
);
|
@ -0,0 +1,12 @@
|
||||
error: Unexpected token `!`. Expected an identifier, void, yield, null, await, break, a string literal, a numeric literal, true, false, `, -, import, this, typeof, {, [, (
|
||||
--> $DIR/tests/typescript-errors/issue-3712/input.ts:8:6
|
||||
|
|
||||
8 | < !doctype html >
|
||||
| ^
|
||||
|
||||
error: Expression expected
|
||||
--> $DIR/tests/typescript-errors/issue-3712/input.ts:7:4
|
||||
|
|
||||
7 | <>
|
||||
| ^
|
||||
|
Loading…
Reference in New Issue
Block a user