缺少某些内容以便使用汇总导入fs模块

时间:2018-06-17 00:10:32

标签: rollup

我在我的Node应用程序中使用ES6 import语句和汇总并遇到困难。例如,在尝试加载fs时:

import * as fs from 'fs';

并尝试使用:

fs.writeFile(...);

我收到错误:

Uncaught (in promise) TypeError: Cannot read property 'writeFile' of undefined

我的汇总配置:

import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';

export default {
  input: 'js/index.js',
  output: {
    file: 'build/bundle.js',
    format: 'iife',
    sourcemap: 'inline'
  },
  plugins: [
    resolve(),
    commonjs()
  ],
  external: [
    'fs'
  ]
};

0 个答案:

没有答案