How to bundle as single file in Rollup.js

Viewed 1649

In the REPL on the Rollup site, the output shows that the imports are injected straight into the output file. On my computer, I'm unable to reproduce this (desired) behavior. Instead, my output file has require('./my-other-file') statements in it.

My entry file looks like this:

// entry.js

import { encode64 } from './utils';

export function myFunction() {
    return encode64('test');
}

My output file looks like this:

// bundle.js

(function () {
    'use strict';

    exports.__esModule = true;
    var utils_1 = require("./utils"); // <- don't want this
    function myFunction() {
        return utils_1.encode64('test');
    }
    exports.myFunction = myFunction;

}());

With a Rollup config file that looks like this:

export default {
    entry: 'entry.js',
    dest: 'bundle.js',
    format: 'iife',
};

How do I get my encode64 import injected into the output file, rather than required?

I need this in the browser and I don't want to use Browserify or other similar tools.

0 Answers
Related