1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/packages/next/taskfile.js
Tim Neutkens 15bb1c5e79
Use Typescript to transpile Next.js core files instead of Babel (#5747)
- Replaces taskr-babel with taskr-typescript for the `next` package
- Makes sure Node 8+ is used, no unneeded transpilation
- Compile Next.js client side files through babel the same way pages are
- Compile Next.js client side files to esmodules, not commonjs, so that tree shaking works.
- Move error-debug.js out of next-server as it's only used/require in development
- Drop ansi-html as dependency from next-server
- Make next/link esmodule (for tree-shaking)
- Make next/router esmodule (for tree-shaking)
- add typescript compilation to next-server
- Remove last remains of Flow
- Move hoist-non-react-statics to next, out of next-server
- Move htmlescape to next, out of next-server
- Remove runtime-corejs2 from next-server
2018-11-28 15:03:02 +01:00

69 lines
2.1 KiB
JavaScript

const notifier = require('node-notifier')
export async function compile (task) {
await task.parallel(['bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client'])
}
export async function bin (task, opts) {
await task.source(opts.src || 'bin/*').typescript({module: 'commonjs'}).target('dist/bin', {mode: '0755'})
notify('Compiled binaries')
}
export async function lib (task, opts) {
await task.source(opts.src || 'lib/**/*.js').typescript({module: 'commonjs'}).target('dist/lib')
notify('Compiled lib files')
}
export async function server (task, opts) {
await task.source(opts.src || 'server/**/*.js').typescript({module: 'commonjs'}).target('dist/server')
notify('Compiled server files')
}
export async function nextbuild (task, opts) {
await task.source(opts.src || 'build/**/*.js').typescript({module: 'commonjs'}).target('dist/build')
notify('Compiled build files')
}
export async function client (task, opts) {
await task.source(opts.src || 'client/**/*.js').typescript().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').typescript({module: 'commonjs'}).target('dist/export')
notify('Compiled export files')
}
export async function pages (task, opts) {
await task.source(opts.src || 'pages/**/*.js').typescript().target('dist/pages')
}
export async function build (task) {
await task.serial(['compile'])
}
export default async function (task) {
await task.start('build')
await task.watch('bin/*', 'bin')
await task.watch('pages/**/*.js', 'pages')
await task.watch('server/**/*.js', 'server')
await task.watch('build/**/*.js', 'nextbuild')
await task.watch('export/**/*.js', 'nextexport')
await task.watch('client/**/*.js', 'client')
await task.watch('lib/**/*.js', 'lib')
}
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
})
}