-
-
Notifications
You must be signed in to change notification settings - Fork 69
Test case for ts/js interop. #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/swcrc", | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true | ||
}, | ||
"target": "es2018" | ||
}, | ||
"module": { | ||
"type": "commonjs" | ||
}, | ||
"minify": false | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||||
load("@aspect_rules_swc//swc:defs.bzl", "swc") | ||||
load("@bazel_skylib//lib:partial.bzl", "partial") | ||||
|
||||
ts_project( | ||||
name = "a_b", | ||||
srcs = [ | ||||
"a.js", | ||||
"b.ts", | ||||
], | ||||
allow_js = True, | ||||
declaration = True, | ||||
emit_declaration_only = True, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I figured as much. So this test case can be deleted and clearly does not solve my problem. I only included it to point out that this is one way to avoid the conflict error, but I need b.js to be produced in my environment. |
||||
resolve_json_module = True, | ||||
transpiler = partial.make( | ||||
swc, | ||||
swcrc = ":.swcrc", | ||||
), | ||||
tsconfig = ":tsconfig.json", | ||||
) | ||||
|
||||
filegroup( | ||||
name = "transpiled_a_b", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these Can we replace those with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with build_test targets, but probably? Have changes gone in that allow these filegroups to build successfully now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Search for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rules_ts/ts/private/build_test.bzl Line 7 in 3849ce6
I see, makes sense. It's a trivial test that will always pass as long as it builds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I've almost exclusively used it for testing rules just like this test you've written. |
||||
# Expect this source to be generated by swc transpilation. | ||||
srcs = ["b.js"], | ||||
) | ||||
|
||||
# Expect not to get: | ||||
# ERROR: file 'examples/ts_js_interop/c.js' is generated by these conflicting actions: | ||||
# Label: //examples/ts_js_interop:c_d_tsc, //examples/ts_js_interop:c_d_transpile | ||||
ts_project( | ||||
name = "c_d", | ||||
srcs = [ | ||||
"c.js", | ||||
"d.ts", | ||||
], | ||||
allow_js = True, | ||||
declaration = True, | ||||
resolve_json_module = True, | ||||
transpiler = partial.make( | ||||
swc, | ||||
swcrc = ":.swcrc", | ||||
), | ||||
tsconfig = ":tsconfig.emit.json", | ||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = 1; | ||
export default a; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = 1; | ||
export default a; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import a from './a' | ||
|
||
console.log(a) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const c = 1 | ||
export default c |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import c from './c' | ||
|
||
console.log(c) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "./", | ||
"esModuleInterop": true, | ||
"rootDirs": ["."], | ||
"allowJs": true, | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"emitDeclarationOnly": true, | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "./", | ||
"esModuleInterop": true, | ||
"rootDirs": ["."], | ||
"allowJs": true, | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": [] | ||
} |
Uh oh!
There was an error while loading. Please reload this page.