mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Allow page extensions in any order (#3827)
This commit is contained in:
parent
69b236b976
commit
07af67bfea
|
@ -36,7 +36,7 @@ export function createEntry (filePath, {name, pageExtensions} = {}) {
|
|||
|
||||
// Makes sure supported extensions are stripped off. The outputted file should always be `.js`
|
||||
if (pageExtensions) {
|
||||
entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})`), '.js')
|
||||
entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})$`), '.js')
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -28,6 +28,18 @@ describe('createEntry', () => {
|
|||
expect(entry.files[0]).toBe('./pages/index.jsx')
|
||||
})
|
||||
|
||||
it('Should allow custom extension like .tsx to be turned into .js', () => {
|
||||
const entry = createEntry('pages/index.tsx', {pageExtensions: ['tsx', 'ts'].join('|')})
|
||||
expect(entry.name).toBe(normalize('bundles/pages/index.js'))
|
||||
expect(entry.files[0]).toBe('./pages/index.tsx')
|
||||
})
|
||||
|
||||
it('Should allow custom extension like .tsx to be turned into .js with another order', () => {
|
||||
const entry = createEntry('pages/index.tsx', {pageExtensions: ['ts', 'tsx'].join('|')})
|
||||
expect(entry.name).toBe(normalize('bundles/pages/index.js'))
|
||||
expect(entry.files[0]).toBe('./pages/index.tsx')
|
||||
})
|
||||
|
||||
it('Should turn pages/blog/index.js into pages/blog.js', () => {
|
||||
const entry = createEntry('pages/blog/index.js')
|
||||
expect(entry.name).toBe(normalize('bundles/pages/blog.js'))
|
||||
|
|
Loading…
Reference in a new issue