-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ESBuild config generation into new getEsbuildConfig helper
- Loading branch information
1 parent
daa5847
commit 320216a
Showing
3 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getEsbuildConfig } from '../src/utils'; | ||
|
||
describe('getEsbuildConfig', () => { | ||
test('with sourcemaps returns correct config', () => { | ||
const config = getEsbuildConfig({ sourcemap: true }, 'filename.js') | ||
|
||
expect(config).toEqual({ | ||
format: 'cjs', | ||
loader: 'js', | ||
target: 'es2018', | ||
sourcefile: 'filename.js', | ||
sourcemap: true, | ||
sourcesContent: false, | ||
}) | ||
}) | ||
|
||
describe('with loaders', () => { | ||
test('.js loader returns correct config', () => { | ||
const config = getEsbuildConfig( | ||
{ loaders: { '.js': 'jsx' } }, | ||
'filename.js' | ||
) | ||
|
||
expect(config).toEqual({ | ||
format: 'cjs', | ||
loader: 'jsx', | ||
target: 'es2018', | ||
}); | ||
}); | ||
|
||
xtest('.js loader returns correct config with compound extension', () => { | ||
const config = getEsbuildConfig( | ||
{ loaders: { '.js': 'jsx' } }, | ||
'filename.test.js' | ||
) | ||
|
||
expect(config).toEqual({ | ||
format: 'cjs', | ||
loader: 'jsx', | ||
target: 'es2018', | ||
}); | ||
}); | ||
}) | ||
}) |