Skip to content

Commit

Permalink
fix(rollup): handle warning for deprecated api
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jun 15, 2020
1 parent fc69352 commit e93f812
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/cli.ts
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import 'v8-compile-cache'
import cac from 'cac'
import { cac } from 'cac'
import { version } from '../package.json'

if (process.env.BILI_LOCAL_PROFILE) {
Expand All @@ -14,7 +14,7 @@ const cli = cac('bili')

cli
.command('[...input]', 'Bundle input files', {
ignoreOptionDefaultValue: true
ignoreOptionDefaultValue: true,
})
.option('-w, --watch', 'Watch files')
.option(
Expand All @@ -36,7 +36,7 @@ cli
.option('--bundle-node-modules', 'Include node modules in your bundle')
.option('--minify', 'Minify output files')
.option('--external <id>', 'Mark a module id as external', {
type: []
type: [],
})
.option('-t, --target <target>', 'Output target', { default: 'node' })
.option('-c, --config <file>', 'Use a custom config file')
Expand All @@ -53,9 +53,9 @@ cli
.option('--verbose', 'Show verbose logs')
.option('--quiet', 'Show minimal logs')
.option('--stack-trace', 'Show stack trace for bundle errors')
.example(bin => ` ${bin} --format cjs --format esm`)
.example(bin => ` ${bin} src/index.js,src/cli.ts`)
.example(bin => ` ${bin} --input.index src/foo.ts`)
.example((bin) => ` ${bin} --format cjs --format esm`)
.example((bin) => ` ${bin} src/index.js,src/cli.ts`)
.example((bin) => ` ${bin} --input.index src/foo.ts`)
.action(async (input, options) => {
const { Bundler } = await import('./')
const rootDir = options.rootDir || '.'
Expand All @@ -71,7 +71,7 @@ cli
extractCSS: options.extractCss,
sourceMap: options.map,
sourceMapExcludeSources: options.mapExcludeSources,
target: options.target
target: options.target,
},
bundleNodeModules: options.bundleNodeModules,
env: options.env,
Expand All @@ -82,8 +82,8 @@ cli
babel: {
asyncToPromises: options.asyncToPromises,
minimal: options.minimal,
babelrc: options.babelrc
}
babelrc: options.babelrc,
},
},
{
logLevel: options.verbose
Expand All @@ -93,14 +93,14 @@ cli
: undefined,
stackTrace: options.stackTrace,
configFile: options.config,
rootDir
rootDir,
}
)
await bundler
.run({
write: true,
watch: options.watch,
concurrent: options.concurrent
concurrent: options.concurrent,
})
.catch((err: any) => {
bundler.handleError(err)
Expand All @@ -113,7 +113,7 @@ cli.help()

cli.parse()

process.on('unhandledRejection', err => {
process.on('unhandledRejection', (err) => {
console.error(err)
process.exit(1)
})
4 changes: 3 additions & 1 deletion src/index.ts
Expand Up @@ -425,7 +425,9 @@ export class Bundler {
assets.set(relative, {
absolute,
get source() {
return file.isAsset ? file.source.toString() : file.code
return file.type === 'asset'
? file.source.toString()
: file.code
},
})
}
Expand Down

0 comments on commit e93f812

Please sign in to comment.