I'm working on a webpack loader for dust.js. It works pretty well as long as I require the entire dustjs npm module via require('dustjs-linkedin)
. However, I want to require just the core (dist/dust-core
) because the loader itself compiles the templates.
The issue appears to be that webpack is seeing the following:
if (typeof define === "function" && define.amd && define.amd.dust === true) {
define(["require", "dust.core"], function(require, dust) {
dust.onLoad = function(name, cb) {
require([name], function() {
cb();
});
};
return dust;
});
}
and automatically turning on code-splitting. Specifically, the require([name], ...)
call is causing webpack to attempt to package all of the files inside the dist
folder. I can use a plugin to turn code-splitting off entirely, but then that makes my loader much less useful.
Is anybody using webpack to require dust.js and running into a similar issue? Has anybody solved that issue? I'm thinking of trying to contribute a fix that generates a webpack-friendly version of dust-core.js
.
You should be able to directly use lib/dust
in your build.
When Dust is built into dist
, AMD loader support for dust.onLoad
is added as part of the build process, but you won't need that piece of code, and it's the code that's giving you trouble above.