use rollup API to get the bundle as an importable string
MODIFY
package.json
package.json
"main": "index.js",
"scripts": {
"test": "tape -r esm test/**/*.js",
- "build-intermediate": "rollup src/bundled/index.js --format cjs --file src/bundle.js"
+ "build-intermediate": "node scripts/build-intermediate.js"
},
"devDependencies": {
"esm": "^3.0.37",

ADD
scripts/build-intermediate.js
+const rollup = require('rollup');
+const fs = require('fs');
+
+async function build() {
+ const bundle = await rollup.rollup({input: 'src/bundled/index'});
+ const { code } = await bundle.generate({format: 'iife',
+ //file: 'src/bundle.js',
+ name: 'makeBundle'});
+ console.log(`bundle.length is ${code.length}`);
+ //console.log(code);
+ // now turn that code into a string definition
+ const built = `
+ const bundle = ${JSON.stringify(code)};
+ export bundle;
+`;
+ fs.writeFileSync('src/bundle.js', built);
+ console.log(`wrote ${built.length} to src/bundle.js`);
+}
+
+build();
+
+

use rollup API to get the bundle as an importable string