未验证 提交 bbc34686 编写于 作者: T Tim Neutkens 提交者: GitHub

Remove Typescript helpers in favor of babel helpers (#6087)

There's still a few Typescript helpers in use, but regenerator is added by Babel after this change, as it was already in the bundle it'll drop bundle sizes by quite a bit, eg _app.js becomes half the size.
上级 9f08e48d
......@@ -32,7 +32,8 @@
},
"taskr": {
"requires": [
"./taskfile-typescript.js"
"./taskfile-typescript.js",
"./taskfile-babel.js"
]
},
"dependencies": {
......
// taskr babel plugin with Babel 7 support
// https://github.com/lukeed/taskr/pull/305
'use strict'
const transform = require('@babel/core').transform
module.exports = function (task) {
task.plugin('babel', {}, function * (file, opts) {
const options = {
...opts
}
options.filename = file.base
options.plugins = [
require('@babel/plugin-syntax-dynamic-import'),
...(options.plugins || [])
]
options.babelrc = false
options.configFile = false
options.babelrcRoots = false
const output = transform(file.data, options)
file.data = Buffer.from(output.code)
})
}
const notifier = require('node-notifier')
const babelOpts = {
presets: [
['@babel/preset-env', {
modules: 'commonjs',
'targets': {
'browsers': ['IE 11']
}
}]
],
plugins: [
['@babel/plugin-transform-runtime', {
corejs: 2,
helpers: true,
regenerator: true,
useESModules: false
}]
]
}
export async function compile (task) {
await task.parallel(['bin', 'server', 'nextbuild', 'nextbuildstatic', 'pages', 'lib', 'client'])
......@@ -25,7 +43,7 @@ export async function nextbuild (task, opts) {
}
export async function client (task, opts) {
await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript({module: 'commonjs', target: 'es5'}).target('dist/client')
await task.source(opts.src || 'client/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).babel(babelOpts).target('dist/client')
notify('Compiled client files')
}
......@@ -36,7 +54,7 @@ export async function nextbuildstatic (task, opts) {
}
export async function pages (task, opts) {
await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript({module: 'commonjs', target: 'es5'}).target('dist/pages')
await task.source(opts.src || 'pages/**/*.+(js|ts|tsx)').typescript({module: 'commonjs'}).babel(babelOpts).target('dist/pages')
}
export async function build (task) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册