1

我正在尝试通过 Rollup 插件在我的应用程序中使用 Tree Shaking。

当我运行时,node_modules/.bin/rollup -c rollup-config.js我收到此错误:

[!] Error: 'Subject' is not exported by node_modules/rxjs/Subject.js

这是我的rollup-config.js文件:

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

export default {
    input: 'src/main.js',
    output: {
        file: 'src/build.js', // output a single application bundle
        format: 'iife',
    },
    sourceMap: false,
    onwarn: function (warning) {
        // Skip certain warnings

        // should intercept ... but doesn't in some rollup versions
        if (warning.code === 'THIS_IS_UNDEFINED') { return; }

        // console.warn everything else
        console.warn(warning.message);
    },
    plugins: [
        nodeResolve({ jsnext: true, module: true }),
        commonjs({
            include: 'node_modules/**',
            include: 'node_modules/rxjs/**',
            include: 'node_modules/ng2-cache-service/**',
            include: 'node_modules/ng2-dragula/**'
        }),
        uglify()
    ]
};

我曾经对ng2-cache-serviceandng2-dragula模块有类似的错误,但我通过将它们导入 commonjs 来解决它们

我不能这样做rxjs/Subject

4

0 回答 0