Rollupjs用打字稿装饰模块摇晃树

时间:2016-10-04 17:17:48

标签: bundle rollup rollupjs

当我在我的脚本中使用带有模块的typescript装饰器时,rollupjs捆绑整个模块而不是导入的模块。

main.js

import { outter } from './index.js';
let a = new outter();

index.js

export * from './display';
export * from './form';

display.js

export var outter = (function (_super) {
  console.log();
})();

form.js

var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};

export var err;
(function (err) {
   err[err["name"] = 0] = "name";
   err[err["error"] = 1] = "error";
})(err || (err = {}));

export var formV = (function (_super) {
  __extends(formV, _super);
  function formV(element, options) {
    _super.call(this, options, element);       
  }
  __decorate([
     Property(err.name)
  ], formV.prototype, "err", void 0);
  return formV;
}());

formV模块不会在main.js文件中导入,但它也与输出文件捆绑在一起。

rollup.config.js

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

    export default {
        entry: 'main.js',    
        plugins: [
            nodeResolve({ jsnext: true })
        ],
        targets: [
            { dest: 'dist/rollup.js', format: 'cjs' },
            { dest: 'dist/rollup.es.js', format: 'es' },
            { dest: 'dist/rollup.amd.js', format: 'amd' }
        ],
        treeshake: true
    };

0 个答案:

没有答案