question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

https://swc-project.github.io/docs/usage-plugin

Proposal: create an swc-plugin-macros that is similar to babel-plugin-macros

SWC is increasing in popularity. It is aiming to be a drop-in replacement for babel with some significant speed improvements. It already has a webpack loader.

There is some early interest in how it might integrate with create-react-app (https://github.com/facebook/create-react-app/issues/8060). Looking at which babel plugins create-react-app uses it seems like most of those things are supported by swc (with only a few exceptions).

SWC appears to be missing support for:

  1. babel-plugin-macros (important for some of my projects)
  2. babel-plugin-transform-react-remove-prop-types (less important in TypeScript projects)
  3. babel-plugin-transform-flow-strip-types (generally SWC has no Flow support 🤷🏻‍♂️)

Generally everything else babel does for me is handled by swc preset-env (or isn’t particularly vital to my projects).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:35
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
arlyoncommented, Aug 19, 2022

I realise this isn’t directly related, however I am working on stailwc, a swc-native version of twin.macro which serves as both

  • an example of swc’s macro capabilities
  • a neat project (my build times are down ~80% compared to bazel!)
  • a living example on how to build a wasm-based swc plugin for nextjs
0reactions
conartist6commented, Feb 11, 2022

@matthewmatician I mean you could always do a two-step process. Parse with babel, transpile macros, send the program to SWC, then have SWC do the rest of the transpilation.

The only question is: how you would send the program to SWC? Obviously you could print it from babel and parse in SWC. But perhaps there’s a more efficient way? I can’t say I understand the PR you linked well enough to know quite what its API would be. If it can do a copy in a way that’s faster than a parse and print, then perhaps the perf numbers would still be favorable at the end of the day.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing a plugin - SWC
As plugin is written in the rust programming language and built as a .wasm file, you need to install rust toolchain and wasm...
Read more >
how to use plugin like 'babel-plugin-import' #3042 - GitHub
The only possible solution is to chain a babel before swc, and I'm still wondering why such a legacy plugin has such a...
Read more >
swc-plugin | Format.JS
swc -plugin ... Process string messages for translation from modules that use react-intl, specifically: Parse and verify that messages are ICU-compliant w/o any ......
Read more >
swc-plugin-transform-import - npm
swc plugin for transforming import path to optimize bundle size. Latest version: 1.2.0, last published: 9 months ago.
Read more >
gatsby-plugin-swc
It uses @parcel/css for CSS minification. How to install and use. yarn add -D gatsby-plugin-swc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found