|
| 1 | +# [Support transform plugin in native rust binaries] |
| 2 | + |
| 3 | +* Status: accepted <!-- optional --> |
| 4 | +* Deciders: @kdy1, @kwonoj <!-- optional --> |
| 5 | +* Date: 2021-01-01 <!-- optional --> |
| 6 | + |
| 7 | +Technical Story: [Issue](https://github.com/swc-project/swc/issues/2635) <!-- optional --> |
| 8 | + |
| 9 | +## Context and Problem Statement |
| 10 | + |
| 11 | +SWC wants to support load, run plugins in the native binary for the custom transform behavior. SWC already have priliminary support to load plugins in its node.js JS bindings but it has known limitations. |
| 12 | + |
| 13 | +## Decision Drivers <!-- optional --> |
| 14 | + |
| 15 | +* [driver 1, e.g., a force, facing concern, …] |
| 16 | +* [driver 2, e.g., a force, facing concern, …] |
| 17 | +* … <!-- numbers of drivers can vary --> |
| 18 | + |
| 19 | +## Considered Options |
| 20 | + |
| 21 | +* [option 1] |
| 22 | +* [option 2] |
| 23 | +* [option 3] SWC embeds web assembly runtime (https://wasmer.io/), loads plugin built as web assembly. |
| 24 | +* … <!-- numbers of options can vary --> |
| 25 | + |
| 26 | +## Decision Outcome |
| 27 | + |
| 28 | +Chosen option: **[option 3] SWC embeds web assembly runtime (https://wasmer.io/), loads plugin built as web assembly.** |
| 29 | + |
| 30 | +This decision is taken because |
| 31 | +- It was relatively easy plugin author to generate single binary works across most of platforms SWC's host binary supports, without concern of cross-target compilations. |
| 32 | +- It was relatively easy to achieve abi-stable between SWC host to plugin binaries. |
| 33 | +- It doesn't require to have separate, specialized AST struct (named `plugin_ast`) to pass into ffi boundary of the plugin. |
| 34 | +- Its serialization / deserialization performance is near identical or faster than `abi_stable` based ffi |
| 35 | + |
| 36 | +## Pros and Cons of the Options <!-- optional --> |
| 37 | + |
| 38 | +### [option 1] |
| 39 | + |
| 40 | +[example | description | pointer to more information | …] <!-- optional --> |
| 41 | + |
| 42 | +* Good, because [argument a] |
| 43 | +* Good, because [argument b] |
| 44 | +* Bad, because [argument c] |
| 45 | +* … <!-- numbers of pros and cons can vary --> |
| 46 | + |
| 47 | +### [option 2] |
| 48 | + |
| 49 | +[example | description | pointer to more information | …] <!-- optional --> |
| 50 | + |
| 51 | +* Good, because [argument a] |
| 52 | +* Good, because [argument b] |
| 53 | +* Bad, because [argument c] |
| 54 | +* … <!-- numbers of pros and cons can vary --> |
| 55 | + |
| 56 | +### [option 3] |
| 57 | + |
| 58 | +[example | description | pointer to more information | …] <!-- optional --> |
| 59 | + |
| 60 | +* Good, because [argument a] |
| 61 | +* Good, because [argument b] |
| 62 | +* Bad, because [argument c] |
| 63 | +* … <!-- numbers of pros and cons can vary --> |
| 64 | + |
| 65 | +## Links <!-- optional --> |
| 66 | + |
| 67 | +* [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) --> |
| 68 | +* … <!-- numbers of links can vary --> |
0 commit comments