rsnext/packages/next/taskfile.js

671 lines
22 KiB
JavaScript
Raw Normal View History

// eslint-disable-next-line import/no-extraneous-dependencies
const notifier = require('node-notifier')
const relative = require('path').relative
2020-03-29 18:56:34 +02:00
export async function next__polyfill_nomodule(task, opts) {
await task
.source(
opts.src ||
relative(__dirname, require.resolve('@next/polyfill-nomodule'))
)
.target('dist/build/polyfills')
}
export async function unfetch(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('unfetch')))
.target('dist/build/polyfills')
}
export async function browser_polyfills(task) {
await task.parallel(['next__polyfill_nomodule', 'unfetch'])
2020-03-29 18:56:34 +02:00
}
2020-03-29 18:16:32 +02:00
const externals = {
2020-03-30 03:25:10 +02:00
// Babel
'@babel/core': '@babel/core',
// Browserslist (post-css plugins)
browserslist: 'browserslist',
2020-08-10 17:27:21 +02:00
'caniuse-lite': 'caniuse-lite',
2020-03-30 03:25:10 +02:00
// Webpack indirect and direct dependencies:
webpack: 'webpack',
'webpack-sources': 'webpack-sources',
'webpack/lib/node/NodeOutputFileSystem':
'webpack/lib/node/NodeOutputFileSystem',
// dependents: terser-webpack-plugin
'webpack/lib/cache/getLazyHashedEtag': 'webpack/lib/cache/getLazyHashedEtag',
'webpack/lib/RequestShortener': 'webpack/lib/RequestShortener',
2020-03-30 03:25:10 +02:00
chokidar: 'chokidar',
// dependents: babel-loader, async-retry, cache-loader, terser-webpack-plugin
2020-03-30 03:25:10 +02:00
'find-cache-dir': 'find-cache-dir',
2020-03-30 01:20:35 +02:00
// dependents: thread-loader
'loader-runner': 'loader-runner',
2020-03-30 03:25:10 +02:00
// dependents: thread-loader, babel-loader
2020-03-30 01:20:35 +02:00
'loader-utils': 'loader-utils',
2020-03-30 03:25:10 +02:00
// dependents: babel-loader
mkdirp: 'mkdirp',
// dependents: thread-loader, cache-loader
'neo-async': 'neo-async',
// dependents: cache-loader, style-loader, file-loader
'schema-utils': 'schema-utils',
// dependents: terser-webpack-plugin
'jest-worker': 'jest-worker',
cacache: 'cacache',
2020-03-29 05:41:35 +02:00
}
2020-03-29 00:31:06 +01:00
// eslint-disable-next-line camelcase
externals['amphtml-validator'] = 'next/dist/compiled/amphtml-validator'
2020-03-29 00:31:06 +01:00
export async function ncc_amphtml_validator(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('amphtml-validator'))
)
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'amphtml-validator', externals })
.target('compiled/amphtml-validator')
2020-03-29 00:31:06 +01:00
}
// eslint-disable-next-line camelcase
externals['arg'] = 'distcompiled/arg'
export async function ncc_arg(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('arg')))
.ncc({ packageName: 'arg' })
.target('compiled/arg')
}
2019-02-27 15:22:18 +01:00
// eslint-disable-next-line camelcase
externals['async-retry'] = 'next/dist/compiled/async-retry'
2020-03-29 00:27:09 +01:00
export async function ncc_async_retry(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('async-retry')))
2020-03-29 01:53:00 +01:00
.ncc({
packageName: 'async-retry',
2020-03-29 18:16:32 +02:00
externals,
2020-03-29 01:53:00 +01:00
})
.target('compiled/async-retry')
2020-03-29 00:27:09 +01:00
}
// eslint-disable-next-line camelcase
externals['async-sema'] = 'next/dist/compiled/async-sema'
2020-03-29 00:27:09 +01:00
export async function ncc_async_sema(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('async-sema')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'async-sema', externals })
.target('compiled/async-sema')
2020-03-29 00:27:09 +01:00
}
2020-03-30 00:49:57 +02:00
// eslint-disable-next-line camelcase
2020-03-30 03:25:10 +02:00
externals['babel-loader'] = 'next/dist/compiled/babel-loader'
export async function ncc_babel_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('babel-loader')))
.ncc({ packageName: 'babel-loader', externals })
.target('compiled/babel-loader')
2020-03-30 03:25:10 +02:00
}
// eslint-disable-next-line camelcase
externals['cache-loader'] = 'next/dist/compiled/cache-loader'
export async function ncc_cache_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('cache-loader')))
.ncc({ packageName: 'cache-loader', externals })
.target('compiled/cache-loader')
2020-03-30 03:25:10 +02:00
}
// eslint-disable-next-line camelcase
2020-05-09 17:21:53 +02:00
// NB: Used by other dependencies, but Vercel version is a duplicate
2020-03-29 21:07:55 +02:00
// version so can be inlined anyway (although may change in future)
externals['chalk'] = 'next/dist/compiled/chalk'
2020-03-29 00:43:52 +01:00
export async function ncc_chalk(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('chalk')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'chalk', externals })
.target('compiled/chalk')
2020-03-29 00:43:52 +01:00
}
// eslint-disable-next-line camelcase
externals['ci-info'] = 'next/dist/compiled/ci-info'
2020-03-29 00:43:52 +01:00
export async function ncc_ci_info(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('ci-info')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'ci-info', externals })
.target('compiled/ci-info')
2020-03-29 00:43:52 +01:00
}
// eslint-disable-next-line camelcase
externals['compression'] = 'next/dist/compiled/compression'
2020-03-29 00:56:38 +01:00
export async function ncc_compression(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('compression')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'compression', externals })
.target('compiled/compression')
2020-03-29 00:56:38 +01:00
}
// eslint-disable-next-line camelcase
externals['conf'] = 'next/dist/compiled/conf'
2020-03-29 17:46:33 +02:00
export async function ncc_conf(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('conf')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'conf', externals })
.target('compiled/conf')
2020-03-29 17:46:33 +02:00
}
// eslint-disable-next-line camelcase
externals['content-type'] = 'next/dist/compiled/content-type'
2020-03-29 00:56:38 +01:00
export async function ncc_content_type(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('content-type')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'content-type', externals })
.target('compiled/content-type')
2020-03-29 00:56:38 +01:00
}
// eslint-disable-next-line camelcase
externals['cookie'] = 'next/dist/compiled/cookie'
2020-03-29 01:02:03 +01:00
export async function ncc_cookie(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('cookie')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'cookie', externals })
.target('compiled/cookie')
2020-03-29 01:02:03 +01:00
}
// eslint-disable-next-line camelcase
externals['debug'] = 'next/dist/compiled/debug'
export async function ncc_debug(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('debug')))
.ncc({ packageName: 'debug', externals })
.target('compiled/debug')
}
// eslint-disable-next-line camelcase
externals['devalue'] = 'next/dist/compiled/devalue'
2020-03-29 01:18:22 +01:00
export async function ncc_devalue(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('devalue')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'devalue', externals })
.target('compiled/devalue')
2020-03-29 01:18:22 +01:00
}
externals['escape-string-regexp'] = 'next/dist/compiled/escape-string-regexp'
// eslint-disable-next-line camelcase
2020-03-29 01:21:07 +01:00
export async function ncc_escape_string_regexp(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('escape-string-regexp'))
)
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'escape-string-regexp', externals })
.target('compiled/escape-string-regexp')
2020-03-29 01:21:07 +01:00
}
// eslint-disable-next-line camelcase
externals['etag'] = 'next/dist/compiled/etag'
2020-03-29 01:22:42 +01:00
export async function ncc_etag(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('etag')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'etag', externals })
.target('compiled/etag')
2020-03-29 01:22:42 +01:00
}
// eslint-disable-next-line camelcase
2020-03-30 03:30:55 +02:00
externals['file-loader'] = 'next/dist/compiled/file-loader'
export async function ncc_file_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('file-loader')))
.ncc({ packageName: 'file-loader', externals })
.target('compiled/file-loader')
2020-03-30 03:30:55 +02:00
}
// eslint-disable-next-line camelcase
externals['find-up'] = 'next/dist/compiled/find-up'
2020-03-29 18:21:53 +02:00
export async function ncc_find_up(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('find-up')))
.ncc({ packageName: 'find-up', externals })
.target('compiled/find-up')
2020-03-29 18:21:53 +02:00
}
// eslint-disable-next-line camelcase
externals['fresh'] = 'next/dist/compiled/fresh'
2020-03-29 01:27:13 +01:00
export async function ncc_fresh(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('fresh')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'fresh', externals })
.target('compiled/fresh')
2020-03-29 01:27:13 +01:00
}
// eslint-disable-next-line camelcase
externals['gzip-size'] = 'next/dist/compiled/gzip-size'
2020-03-29 01:29:14 +01:00
export async function ncc_gzip_size(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('gzip-size')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'gzip-size', externals })
.target('compiled/gzip-size')
2020-03-29 01:29:14 +01:00
}
// eslint-disable-next-line camelcase
externals['http-proxy'] = 'next/dist/compiled/http-proxy'
2020-03-29 01:30:34 +01:00
export async function ncc_http_proxy(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('http-proxy')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'http-proxy', externals })
.target('compiled/http-proxy')
2020-03-29 01:30:34 +01:00
}
// eslint-disable-next-line camelcase
2020-03-30 03:37:41 +02:00
externals['ignore-loader'] = 'next/dist/compiled/ignore-loader'
export async function ncc_ignore_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('ignore-loader')))
.ncc({ packageName: 'ignore-loader', externals })
.target('compiled/ignore-loader')
2020-03-30 03:37:41 +02:00
}
// eslint-disable-next-line camelcase
externals['is-docker'] = 'next/dist/compiled/is-docker'
2020-03-29 01:33:35 +01:00
export async function ncc_is_docker(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('is-docker')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'is-docker', externals })
.target('compiled/is-docker')
2020-03-29 01:33:35 +01:00
}
// eslint-disable-next-line camelcase
externals['is-wsl'] = 'next/dist/compiled/is-wsl'
2020-03-29 01:33:35 +01:00
export async function ncc_is_wsl(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('is-wsl')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'is-wsl', externals })
.target('compiled/is-wsl')
2020-03-29 01:33:35 +01:00
}
// eslint-disable-next-line camelcase
externals['json5'] = 'next/dist/compiled/json5'
2020-03-29 01:36:15 +01:00
export async function ncc_json5(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('json5')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'json5', externals })
.target('compiled/json5')
2020-03-29 01:36:15 +01:00
}
// eslint-disable-next-line camelcase
externals['jsonwebtoken'] = 'next/dist/compiled/jsonwebtoken'
2020-03-29 01:37:45 +01:00
export async function ncc_jsonwebtoken(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('jsonwebtoken')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'jsonwebtoken', externals })
.target('compiled/jsonwebtoken')
2020-03-29 01:37:45 +01:00
}
// eslint-disable-next-line camelcase
externals['lodash.curry'] = 'next/dist/compiled/lodash.curry'
2020-03-29 01:43:59 +01:00
export async function ncc_lodash_curry(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('lodash.curry')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'lodash.curry', externals })
.target('compiled/lodash.curry')
2020-03-29 01:43:59 +01:00
}
// eslint-disable-next-line camelcase
externals['lru-cache'] = 'next/dist/compiled/lru-cache'
2020-03-29 01:46:22 +01:00
export async function ncc_lru_cache(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('lru-cache')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'lru-cache', externals })
.target('compiled/lru-cache')
2020-03-29 01:46:22 +01:00
}
// eslint-disable-next-line camelcase
externals['nanoid'] = 'next/dist/compiled/nanoid'
export async function ncc_nanoid(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('nanoid')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'nanoid', externals })
.target('compiled/nanoid')
}
// eslint-disable-next-line camelcase
externals['node-fetch'] = 'next/dist/compiled/node-fetch'
2020-03-29 01:53:00 +01:00
export async function ncc_node_fetch(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('node-fetch')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'node-fetch', externals })
.target('compiled/node-fetch')
2020-03-29 01:53:00 +01:00
}
// eslint-disable-next-line camelcase
externals['ora'] = 'next/dist/compiled/ora'
2020-03-29 01:53:00 +01:00
export async function ncc_ora(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('ora')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'ora', externals })
.target('compiled/ora')
2020-03-29 01:53:00 +01:00
}
// eslint-disable-next-line camelcase
2020-03-30 04:01:30 +02:00
externals['postcss-flexbugs-fixes'] =
'next/dist/compiled/postcss-flexbugs-fixes'
export async function ncc_postcss_flexbugs_fixes(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-flexbugs-fixes'))
)
.ncc({ packageName: 'postcss-flexbugs-fixes', externals })
.target('compiled/postcss-flexbugs-fixes')
2020-03-30 04:01:30 +02:00
}
// eslint-disable-next-line camelcase
externals['postcss-loader'] = 'next/dist/compiled/postcss-loader'
export async function ncc_postcss_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('postcss-loader')))
.ncc({ packageName: 'postcss-loader', externals })
.target('compiled/postcss-loader')
2020-03-30 04:01:30 +02:00
}
// eslint-disable-next-line camelcase
externals['postcss-preset-env'] = 'next/dist/compiled/postcss-preset-env'
export async function ncc_postcss_preset_env(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-preset-env'))
)
.ncc({ packageName: 'postcss-preset-env', externals })
.target('compiled/postcss-preset-env')
2020-03-30 04:01:30 +02:00
}
// eslint-disable-next-line camelcase
externals['raw-body'] = 'next/dist/compiled/raw-body'
2020-03-29 01:58:43 +01:00
export async function ncc_raw_body(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('raw-body')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'raw-body', externals })
.target('compiled/raw-body')
2020-03-29 01:58:43 +01:00
}
// eslint-disable-next-line camelcase
externals['recast'] = 'next/dist/compiled/recast'
2020-03-29 03:36:38 +02:00
export async function ncc_recast(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('recast')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'recast', externals })
.target('compiled/recast')
2020-03-29 03:36:38 +02:00
}
// eslint-disable-next-line camelcase
2020-05-09 17:21:53 +02:00
// NB: Used by other dependencies, but Vercel version is a duplicate
2020-03-29 21:07:55 +02:00
// version so can be inlined anyway (although may change in future)
externals['resolve'] = 'next/dist/compiled/resolve'
export async function ncc_resolve(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('resolve')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'resolve', externals })
.target('compiled/resolve')
}
// eslint-disable-next-line camelcase
externals['send'] = 'next/dist/compiled/send'
2020-03-29 03:40:29 +02:00
export async function ncc_send(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('send')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'send', externals })
.target('compiled/send')
2020-03-29 03:40:29 +02:00
}
// eslint-disable-next-line camelcase
2020-05-09 17:21:53 +02:00
// NB: Used by other dependencies, but Vercel version is a duplicate
2020-03-29 21:07:55 +02:00
// version so can be inlined anyway (although may change in future)
externals['source-map'] = 'next/dist/compiled/source-map'
2020-03-29 05:41:35 +02:00
export async function ncc_source_map(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('source-map')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'source-map', externals })
.target('compiled/source-map')
2020-03-29 05:41:35 +02:00
}
// eslint-disable-next-line camelcase
externals['string-hash'] = 'next/dist/compiled/string-hash'
2020-03-29 05:05:26 +02:00
export async function ncc_string_hash(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('string-hash')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'string-hash', externals })
.target('compiled/string-hash')
2020-03-29 05:05:26 +02:00
}
// eslint-disable-next-line camelcase
externals['strip-ansi'] = 'next/dist/compiled/strip-ansi'
2020-03-29 05:05:26 +02:00
export async function ncc_strip_ansi(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('strip-ansi')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'strip-ansi', externals })
.target('compiled/strip-ansi')
2020-03-29 05:05:26 +02:00
}
// eslint-disable-next-line camelcase
externals['terser'] = 'next/dist/compiled/terser'
2020-03-29 05:52:40 +02:00
export async function ncc_terser(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('terser')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'terser', externals })
.target('compiled/terser')
2020-03-29 05:52:40 +02:00
}
// eslint-disable-next-line camelcase
externals['text-table'] = 'next/dist/compiled/text-table'
export async function ncc_text_table(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('text-table')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'text-table', externals })
.target('compiled/text-table')
}
// eslint-disable-next-line camelcase
2020-03-30 01:20:35 +02:00
externals['thread-loader'] = 'next/dist/compiled/thread-loader'
export async function ncc_thread_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('thread-loader')))
.ncc({ packageName: 'thread-loader', externals })
.target('compiled/thread-loader')
2020-03-30 01:20:35 +02:00
}
// eslint-disable-next-line camelcase
externals['unistore'] = 'next/dist/compiled/unistore'
export async function ncc_unistore(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('unistore')))
2020-03-29 18:16:32 +02:00
.ncc({ packageName: 'unistore', externals })
.target('compiled/unistore')
}
externals['terser-webpack-plugin'] = 'next/dist/compiled/terser-webpack-plugin'
export async function ncc_terser_webpack_plugin(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('terser-webpack-plugin'))
)
.ncc({ packageName: 'terser-webpack-plugin', externals })
.target('compiled/terser-webpack-plugin')
}
externals['comment-json'] = 'next/dist/compiled/comment-json'
export async function ncc_comment_json(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('comment-json')))
.ncc({ packageName: 'comment-json', externals })
.target('compiled/comment-json')
}
externals['semver'] = 'next/dist/compiled/semver'
export async function ncc_semver(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('semver')))
.ncc({ packageName: 'semver', externals })
.target('compiled/semver')
}
externals['path-to-regexp'] = 'next/dist/compiled/path-to-regexp'
2020-03-29 19:17:06 +02:00
export async function path_to_regexp(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('path-to-regexp')))
.target('dist/compiled/path-to-regexp')
}
2020-03-29 19:31:43 +02:00
export async function precompile(task) {
2020-05-15 20:14:44 +02:00
await task.parallel(['browser_polyfills', 'path_to_regexp', 'copy_ncced'])
}
// eslint-disable-next-line camelcase
export async function copy_ncced(task) {
// we don't ncc every time we build since these won't change
// that often and can be committed to the repo saving build time
await task.source('compiled/**/*').target('dist/compiled')
}
export async function ncc(task) {
await task
.clear('compiled')
.parallel([
'ncc_amphtml_validator',
'ncc_arg',
'ncc_async_retry',
'ncc_async_sema',
'ncc_babel_loader',
'ncc_cache_loader',
'ncc_chalk',
'ncc_ci_info',
'ncc_compression',
'ncc_conf',
'ncc_content_type',
'ncc_cookie',
'ncc_debug',
'ncc_devalue',
'ncc_escape_string_regexp',
'ncc_etag',
'ncc_file_loader',
'ncc_find_up',
'ncc_fresh',
'ncc_gzip_size',
'ncc_http_proxy',
'ncc_ignore_loader',
'ncc_is_docker',
'ncc_is_wsl',
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_nanoid',
'ncc_node_fetch',
'ncc_ora',
'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env',
'ncc_raw_body',
'ncc_recast',
'ncc_resolve',
'ncc_send',
'ncc_source_map',
'ncc_string_hash',
'ncc_strip_ansi',
'ncc_terser',
'ncc_text_table',
'ncc_thread_loader',
'ncc_unistore',
'ncc_terser_webpack_plugin',
'ncc_comment_json',
'ncc_semver',
])
}
export async function compile(task) {
await task.parallel([
'cli',
'bin',
'server',
'nextbuild',
'nextbuildstatic',
'pages',
'lib',
'client',
'telemetry',
'nextserver',
])
}
export async function bin(task, opts) {
await task
.source(opts.src || 'bin/*')
.babel('server', { stripExtension: true })
.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')
.target('dist/cli')
2019-02-26 21:57:32 +01:00
notify('Compiled cli files')
}
export async function lib(task, opts) {
await task
.source(opts.src || 'lib/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/lib')
notify('Compiled lib files')
}
export async function server(task, opts) {
await task
.source(opts.src || 'server/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/server')
notify('Compiled server files')
}
export async function nextbuild(task, opts) {
await task
.source(opts.src || 'build/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/build')
notify('Compiled build files')
}
export async function client(task, opts) {
await task
.source(opts.src || 'client/**/*.+(js|ts|tsx)')
.babel('client')
.target('dist/client')
notify('Compiled client files')
}
// export is a reserved keyword for functions
export async function nextbuildstatic(task, opts) {
await task
.source(opts.src || 'export/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/export')
notify('Compiled export files')
}
export async function pages_app(task) {
2020-05-18 21:24:37 +02:00
await task.source('pages/_app.tsx').babel('client').target('dist/pages')
}
export async function pages_error(task) {
2020-05-18 21:24:37 +02:00
await task.source('pages/_error.tsx').babel('client').target('dist/pages')
}
export async function pages_document(task) {
2020-05-18 21:24:37 +02:00
await task.source('pages/_document.tsx').babel('server').target('dist/pages')
}
export async function pages(task, _opts) {
await task.parallel(['pages_app', 'pages_error', 'pages_document'])
}
export async function telemetry(task, opts) {
await task
.source(opts.src || 'telemetry/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/telemetry')
notify('Compiled telemetry files')
}
export async function build(task) {
await task.serial(['precompile', 'compile'])
}
2020-05-18 21:24:37 +02:00
export default async function (task) {
2018-11-30 13:10:30 +01:00
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')
}
export async function nextserver(task, opts) {
await task
.source(opts.src || 'next-server/**/*.+(js|ts|tsx)')
.babel('server')
.target('dist/next-server')
notify('Compiled server files')
}
export async function release(task) {
await task.clear('dist').start('build')
}
// notification helper
function notify(msg) {
return notifier.notify({
title: '▲ Next',
message: msg,
icon: false,
})
}