diff --git a/package.json b/package.json index d0cd2a9312496..aa124793cc3d5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ ], "scripts": { "lerna": "lerna", - "dev": "lerna run build --stream --parallel", + "dev": "lerna run dev --stream --parallel", "dev2": "while true; do yarn --check-files && yarn dev; done", "testonly": "jest --runInBand", "testheadless": "cross-env HEADLESS=true yarn testonly", diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 37b27051114d1..03eb9d0d14b99 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -21,7 +21,7 @@ "dist" ], "scripts": { - "build": "ncc build ./index.ts -w -o dist/", + "dev": "ncc build ./index.ts -w -o dist/", "prerelease": "rimraf ./dist/", "release": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register", "prepublish": "yarn release" diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index f693de2abe2c9..c6a2bf74c65d5 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -17,7 +17,7 @@ ], "scripts": { "prepublish": "yarn tsc -d -p tsconfig.json", - "build": "yarn tsc -d -w -p tsconfig.json", + "dev": "yarn tsc -d -w -p tsconfig.json", "test": "jest" }, "bin": "./bin/next-codemod.js" diff --git a/packages/next-env/package.json b/packages/next-env/package.json index c83dd0dfd11ce..dcd138d3366b2 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -22,7 +22,7 @@ "types" ], "scripts": { - "build": "ncc build ./index.ts -w -o dist/", + "dev": "ncc build ./index.ts -w -o dist/", "prerelease": "rimraf ./dist/", "types": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir types --esModuleInterop", "release": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register", diff --git a/packages/next/package.json b/packages/next/package.json index 96addcb619984..8bc1d989450e2 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -45,7 +45,7 @@ "next": "./dist/bin/next" }, "scripts": { - "build": "taskr", + "dev": "taskr", "release": "taskr release", "prepublish": "npm run release && yarn types", "types": "tsc --declaration --emitDeclarationOnly --declarationDir dist", diff --git a/packages/next/taskfile-babel.js b/packages/next/taskfile-babel.js index b2603c57e9ad4..90e2d9046f17e 100644 --- a/packages/next/taskfile-babel.js +++ b/packages/next/taskfile-babel.js @@ -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 @@ -111,7 +111,7 @@ module.exports = function (task) { ] : false, ].filter(Boolean), - compact: true, + compact: !dev, babelrc: false, configFile: false, cwd: __dirname, diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index a93b7a1bee6f6..b5a50d05f1a43 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -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 = { @@ -659,8 +659,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 @@ -670,93 +673,99 @@ 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_bfj', - '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_bfj', + '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') } @@ -764,7 +773,7 @@ export async function bin(task, opts) { 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') } @@ -772,7 +781,7 @@ export async function cli(task, opts) { 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') } @@ -780,7 +789,7 @@ export async function lib(task, opts) { 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') } @@ -788,7 +797,7 @@ export async function server(task, opts) { 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') } @@ -796,7 +805,7 @@ export async function nextbuild(task, opts) { 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') } @@ -805,58 +814,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') } diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index a3dca70f1d330..7ff4f5b0f9e4e 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -13,7 +13,7 @@ "license": "MIT", "scripts": { "prepublish": "tsc -d -p tsconfig.json", - "build": "tsc -d -w -p tsconfig.json" + "dev": "tsc -d -w -p tsconfig.json" }, "dependencies": { "@babel/code-frame": "7.12.11", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 881b1a8930f09..d9dd09c6e8988 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -16,7 +16,7 @@ "license": "MIT", "scripts": { "prepublish": "tsc -d -p tsconfig.json", - "build": "tsc -d -w -p tsconfig.json" + "dev": "tsc -d -w -p tsconfig.json" }, "peerDependencies": { "react-refresh": "0.8.3",