diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index ab70aeab5516d..1a3a7286b8acd 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1778,6 +1778,7 @@ export async function compile(task, opts) { 'telemetry', 'trace', 'shared', + 'shared_re_exported', 'server_wasm', // we compile this each time so that fresh runtime data is pulled // before each publish @@ -1916,18 +1917,39 @@ export default async function (task) { await task.watch('cli/**/*.+(js|ts|tsx)', 'cli', opts) await task.watch('telemetry/**/*.+(js|ts|tsx)', 'telemetry', opts) await task.watch('trace/**/*.+(js|ts|tsx)', 'trace', opts) - await task.watch('shared/**/*.+(js|ts|tsx)', 'shared', opts) + await task.watch( + 'shared/lib/{amp,config,constants,dynamic,head}.+(js|ts|tsx)', + 'shared_re_exported', + opts + ) + await task.watch( + 'shared/**/!(amp|config|constants|dynamic|head).+(js|ts|tsx)', + 'shared', + opts + ) await task.watch('server/**/*.+(wasm)', 'server_wasm', opts) } export async function shared(task, opts) { await task - .source(opts.src || 'shared/**/*.+(js|ts|tsx)') - .swc('server', { dev: opts.dev, interopClientDefaultExport: true }) + .source( + opts.src || 'shared/**/!(amp|config|constants|dynamic|head).+(js|ts|tsx)' + ) + .swc('server', { dev: opts.dev }) .target('dist/shared') notify('Compiled shared files') } +export async function shared_re_exported(task, opts) { + await task + .source( + opts.src || 'shared/**/{amp,config,constants,dynamic,head}.+(js|ts|tsx)' + ) + .swc('server', { dev: opts.dev, interopClientDefaultExport: true }) + .target('dist/shared') + notify('Compiled shared re-exported files') +} + export async function server_wasm(task, opts) { await task.source(opts.src || 'server/**/*.+(wasm)').target('dist/server') notify('Moved server wasm files')