sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.73k stars 147 forks source link

`replace` does not support source maps #570

Open benignant opened 1 year ago

benignant commented 1 year ago

Is your feature request related to a problem? Please describe. The replace preprocessor does not support source maps. I'm using it to replace multiple lines.

Describe the solution you'd like Can the replace transformer use the magic-string replace method?

Rishab49 commented 11 months ago

@dummdidumm @benignant does it means processors/replace.ts should have a method which takes file content, options and returns the new formatted content using magicstring.replace method?

benignant commented 11 months ago

I think the change would go in transformers/replace.ts.

Rishab49 commented 11 months ago

@benignant But transformer/replace.ts is doing the same thing as magicstring.replace, then why do you want to change it?

benignant commented 10 months ago

The magic-string replace method maintains the source map.

Rishab49 commented 10 months ago

@benignant Sorry but I can understand your exact requirement.Do you want to use replace method to generate a source map of a given script file using replace method?