fix: set input with module resolve
This commit is contained in:
@@ -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
@@ -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 })
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user