-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add typeonly example with crashing swcrc
- Loading branch information
Showing
11 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
load("@aspect_rules_swc//swc:defs.bzl", "swc") | ||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") | ||
load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches") | ||
|
||
# Example test reproducing https://github.com/swc-project/swc/issues/7822 | ||
|
||
swc( | ||
name = "compile", | ||
srcs = [ | ||
"a.ts", | ||
"b.ts", | ||
"c.d.ts", | ||
"e.ts", | ||
], | ||
out_dir = "out", | ||
source_maps = True, | ||
swcrc = "swcrc.json", | ||
) | ||
|
||
# Assert that the output of "compile" rule matches the expected file. | ||
write_source_files( | ||
name = "test", | ||
files = { | ||
"expected/a.js": ":out/a.js", | ||
"expected/b.js": ":out/b.js", | ||
}, | ||
) | ||
|
||
[ | ||
assert_json_matches( | ||
name = "test_%s" % f.replace("/", "-"), | ||
file1 = ":out/%s.js.map" % f, | ||
file2 = "expected/%s.js.map.golden" % f, | ||
filter1 = ".sourceRoot,.sources", | ||
filter2 = ".sourceRoot,.sources", | ||
) | ||
for f in [ | ||
"a", | ||
"b", | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Can also be reproduced using the swc-binary. Not (yet) reproduced using @swc/cli | ||
|
||
``` | ||
> ./swc-darwin-x64 compile --source-file-name c.d.ts --config-file swcrc.json --source-maps true --out-file c.js c.d.ts | ||
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sourcemap-6.2.3/src/types.rs:655:9 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
``` | ||
|
||
``` | ||
> ./swc-darwin-x64 compile --source-file-name b.ts --config-file swcrc.json --source-maps true --out-file b.js b.ts | ||
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sourcemap-6.2.3/src/types.rs:655:9 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Foo } from "./b" | ||
import { Bar } from "./c" | ||
|
||
const a: Foo = 1 | ||
const b: Bar = 2 | ||
|
||
console.log(a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Foo = number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Bar = number |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"sources": [ | ||
"../a.ts" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"sources": [ | ||
"../b.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"sourceMaps": true, | ||
"module": { | ||
"type": "commonjs", | ||
"strictMode": true, | ||
"noInterop": true | ||
}, | ||
"jsc": { | ||
"externalHelpers": true, | ||
"target": "es2015", | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true, | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"transform": { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true, | ||
"react": { | ||
"throwIfNamespace": false, | ||
"useBuiltins": false, | ||
"pragma": "React.createElement", | ||
"pragmaFrag": "React.Fragment", | ||
"importSource": "react" | ||
} | ||
}, | ||
"keepClassNames": false | ||
} | ||
} |