Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function bundle(opts: *) {
const directory = process.cwd();
// Need to add @babel/register to support ES2015+ in config file.
require('../babelRegister');
const configPath = getProjectConfigPath(directory, opts.config);
const projectConfig = getProjectConfig(configPath);
const config = getWebpackConfig(
new Runtime(),
{
platform: opts.platform,
root: directory,
dev: opts.dev,
minify: opts.minify,
bundle: true,
},
projectConfig
);
if (opts.assetsDest) {
config.output.path = path.isAbsolute(opts.assetsDest)
? opts.assetsDest
: path.join(directory, opts.assetsDest);
}
export default async function main() {
const {
HAUL_INSPECTOR,
HAUL_INSPECTOR_PORT,
HAUL_INSPECTOR_HOST,
NODE_INSPECTOR,
} = process.env;
let { haulInspector, nodeInspector } = yargsParser(process.argv);
haulInspector = haulInspector || HAUL_INSPECTOR;
nodeInspector = nodeInspector || NODE_INSPECTOR;
const runtime = new Runtime(
haulInspector || HAUL_INSPECTOR_PORT || HAUL_INSPECTOR_HOST
? new InspectorClient(HAUL_INSPECTOR_HOST, HAUL_INSPECTOR_PORT)
: undefined
);
await runtime.ready(haulInspector === 'wait');
// Experimental
if (nodeInspector) {
const wait = nodeInspector === 'wait';
runtime.nodeInspectorStarted(wait);
const inspector = require('inspector');
inspector.open(undefined, undefined, wait);
}
[
module.exports = async function runWebpackCompiler({
platform,
options,
}: {
[key: string]: any,
}) {
const emitter = new EventEmitter();
const { configPath, configOptions } = JSON.parse(options);
const runtime = new Runtime();
runtime.logger.proxy((level, ...args) => {
setImmediate(() => {
emitter.emit(Events.LOG, {
message: runtime.logger.stringify(args).join(' '),
level,
});
});
});
const outputPath = configOptions.assetsDest;
const projectConfig = getNormalizedProjectConfigBuilder(runtime, configPath)(
runtime,
{
...configOptions,
platform,
}