Skip to content

Commit

Permalink
feat(vite-node): Add --inline-deps flag
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerey committed Apr 30, 2022
1 parent ac9645c commit 73770d7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/vite-node/src/cli.ts
Expand Up @@ -11,9 +11,10 @@ const argv = minimist(process.argv.slice(2), {
h: 'help',
w: 'watch',
s: 'silent',
i: 'inline-deps',
},
'--': true,
'string': ['root', 'config'],
'string': ['root', 'config', 'inline-deps'],
'boolean': ['help', 'watch', 'silent'],
unknown(name: string) {
if (name[0] === '-') {
Expand Down Expand Up @@ -48,11 +49,12 @@ Usage:
$ vite-node [options] [files]
Options:
-r, --root <path> ${dim('[string]')} use specified root directory
-c, --config <file> ${dim('[string]')} use specified config file
-w, --watch ${dim('[boolean]')} restart on file changes, similar to "nodemon"
-s, --silent ${dim('[boolean]')} do not emit errors and logs
--vue ${dim('[boolean]')} support for importing Vue component
-r, --root <path> ${dim('[string]')} use specified root directory
-c, --config <file> ${dim('[string]')} use specified config file
-w, --watch ${dim('[boolean]')} restart on file changes, similar to "nodemon"
-s, --silent ${dim('[boolean]')} do not emit errors and logs
--vue ${dim('[boolean]')} support for importing Vue component
-i, --inline-deps <deps> ${dim('[string]')} inline specified dependencies
`)
}

Expand All @@ -62,18 +64,24 @@ export interface CliOptions {
root?: string
config?: string
watch?: boolean
'inline-deps'?: string | string[]
}

async function run(options: CliOptions = {}) {
const files = options.files || options._ || []
const inlineDeps = options['inline-deps'] || []
const server = await createServer({
logLevel: 'error',
configFile: options.config,
root: options.root,
})
await server.pluginContainer.buildStart({})

const node = new ViteNodeServer(server)
const node = new ViteNodeServer(server, {
deps: {
inline: Array.isArray(inlineDeps) ? inlineDeps : [inlineDeps],
},
})

const runner = new ViteNodeRunner({
root: server.config.root,
Expand Down

0 comments on commit 73770d7

Please sign in to comment.