Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
},
"devDependencies": {
"package-preamble": "0.1",
"rollup": "0.49",
"rollup": "1.23.0",
"rollup-plugin-ascii": "0.0",
"rollup-plugin-node-resolve": "3",
"rollup-plugin-node-resolve": "5.2.0",
"tape": "4",
"uglify-js": "3"
},
"dependencies": {
"topojson-client": "3.0.0",
"topojson-server": "3.0.0",
"topojson-simplify": "3.0.2"
"topojson-client": "3.0.1",
"topojson-server": "3.0.1",
"topojson-simplify": "3.0.3"
}
}
48 changes: 29 additions & 19 deletions rollup.node.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
var fs = require("fs"),
rollup = require("rollup"),
dependencies = require("./package.json").dependencies;
const rollup = require("rollup");
const dependencies = require("./package.json").dependencies;

rollup.rollup({
// see below for details on the options
const inputOptions = {
input: "index.js",
external: Object.keys(dependencies)
}).then(function(bundle) {
return bundle.generate({
format: "cjs"
});
}).then(function(bundle) {
var code = bundle.code;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the newer version of rollup, bundle is an object with member output of type Array. Looking at the new docs for rollup, I decided to go from their example:

https://rollupjs.org/guide/en/#rolluprollup

return new Promise(function(resolve, reject) {
fs.writeFile("dist/topojson.node.js", code, "utf8", function(error) {
if (error) return reject(error);
else resolve();
});
});
}).catch(abort);
};
const outputOptions = {
file: "dist/topojson.node.js",
format: "cjs"
};

function abort(error) {
console.error(error.stack);
async function build() {
// create a bundle
const bundle = await rollup.rollup(inputOptions);

console.log(bundle.watchFiles); // an array of file names this bundle depends on

// generate code
const { output } = await bundle.generate(outputOptions);

for (const chunkOrAsset of output) {
if (chunkOrAsset.type === "chunk") {
console.log(chunkOrAsset.fileName);
console.log(chunkOrAsset.exports);
}
}

// or write the bundle to disk
await bundle.write(outputOptions);
}

build();
Loading