Allow default exports fixes #452

This commit is contained in:
Zack Rauen 2020-09-23 13:08:36 -04:00
parent 538324ed52
commit 7a22887da1
1 changed files with 6 additions and 12 deletions

View File

@ -134,21 +134,15 @@ export default new class ContentManager {
meta.css = content;
if (meta.format == "json") meta.css = meta.css.split("\n").slice(1).join("\n");
content = `module.exports = ${JSON.stringify(meta)};`;
module._compile(content, filename);
}
if (isPlugin) {
module._compile(content, module.filename);
const didExport = !Utils.isEmpty(module.exports);
if (didExport) {
meta.type = module.exports;
module.exports = meta;
content = "";
}
else {
Utils.warn("Module Not Exported", `${meta.name}, please start setting module.exports`);
content += `\nmodule.exports = ${JSON.stringify(meta)};\nmodule.exports.type = ${meta.exports || meta.name};`;
}
content += `\nif (module.exports.default) {module.exports = module.exports.default;}\nif (!module.exports.prototype || !module.exports.prototype.start) {module.exports = ${meta.exports || meta.name};}`;
module._compile(content, filename);
meta.type = module.exports;
module.exports = meta;
}
module._compile(content, filename);
};
}