fix: set input with module resolve

This commit is contained in:
calebboyd
2018-03-24 19:13:08 -05:00
committed by Caleb Boyd
parent 54212cbc52
commit 5ac93b43ec
3 changed files with 16 additions and 2 deletions
-1
View File
@@ -39,7 +39,6 @@ async function compile(
if (error) {
if (compiler.options.loglevel !== 'silent' && error) {
console.log(error)
process.stderr.write(EOL + error.message + EOL)
}
compiler.quit()
+8 -1
View File
@@ -186,8 +186,15 @@ export function resolveEntry(input: string, cwd: string, maybeEntry?: string) {
return ''
}
let result = null
if (input && isAbsolute(input)) {
return input
}
if (input) {
result = resolveFileName(cwd, input, { silent: true })
let prefix = ''
if (!input.startsWith('.')) {
prefix = './'
}
result = resolveFileName(cwd, prefix + input, { silent: true })
}
if (isEntryFile(maybeEntry)) {
result = resolveFileName(cwd, maybeEntry, { silent: true })
+8
View File
@@ -14,6 +14,14 @@ describe('options', () => {
const options = normalizeOptions()
expect(options.input).to.equal(path.resolve('./index.js'))
})
it('should resolve relative paths for input', () => {
const options = normalizeOptions({ input: 'test/fixture/entry.js' })
expect(options.input).to.equal(path.resolve('./test/fixture/entry.js'))
})
it('should accept a module entry as input', () => {
const options = normalizeOptions({ input: 'test/fixture' })
expect(options.input).to.equal(path.resolve('./test/fixture/entry.js'))
})
it('should resolve pathed options against cwd', () => {
const cwd = path.join(process.cwd(), 'test/fixture')
const options = normalizeOptions({