如何使用和不使用 babel 转译代码要求文件 2 次
How require file 2 times with and without transpilled code by babel
我需要请求文件 2 次。
在第一种情况下,我需要结果作为 源代码,像这样:
const code = require('./example')
// result: const a = () => { return 'a' }
在第二种情况下 用 babel 转译的代码:
const code = require('./example')
// result: const a = function() { return 'a' }
我如何才能将其集成到单个构建中?
我尝试使用 raw-loader,但文件仍然使用 babel 转译。
我需要使用“!”在原始装载机之前。它阻止所有加载器。
const code = require('!raw-loader!./example')
我需要请求文件 2 次。
在第一种情况下,我需要结果作为 源代码,像这样:
const code = require('./example')
// result: const a = () => { return 'a' }
在第二种情况下 用 babel 转译的代码:
const code = require('./example')
// result: const a = function() { return 'a' }
我如何才能将其集成到单个构建中?
我尝试使用 raw-loader,但文件仍然使用 babel 转译。
我需要使用“!”在原始装载机之前。它阻止所有加载器。
const code = require('!raw-loader!./example')