Skip to content

Commit ce5c541

Browse files
committed
chore: don't use esbuild by default
1 parent 332cfd4 commit ce5c541

File tree

6 files changed

+39
-39
lines changed

6 files changed

+39
-39
lines changed

src/lib/helpers/setupNetlifyFunctionForPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const setupNetlifyFunctionForPage = async ({ filePath, functionsPath, isApiPage,
2323
}
2424

2525
// Write entry point to function directory
26-
const entryPointPath = join(functionDirectory, `${functionName}.ts`)
26+
const entryPointPath = join(functionDirectory, `${functionName}.js`)
2727
await writeFile(entryPointPath, getTemplate({ filePath, isISR }))
2828

2929
// Copy function helper

src/lib/templates/getTemplate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const getTemplate = ({ filePath, isISR }) => {
22
if (isISR) {
33
return `// Auto-generated file. DO NOT MODIFY.
4-
import { getHandlerFunction } from './getHandlerFunction'
5-
import { builder } from '@netlify/functions'
6-
export const handler = builder(getHandlerFunction(require("./nextPage/${filePath}")))
4+
const { getHandlerFunction } = require('./getHandlerFunction')
5+
const { builder } = require('@netlify/functions')
6+
exports.handler = builder(getHandlerFunction(require("./nextPage/${filePath}")))
77
`
88
}
99
return `// Auto-generated file. DO NOT MODIFY.
10-
import { getHandlerFunction } from './getHandlerFunction'
11-
export const handler = getHandlerFunction(require("./nextPage/${filePath}"))
10+
const { getHandlerFunction } = require('./getHandlerFunction')
11+
exports.handler = getHandlerFunction(require("./nextPage/${filePath}"))
1212
`
1313
}
1414

src/tests/configurableDirs.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ describe('next-on-netlify', () => {
4545
})
4646

4747
test('creates a Netlify Function for each SSR page', () => {
48-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
49-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
50-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
51-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
48+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
49+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
50+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
51+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
5252
true,
5353
)
54-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'))).toBe(true)
54+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'))).toBe(true)
5555
})
5656

5757
test('copies static pages to output directory', () => {

src/tests/defaults.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ describe('SSR Pages', () => {
6161
const functionsDir = join(PROJECT_PATH, 'out_functions')
6262

6363
test('creates a Netlify Function for each SSR page', () => {
64-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
65-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
66-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
67-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
64+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
65+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
66+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
67+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
6868
true,
6969
)
7070
expect(
71-
readFileSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'), 'utf-8'),
71+
readFileSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'), 'utf-8'),
7272
).toMatch(`require("./nextPage/pages/getServerSideProps/[id].js")`)
7373
})
7474
})
@@ -77,10 +77,10 @@ describe('API Pages', () => {
7777
const functionsDir = join(PROJECT_PATH, 'out_functions')
7878

7979
test('creates a Netlify Function for each API endpoint', () => {
80-
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.ts'))).toBe(true)
81-
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.ts'))).toBe(true)
82-
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.ts'))).toBe(true)
83-
expect(existsSync(join(functionsDir, 'next_api_hello-background', 'next_api_hello-background.ts'))).toBe(true)
80+
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.js'))).toBe(true)
81+
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.js'))).toBe(true)
82+
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.js'))).toBe(true)
83+
expect(existsSync(join(functionsDir, 'next_api_hello-background', 'next_api_hello-background.js'))).toBe(true)
8484
})
8585
})
8686

@@ -126,10 +126,10 @@ describe('SSG Pages with getStaticProps', () => {
126126
})
127127

128128
test('creates Netlify Functions for pages with fallback', () => {
129-
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.ts'
129+
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.js'
130130
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath1))).toBe(true)
131131

132-
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.ts'
132+
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.js'
133133
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath2))).toBe(true)
134134
})
135135
})
@@ -139,19 +139,19 @@ describe('SSG Pages with getStaticProps and revalidate', () => {
139139

140140
test('creates a Netlify Function for each page', () => {
141141
expect(
142-
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.ts')),
142+
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.js')),
143143
).toBe(true)
144144
expect(
145145
existsSync(
146-
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.ts'),
146+
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.js'),
147147
),
148148
).toBe(true)
149149
expect(
150150
existsSync(
151151
join(
152152
functionsDir,
153153
'next_getStaticProps_withRevalidate_withFallback_id',
154-
'next_getStaticProps_withRevalidate_withFallback_id.ts',
154+
'next_getStaticProps_withRevalidate_withFallback_id.js',
155155
),
156156
),
157157
).toBe(true)

src/tests/i18n.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ describe('SSR Pages', () => {
6161
const functionsDir = join(PROJECT_PATH, 'out_functions')
6262

6363
test('creates a Netlify Function for each SSR page', () => {
64-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
65-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
66-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
67-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
64+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
65+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
66+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
67+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
6868
true,
6969
)
70-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'))).toBe(true)
70+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'))).toBe(true)
7171
})
7272
})
7373

7474
describe('API Pages', () => {
7575
const functionsDir = join(PROJECT_PATH, 'out_functions')
7676

7777
test('creates a Netlify Function for each API endpoint', () => {
78-
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.ts'))).toBe(true)
79-
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.ts'))).toBe(true)
80-
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.ts'))).toBe(true)
78+
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.js'))).toBe(true)
79+
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.js'))).toBe(true)
80+
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.js'))).toBe(true)
8181
})
8282
})
8383

@@ -110,10 +110,10 @@ describe('SSG Pages with getStaticProps', () => {
110110
})
111111

112112
test('creates Netlify Functions for pages with fallback', () => {
113-
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.ts'
113+
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.js'
114114
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath1))).toBe(true)
115115

116-
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.ts'
116+
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.js'
117117
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath2))).toBe(true)
118118
})
119119
})
@@ -123,19 +123,19 @@ describe('SSG Pages with getStaticProps and revalidate', () => {
123123

124124
test('creates a Netlify Function for each page', () => {
125125
expect(
126-
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.ts')),
126+
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.js')),
127127
).toBe(true)
128128
expect(
129129
existsSync(
130-
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.ts'),
130+
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.js'),
131131
),
132132
).toBe(true)
133133
expect(
134134
existsSync(
135135
join(
136136
functionsDir,
137137
'next_getStaticProps_withRevalidate_withFallback_id',
138-
'next_getStaticProps_withRevalidate_withFallback_id.ts',
138+
'next_getStaticProps_withRevalidate_withFallback_id.js',
139139
),
140140
),
141141
).toBe(true)

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ describe('onBuild()', () => {
336336
utils,
337337
})
338338

339-
expect(await pathExists(`${resolvedFunctions}/next_api_test/next_api_test.ts`)).toBeTruthy()
339+
expect(await pathExists(`${resolvedFunctions}/next_api_test/next_api_test.js`)).toBeTruthy()
340340
})
341341
})
342342

0 commit comments

Comments
 (0)