-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: add emitIsolatedDts support #270
Draft
jbedard
wants to merge
1
commit into
main
Choose a base branch
from
dts_outs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+159
−5
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,15 @@ | ||
# Import Aspect bazelrc presets | ||
try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/convenience.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/correctness.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/debug.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/javascript.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/performance.bazelrc | ||
|
||
### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### | ||
|
||
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. | ||
# This file should appear in `.gitignore` so that settings are not shared with team members. This | ||
# should be last statement in this config so the user configuration is able to overwrite flags from | ||
# this file. See https://bazel.build/configure/best-practices#bazelrc-file. | ||
try-import %workspace%/../../.aspect/bazelrc/user.bazelrc |
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 @@ | ||
../../.bazelversion |
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,34 @@ | ||
load("@aspect_rules_swc//swc:defs.bzl", "swc") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
swc( | ||
name = "compile", | ||
srcs = [ | ||
"a.ts", | ||
"b.ts", | ||
], | ||
) | ||
|
||
swc( | ||
name = "compile_emit_dts", | ||
srcs = [ | ||
"a.ts", | ||
"b.ts", | ||
], | ||
emit_isolated_dts = True, | ||
out_dir = "dts_out", | ||
) | ||
|
||
build_test( | ||
name = "test", | ||
targets = [ | ||
":compile", | ||
":compile_emit_dts", | ||
"a.js", | ||
"b.js", | ||
"dts_out/a.js", | ||
"dts_out/b.js", | ||
"dts_out/a.d.ts", | ||
"dts_out/b.d.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,14 @@ | ||
bazel_dep(name = "aspect_rules_swc", version = "0.0.0", dev_dependency = True) | ||
local_path_override( | ||
module_name = "aspect_rules_swc", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) | ||
|
||
# Use a recent swc version which includes the experimental emitIsolatedDts feature. | ||
swc = use_extension("@aspect_rules_swc//swc:extensions.bzl", "swc", dev_dependency = True) | ||
swc.toolchain( | ||
name = "swc", | ||
swc_version = "v1.6.6", | ||
) |
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,31 @@ | ||
# Override http_archive for local testing | ||
local_repository( | ||
name = "aspect_rules_swc", | ||
path = "../..", | ||
) | ||
|
||
#---SNIP--- Below here is re-used in the snippet published on releases | ||
|
||
################### | ||
# rules_swc setup # | ||
################### | ||
|
||
# Fetches the rules_swc dependencies. | ||
# If you want to have a different version of some dependency, | ||
# you should fetch it *before* calling this. | ||
# Alternatively, you can skip calling this function, so long as you've | ||
# already fetched all the dependencies. | ||
load("@aspect_rules_swc//swc:dependencies.bzl", "rules_swc_dependencies") | ||
|
||
rules_swc_dependencies() | ||
|
||
# Fetches a SWC cli from | ||
# https://github.com/swc-project/swc/releases | ||
# If you'd rather compile it from source, you can use rules_rust, fetch the project, | ||
# then register the toolchain yourself. (Note, this is not yet documented) | ||
load("@aspect_rules_swc//swc:repositories.bzl", "swc_register_toolchains") | ||
|
||
swc_register_toolchains( | ||
name = "swc", | ||
swc_version = "v1.6.6", | ||
) |
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 @@ | ||
# This file replaces `WORKSPACE.bazel` when --enable_bzlmod is set. |
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,8 @@ | ||
export interface Foo { | ||
name: string; | ||
} | ||
|
||
export const A = 1; | ||
export const AF: Foo = { | ||
name: "bar", | ||
}; |
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,6 @@ | ||
import { A, Foo } from "./a"; | ||
|
||
export const B: typeof A = 1; | ||
export const BF: Foo = { | ||
name: "baz", | ||
}; |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you tested that
--config-file foo --config-json '{"some": "object"}'
has the desired behavior of overriding the file?What happens if the user also gives a
--config-json
in the args they provide?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would be good to comment if there's an ordering constraint between these two flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are a few things that I think need more testing, both here and our other
--config-json
cases (see plugins).Note that we could also go the route where if
experimental_emit_isolated_dts = True
then we assume you set thisemitIsolatedDts
flag yourself, then maybe add some "validation" in the future like tsc does.IMO if
--config-json
merges+overwrites the existing config then I prefer this instead of requiring validation, but both have trade-offs.