Comments (5)
The code I passed to d3-bundler to test is:
import {event, select, selectAll} from "d3-selection";
export {event, select, selectAll};
The resulting output was:
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
factory((global.d3 = {}));
}(this, function (exports) { 'use strict';
…
var event = null;
function listenerOf(listener, ancestors, args) {
return function(event1) {
var i = ancestors.length, event0 = event; // Events can be reentrant (e.g., focus).
while (--i >= 0) args[i << 1] = ancestors[i].__data__;
event = event1;
try {
listener.apply(ancestors[0], args);
} finally {
event = event0;
}
};
}
…
exports.event = event;
…
}));
from rollup.
Ah, yes - will need to implement this. IIRC Esperanto replaces all assignments to an exported value foo
that take place a) after the export declaration or b) inside a function body with exports.foo = ...
.
I was wondering what would happen to d3.event
. In d3-jsnext I had to cheat and use a global. Having it only be assigned to within selection-event
will make life much easier, since it's illegal to assign to an imported binding.
from rollup.
FWIW, this is no longer blocking me because I’ve changed (yet again) the d3-bundler strategy to export a default object rather than use named exports. The new build looks like this:
import {
event,
select,
selectAll
} from "d3-selection";
export default {
get event() { return event; },
select: select,
selectAll: selectAll
};
And this works fine with Rollup just setting the local event directly.
from rollup.
I've changed some of the rewriting behaviour so that exported vars (or lets) are always rewritten as export.foo = ...
. Involves a little bit of dancing around, but I think it's the best solution. Hopefully I didn't introduce any bugs in the process.
Just so you're aware, using a default export will mean that Rollup wouldn't be able to (say) import select
but not selectAll
- it will always have to import the entire module. (Though it will look identical as far as UMD consumers are concerned.)
from rollup.
using a default export will mean that Rollup wouldn't be able to (say) import select but not selectAll
Right, but this module definition is the “end of the line” as far as composition goes: its only purpose is to generate UMD (or whatever), not to serve as another ES6 module to be imported elsewhere.
from rollup.
Related Issues (20)
- How to configure the .scss file under the style folder to generate a .css file in dist/style/ after building?
- Does not support BSD, not sure why, but it should be easy to port. HOT 2
- Declaring `sideEffects` causes Rollup to drop code with side effects HOT 2
- How to named export from CommonJS module with rollup?
- Packaging vue components, it seems that typescript code is not recognized
- inlineDynamicImports with top level await import() cause runtime error
- JS Decorator Stage 3 support HOT 1
- `@__NO_SIDE_EFFECTS__` annotation not working with imported function HOT 2
- The compiled file fails with error during namespace mapping HOT 2
- It can't process "three/examples/jsm/controls/MapControls.js"
- Tree-shaking for instanceof checks on never-instantiated classes HOT 1
- Web extensions built using --preserveModules cannot be installed
- @__NO_SIDE_EFFECTS doesn't work for some edge case, especially the returned value uses in someway. HOT 4
- Cannot find module @rollup/rollup-win32-x64-msvc (rollup 4.18.1) HOT 2
- manualchunks on chunks with preserveSignature: 'allow-extension' still exports separate chunks
- build the project to another repo
- [Treeshaking] Dead branches of OR logical expressions leave a mapped empty space in the bundle HOT 4
- Function with assignment to global variable may be incorrectly tree-shaken HOT 3
- i18n support for rollup docs HOT 6
- TreeShake ERROR: Expected ")" but found "}"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rollup.