chore: default exports
This commit is contained in:
+10
-12
@@ -3,21 +3,19 @@ import webpack from 'webpack'
|
||||
import { fromCallback } from 'bluebird'
|
||||
import { resolve, join, relative } from 'path'
|
||||
|
||||
const
|
||||
isObject = (x) => typeof x === 'object',
|
||||
isString = (x) => typeof x === 'string'
|
||||
const isObject = (x) => typeof x === 'object'
|
||||
const isString = (x) => typeof x === 'string'
|
||||
|
||||
export async function bundle (compiler, next) {
|
||||
export default async function bundle (compiler, next) {
|
||||
let bundleConfig = compiler.options.bundle
|
||||
if (!bundleConfig) {
|
||||
return next()
|
||||
}
|
||||
|
||||
const
|
||||
input = compiler.options.input || require.resolve(process.cwd()),
|
||||
fs = new Mfs(),
|
||||
path = resolve('nexe'),
|
||||
filename = 'virtual-bundle.js'
|
||||
const input = compiler.options.input || require.resolve(process.cwd())
|
||||
const mfs = new Mfs()
|
||||
const path = resolve('nexe')
|
||||
const filename = 'virtual-bundle.js'
|
||||
|
||||
if (isString(bundleConfig)) {
|
||||
bundleConfig === require(relative(process.cwd(), bundleConfig))
|
||||
@@ -30,15 +28,15 @@ export async function bundle (compiler, next) {
|
||||
}
|
||||
|
||||
const bundler = webpack(bundleConfig)
|
||||
bundler.outputFileSystem = fs
|
||||
bundler.outputFileSystem = mfs
|
||||
const stats = await fromCallback(cb => bundler.run(cb))
|
||||
|
||||
if (stats.hasErrors()) {
|
||||
compiler.log.error(stats.toString())
|
||||
return null
|
||||
}
|
||||
//eslint-disable-next-line no-sync
|
||||
compiler.input = fs.readFileSync(
|
||||
|
||||
compiler.input = mfs.readFileSync(
|
||||
join(bundleConfig.output.path, bundleConfig.output.filename)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user