-
Notifications
You must be signed in to change notification settings - Fork 6
Description
I would like to be able to export functions, even if they are unused by the bundle as a whole. Reproduction: With the following configuration:
"use strict";
let templateDir = "./src/main/resources/views";
module.exports = {
watchDirs: [templateDir],
js: [{
source: templateDir + "/index.js",
target: "./target/classes/dist/views.js",
jsx: { pragma: "createElement" },
esnext: true,
format: "esm",
}]
};
The following is the relevant part of by js bundle:
import views from "./manifest";
import Renderer from "complate-stream";
let renderer = new Renderer("<!DOCTYPE html>");
views.forEach(view => {
renderer.registerView(view);
});
let render = function render(stream, tag, params) {
renderer.renderView(tag, params, stream, true, null);
stream.flush();
}
Downstream requires that the last thing in the dist/views.js is exactly that render function above. But render is unused by the bundle and is excluded by faucet when creating the dist/views.js. In the transpiled file, the function render is not present.
I could get around this problem by referring to the function in a hacky way like console.log(render) on the line before defining the function. But it would be better to be able to configure the option weather to exclude unused functions.
If you point me to a possible solution, I can also try to implement it.