It seems babel is doing some automatic escaping of special characters when using t.stringLiteral which causes problems for me. Is there any way to disable this behaviour or a workaround perhaps?
stringBabelPlugin.js
const t = require("@babel/types")
module.exports = ({ types: t }) => {
return {
visitor: {
CallExpression: {
exit(path, state) {
path.replaceWith(t.stringLiteral('ö'))
},
},
}
}
}
stringBabelPlugin.spec.js
import { pluginTester } from 'babel-plugin-tester';
import stringPlugin from './stringPlugin';
pluginTester({
plugin: stringPlugin,
tests: [
{
code: `fn("ö")`,
output: `"ö"`,
},
],
});
npm test
- Expected ""ö""
+ Received ""\xF6";"