SD
SWC Developers
Join the SWC Developers server to ask questions!
SD
SWC Developers
Join the community to ask questions about SWC Developers and get answers from other members.
1:1 line number mapping
Is there a way to have line numbers in typescript be the same line numbers as javascript? For example, if there's a statement on line 17 in the TS source, SWC would put it on line 17 in the generated JS
I'm using the Rust API...
how to migrate from visit_mut_with to Pass?
I'm upgrading the swc dependency for the qwik optimizer (https://github.com/QwikDev/qwik/blob/2ed63b78bd4a20b0f96b4e6fba9ae396916f2321/packages/qwik/src/optimizer/core/src/parse.rs#L266) and it looks like I need to convert
```rust
program.visit_mut_with(&mut typescript::strip(
Default::default(),
top_level_mark,...
preset-env support
So, in short, I've bumped into the following info (was even updated somewhat recently).
What I wanna know: is that a fact? Can someone point me to
/*#__PURE__*/
annotation handles/config/settings/API? (specifically, I'm in need of what @babel/plugin-transform-react-pure-annotations does, since their absence/incorrectness is kind of detrimental to tree-shaking)
Oh and, hello authors of the least rusty swc 😄...Plugin panics when trying to read line number from SourceMapper
I've got a plugin where part of the logic involves reading the current line number:
```rs
pub struct MyVisitor {
// Provided by in from TransformPluginProgramMetadata...
how can I mark a context?
I'm trying to mark a call expression for checking if I visited it later, but this doesn't print that it worked:
```rs
impl VisitMut for CleanMarker {
fn visit_mut_module_item(&mut self, node: &mut ast::ModuleItem) {
if let ast::ModuleItem::Stmt(ast::Stmt::Expr(expr)) = node {...
wasm build uses old swc libraries?
I'm a Rust newbie, maybe I'm doing something wrong.
I have everything building natively with the latest swc.
However, when I try to build for wasm, it's giving errors that indicate it's still using the old API?
```...
How can I rewrite this code for the moved SyntaxContext?
I'm upgrading the Qwik optimizer and this code no longer works because expr.span no longer has the SyntaxContext.
However, the only other property is
expr.expr
which is a Box<Expr>
.
How can I get at the syntax context to add the mark? Or is this the wrong approach and should I be doing one of https://swc.rs/docs/plugin/ecmascript/cheatsheet#deleting-node ? I'm not sure how to apply that though, since it marks by making the name invalid and then removes, but here I need to retain what's marked.
...what happened with swc_ecmascript::visit::visit_expr?
I can't find the PR nor commit that removed it, nor any discussions. It's no longer exported and I don't know what to replace it with. My code is
```rust
impl Visit for IdentCollector {
noop_visit_type!();...
How to debug in Rust
When I'm stepping through the code, the AST is binary data. I end up having to put a lot of dbg! statements.
Is there a better way to see what the current state is?...
How to replace typescript::strip_with_jsx
In 1.3.89 typescript got overhauled and that removed typescript::strip_with_jsx.
What should I do instead now?...