Skip to content

Commit

Permalink
Remove .test.js from dist
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Sep 25, 2023
1 parent adcf6e6 commit 2ef44c4
Show file tree
Hide file tree
Showing 3 changed files with 8,345 additions and 8,295 deletions.
59 changes: 45 additions & 14 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2451,26 +2451,43 @@ export async function server_esm(task, opts) {

export async function nextbuild(task, opts) {
await task
.source('src/build/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**', '**/jest/**'],
.source('src/build/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/jest/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev })
.target('dist/build')
}

export async function nextbuild_esm(task, opts) {
await task
.source('src/build/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**', '**/jest/**'],
.source('src/build/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/jest/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev, esm: true })
.target('dist/esm/build')
}

export async function nextbuildjest(task, opts) {
await task
.source('src/build/jest/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**'],
.source('src/build/jest/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/build/jest')
Expand Down Expand Up @@ -2641,26 +2658,37 @@ export default async function (task) {

export async function shared(task, opts) {
await task
.source(
'src/shared/**/!(amp|config|constants|dynamic|app-dynamic|head|runtime-config).+(js|ts|tsx)'
)
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/(amp|config|constants|dynamic|app-dynamic|head|runtime-config).+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev })
.target('dist/shared')
}

export async function shared_esm(task, opts) {
await task
.source(
'src/shared/**/!(amp|config|constants|dynamic|app-dynamic|head).+(js|ts|tsx)'
)
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/(amp|config|constants|dynamic|app-dynamic|head|runtime-config).+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/shared')
}

export async function shared_re_exported(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)'
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/shared')
Expand All @@ -2669,7 +2697,10 @@ export async function shared_re_exported(task, opts) {
export async function shared_re_exported_esm(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)'
'src/shared/**/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', {
dev: opts.dev,
Expand Down
11 changes: 10 additions & 1 deletion test/build-turbopack-tests-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ async function updatePassingTests() {
}
}

fs.writeFileSync(PASSING_JSON_PATH, JSON.stringify(passing, null, 2))
// JS keys are ordered, this ensures the tests are written in a consistent order
// https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key
const ordered = Object.keys(passing)
.sort()
.reduce((obj, key) => {
obj[key] = passing[key]
return obj
}, {})

fs.writeFileSync(PASSING_JSON_PATH, JSON.stringify(ordered, null, 2))
}

function stripWorkingPath(path) {
Expand Down

0 comments on commit 2ef44c4

Please sign in to comment.