How to fix code in NAPI? #478
-
Trying to use NAPI for replacing some text but didn't find any function for it. How can I replace nodes using NAPI? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, NAPI fix is not shipped now because most JS code needs sourcemap support, which is not supported at the moment. To replace code, using See https://github.com/vue-vine/vue-vine/blob/0d302140f2a0a606cca62a130082952ec183628a/packages/compiler/src/transform.ts#L32-L37 as an example. |
Beta Was this translation helpful? Give feedback.
-
I think it would be incredibly useful to be able to apply a I don't think source maps are always a requirement. In my use case, I am attempting to pre-process/transform code before the compilation step so, source maps generation is left to the compiler. Thanks for this great tool. Love it. |
Beta Was this translation helpful? Give feedback.
Hi, NAPI fix is not shipped now because most JS code needs sourcemap support, which is not supported at the moment.
To replace code, using
magic-string
is recommended for JS source code manipulation. You may need to write replacement string manually, though.See https://github.com/vue-vine/vue-vine/blob/0d302140f2a0a606cca62a130082952ec183628a/packages/compiler/src/transform.ts#L32-L37 as an example.