@herberttn/bytenode-webpack-plugin
Version:
Compile JavaScript into bytecode using bytenode
29 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLoaderCode = void 0;
const utils_1 = require("./utils");
function checkLoaderOptions(options) {
if (!options || typeof options !== 'object') {
throw new Error('loader options should be an object');
}
if (!Array.isArray(options.imports)) {
throw new Error('loader options.imports should be an array');
}
if (options.imports.length <= 0) {
throw new Error('loader options.imports cannot be empty');
}
if (options.imports.some(file => typeof file !== 'string')) {
throw new Error('loader options.imports can only have strings');
}
}
function createLoaderCode(options) {
checkLoaderOptions(options);
let { imports } = options;
imports = imports.map(path => (0, utils_1.normalizeCodePath)(path));
imports.unshift('bytenode');
return imports
.map(path => `require('${path}');`)
.join('\n');
}
exports.createLoaderCode = createLoaderCode;
//# sourceMappingURL=loaders.js.map