rollupjs

Prevent rollup from renaming Promise to Promise$1

筅森魡賤 提交于 2019-12-05 14:12:05
Update: Turned out that this is not a problem with Babel, but with Rollup, which is run before. Thanks for your help anyway and sorry for the noise. I use rollup to bundle a number of modules including a Promise polyfill (deliberately overwriting the global Promise). However, rollup recognizes Promise as a global name and transforms export default function Promise(fn) { ... } ... global.Promise = Promise; to function Promise$1(fn) { ... } ... global.Promise = Promise$1; The resulting code works, but I would like the following assertion to hold true: expect(Promise.name).to.equal('Promise'); Is

How to import ES2015 modules functions selectively, but with namespacing?

余生长醉 提交于 2019-11-30 03:17:46
问题 I'm getting started with Rollup and D3 version 4, which is written in ES2015 modules. I've written a some code using the traditional D3 namespace "d3". Now I want to create a custom bundle using Rollup. I want to using tree-shaking, because I'm probably only using about half the functions in d3, and I want to keep things as light as possible. I'm clear that I can import functions selectively, e.g.: import {scaleLinear} from "d3-scale"; import { event, select, selectAll } from "d3-selection";

Using Rollup for Angular 2's AoT compiler and importing Moment.js

谁说胖子不能爱 提交于 2019-11-29 23:57:10
I'm trying to follow the official AoT guide for Angular 2, and I'm using Moment.js in my application. Moment.js is on my packages.json file, and I'm using version 2.15.0. I've been importing it like this so far: import * as moment from 'moment'; But when I get to the part where I have to run rollup, I end up with the following error: Cannot call a namespace ('moment') Which appears to be related to the way I import moment according to this . So, how am I supposed to do this? I can't seem to import moment any other way. If I use import moment from 'moment' I get the compile error External

Using Rollup for Angular 2's AoT compiler and importing Moment.js

南楼画角 提交于 2019-11-28 20:59:27
问题 I'm trying to follow the official AoT guide for Angular 2, and I'm using Moment.js in my application. Moment.js is on my packages.json file, and I'm using version 2.15.0. I've been importing it like this so far: import * as moment from 'moment'; But when I get to the part where I have to run rollup, I end up with the following error: Cannot call a namespace ('moment') Which appears to be related to the way I import moment according to this. So, how am I supposed to do this? I can't seem to

importing d3.event into a custom build using rollup

隐身守侯 提交于 2019-11-28 07:41:52
问题 I've got a file d3.custom.build.js like this (simplified): import { range } from 'd3-array'; import { select, selectAll, event } from 'd3-selection'; import { transition } from 'd3-transition'; export default { range, select, selectAll, event, transition }; And a rollup.config.js like this: import nodeResolve from 'rollup-plugin-node-resolve'; export default { entry: './js/vendor/d3-custom-build.js', dest: './js/vendor/d3-custom-built.js', format: 'iife', globals: { d3: 'd3' }, moduleId: 'd3'