Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript #144

Open
aJean opened this issue Mar 15, 2022 · 0 comments
Open

Typescript #144

aJean opened this issue Mar 15, 2022 · 0 comments
Projects

Comments

@aJean
Copy link
Owner

aJean commented Mar 15, 2022

方案一
babel-loader + @babel/preset-env + @babel/preset-typescript + fork-ts-checker-webpack-plugin

Babel 7 编译器具有编译 TypeScript 的能力。

@babel/preset-typescript 在编译 TypeScript 文件时会为了速度会删除所有的类型,这样类型检查就没用了。

fork-ts-checker-webpack-plugin 在独立的进程中提供类型检查。

注意:这种编译方式主要依赖于 .babelrc,忽略 tsconfig.json 里关于编译的所有设置。

参考 1:https://babeljs.io/docs/en/babel-preset-typescript

参考 2:https://babeljs.io/docs/en/babel-plugin-transform-typescript

参考 3:https://github.com/TypeStrong/fork-ts-checker-webpack-plugin

例子: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/main/examples/babel-loader

方案二
ts-loader + fork-ts-checker-webpack-plugin

ts-loader 依赖 typescript 里 tsc 编译器的能力,会读取 tsconfig.json 里关于编译的设置(target、module 等)。

tsc 具有与时俱进的编译能力,支持 TypeScript 各项特性。

fork-ts-checker-webpack-plugin 在独立的进程中提供类型检查。

参考 1:https://webpack.js.org/guides/typescript/

参考 2:https://webpack.js.org/guides/build-performance/

参考 3:https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/main/examples/ts-loader

参考 4:https://www.typescriptlang.org/docs/handbook/release-notes/overview.html

方案三
swc-loader + fork-ts-checker-webpack-plugin

swc-loader 是一个 Rust 语言开发超级快的编译器。

fork-ts-checker-webpack-plugin 在独立的进程中提供类型检查。

参考 1:https://swc.rs/

参考 2:https://github.com/TypeStrong/fork-ts-checker-webpack-plugin

方案四
esbuild-loader + fork-ts-checker-webpack-plugin

esbuild-loader 是一个 Go 语言开发超级快的编译器。

fork-ts-checker-webpack-plugin 在独立的进程中提供类型检查。

参考 1:https://esbuild.github.io/

参考 2:https://github.com/evanw/esbuild

参考 3:https://github.com/privatenumber/esbuild-loader

参考 4:https://github.com/TypeStrong/fork-ts-checker-webpack-plugin

@aJean aJean created this issue from a note in 工程 (工具) Mar 15, 2022
@aJean aJean changed the title ts Typescript Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
工程
工具
Development

No branches or pull requests

1 participant