Skip to content

Commit

Permalink
Disable compact mode in development
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Feb 1, 2021
1 parent 325fb6d commit 76ce5aa
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 114 deletions.
4 changes: 2 additions & 2 deletions packages/next/taskfile-babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = function (task) {
task.plugin('babel', {}, function* (
file,
serverOrClient,
{ stripExtension } = {}
{ stripExtension, dev } = {}
) {
// Don't compile .d.ts
if (file.base.endsWith('.d.ts')) return
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = function (task) {
]
: false,
].filter(Boolean),
compact: true,
compact: !dev,
babelrc: false,
configFile: false,
cwd: __dirname,
Expand Down
243 changes: 131 additions & 112 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export async function next__polyfill_nomodule(task, opts) {
.target('dist/build/polyfills')
}

export async function browser_polyfills(task) {
await task.parallel(['next__polyfill_nomodule'])
export async function browser_polyfills(task, opts) {
await task.parallel(['next__polyfill_nomodule'], opts)
}

const externals = {
Expand Down Expand Up @@ -651,8 +651,11 @@ export async function path_to_regexp(task, opts) {
.target('dist/compiled/path-to-regexp')
}

export async function precompile(task) {
await task.parallel(['browser_polyfills', 'path_to_regexp', 'copy_ncced'])
export async function precompile(task, opts) {
await task.parallel(
['browser_polyfills', 'path_to_regexp', 'copy_ncced'],
opts
)
}

// eslint-disable-next-line camelcase
Expand All @@ -662,132 +665,138 @@ export async function copy_ncced(task) {
await task.source('compiled/**/*').target('dist/compiled')
}

export async function ncc(task) {
export async function ncc(task, opts) {
await task
.clear('compiled')
.parallel([
'ncc_amphtml_validator',
'ncc_arg',
'ncc_async_retry',
'ncc_async_sema',
'ncc_babel_bundle',
'ncc_babel_bundle_packages',
'ncc_cacache',
'ncc_cache_loader',
'ncc_ci_info',
'ncc_comment_json',
'ncc_compression',
'ncc_conf',
'ncc_content_type',
'ncc_cookie',
'ncc_css_loader',
'ncc_debug',
'ncc_devalue',
'ncc_escape_string_regexp',
'ncc_file_loader',
'ncc_find_cache_dir',
'ncc_find_up',
'ncc_fresh',
'ncc_gzip_size',
'ncc_http_proxy',
'ncc_ignore_loader',
'ncc_is_animated',
'ncc_is_docker',
'ncc_is_wsl',
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_loader_utils',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_nanoid',
'ncc_neo_async',
'ncc_ora',
'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env',
'ncc_postcss_scss',
'ncc_recast',
'ncc_resolve_url_loader',
'ncc_sass_loader',
'ncc_schema_utils',
'ncc_schema_utils3',
'ncc_semver',
'ncc_send',
'ncc_source_map',
'ncc_string_hash',
'ncc_strip_ansi',
'ncc_terser',
'ncc_text_table',
'ncc_thread_loader',
'ncc_unistore',
'ncc_web_vitals',
'ncc_webpack_bundle4',
'ncc_webpack_bundle5',
'ncc_webpack_bundle_packages',
'ncc_webpack_sources',
'ncc_webpack_sources2',
])
}

export async function compile(task) {
await task.parallel([
'cli',
'bin',
'server',
'nextbuild',
'nextbuildstatic',
'pages',
'lib',
'client',
'telemetry',
'nextserver',
])
.parallel(
[
'ncc_amphtml_validator',
'ncc_arg',
'ncc_async_retry',
'ncc_async_sema',
'ncc_babel_bundle',
'ncc_babel_bundle_packages',
'ncc_cacache',
'ncc_cache_loader',
'ncc_ci_info',
'ncc_comment_json',
'ncc_compression',
'ncc_conf',
'ncc_content_type',
'ncc_cookie',
'ncc_css_loader',
'ncc_debug',
'ncc_devalue',
'ncc_escape_string_regexp',
'ncc_file_loader',
'ncc_find_cache_dir',
'ncc_find_up',
'ncc_fresh',
'ncc_gzip_size',
'ncc_http_proxy',
'ncc_ignore_loader',
'ncc_is_animated',
'ncc_is_docker',
'ncc_is_wsl',
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_loader_utils',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_nanoid',
'ncc_neo_async',
'ncc_ora',
'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env',
'ncc_postcss_scss',
'ncc_recast',
'ncc_resolve_url_loader',
'ncc_sass_loader',
'ncc_schema_utils',
'ncc_schema_utils3',
'ncc_semver',
'ncc_send',
'ncc_source_map',
'ncc_string_hash',
'ncc_strip_ansi',
'ncc_terser',
'ncc_text_table',
'ncc_thread_loader',
'ncc_unistore',
'ncc_web_vitals',
'ncc_webpack_bundle4',
'ncc_webpack_bundle5',
'ncc_webpack_bundle_packages',
'ncc_webpack_sources',
'ncc_webpack_sources2',
],
opts
)
}

export async function compile(task, opts) {
await task.parallel(
[
'cli',
'bin',
'server',
'nextbuild',
'nextbuildstatic',
'pages',
'lib',
'client',
'telemetry',
'nextserver',
],
opts
)
}

export async function bin(task, opts) {
await task
.source(opts.src || 'bin/*')
.babel('server', { stripExtension: true })
.babel('server', { stripExtension: true, dev: opts.dev })
.target('dist/bin', { mode: '0755' })
notify('Compiled binaries')
}

export async function cli(task, opts) {
await task
.source(opts.src || 'cli/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/cli')
notify('Compiled cli files')
}

export async function lib(task, opts) {
await task
.source(opts.src || 'lib/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/lib')
notify('Compiled lib files')
}

export async function server(task, opts) {
await task
.source(opts.src || 'server/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/server')
notify('Compiled server files')
}

export async function nextbuild(task, opts) {
await task
.source(opts.src || 'build/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/build')
notify('Compiled build files')
}

export async function client(task, opts) {
await task
.source(opts.src || 'client/**/*.+(js|ts|tsx)')
.babel('client')
.babel('client', { dev: opts.dev })
.target('dist/client')
notify('Compiled client files')
}
Expand All @@ -796,58 +805,68 @@ export async function client(task, opts) {
export async function nextbuildstatic(task, opts) {
await task
.source(opts.src || 'export/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/export')
notify('Compiled export files')
}

export async function pages_app(task) {
await task.source('pages/_app.tsx').babel('client').target('dist/pages')
export async function pages_app(task, opts) {
await task
.source('pages/_app.tsx')
.babel('client', { dev: opts.dev })
.target('dist/pages')
}

export async function pages_error(task) {
await task.source('pages/_error.tsx').babel('client').target('dist/pages')
export async function pages_error(task, opts) {
await task
.source('pages/_error.tsx')
.babel('client', { dev: opts.dev })
.target('dist/pages')
}

export async function pages_document(task) {
await task.source('pages/_document.tsx').babel('server').target('dist/pages')
export async function pages_document(task, opts) {
await task
.source('pages/_document.tsx')
.babel('server', { dev: opts.dev })
.target('dist/pages')
}

export async function pages(task, _opts) {
await task.parallel(['pages_app', 'pages_error', 'pages_document'])
export async function pages(task, opts) {
await task.parallel(['pages_app', 'pages_error', 'pages_document'], opts)
}

export async function telemetry(task, opts) {
await task
.source(opts.src || 'telemetry/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/telemetry')
notify('Compiled telemetry files')
}

export async function build(task) {
await task.serial(['precompile', 'compile'])
export async function build(task, opts) {
await task.serial(['precompile', 'compile'], opts)
}

export default async function (task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build')
await task.watch('bin/*', 'bin')
await task.watch('pages/**/*.+(js|ts|tsx)', 'pages')
await task.watch('server/**/*.+(js|ts|tsx)', 'server')
await task.watch('build/**/*.+(js|ts|tsx)', 'nextbuild')
await task.watch('export/**/*.+(js|ts|tsx)', 'nextbuildstatic')
await task.watch('client/**/*.+(js|ts|tsx)', 'client')
await task.watch('lib/**/*.+(js|ts|tsx)', 'lib')
await task.watch('cli/**/*.+(js|ts|tsx)', 'cli')
await task.watch('telemetry/**/*.+(js|ts|tsx)', 'telemetry')
await task.watch('next-server/**/*.+(js|ts|tsx)', 'nextserver')
await task.start('build', opts)
await task.watch('bin/*', 'bin', opts)
await task.watch('pages/**/*.+(js|ts|tsx)', 'pages', opts)
await task.watch('server/**/*.+(js|ts|tsx)', 'server', opts)
await task.watch('build/**/*.+(js|ts|tsx)', 'nextbuild', opts)
await task.watch('export/**/*.+(js|ts|tsx)', 'nextbuildstatic', opts)
await task.watch('client/**/*.+(js|ts|tsx)', 'client', opts)
await task.watch('lib/**/*.+(js|ts|tsx)', 'lib', opts)
await task.watch('cli/**/*.+(js|ts|tsx)', 'cli', opts)
await task.watch('telemetry/**/*.+(js|ts|tsx)', 'telemetry', opts)
await task.watch('next-server/**/*.+(js|ts|tsx)', 'nextserver', opts)
}

export async function nextserver(task, opts) {
await task
.source(opts.src || 'next-server/**/*.+(js|ts|tsx)')
.babel('server')
.babel('server', { dev: opts.dev })
.target('dist/next-server')
notify('Compiled server files')
}
Expand Down

0 comments on commit 76ce5aa

Please sign in to comment.