[英]Import specific javascript files as string in react-native with metro bundler
window
, so currently it throws an error on import when the code gets interpretedwindow
之类的对象,因此当前在解释代码时会在导入时引发错误Thank you for your help!谢谢您的帮助!
In my case I needed to write a custom transformer.就我而言,我需要编写一个自定义转换器。
const babelTransformer = require('metro-react-native-babel-transformer');
module.exports.transform = ({ src, filename, options }) => {
return babelTransformer.transform({
src: `let code = ${JSON.stringify(src)}; export default code;`,
filename,
options,
});
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.