webpack: Transpile JS code with Babel.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-07-09 15:05:46 -07:00 committed by Tim Abbott
parent ecfb7c6a7f
commit f54a63e2f9
8 changed files with 848 additions and 28 deletions

16
.babelrc Normal file
View File

@ -0,0 +1,16 @@
{
"presets": [
[
"@babel/preset-env",
{
"corejs": 3,
"useBuiltIns": "usage"
}
],
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties"
],
"sourceType": "unambiguous"
}

6
.browserslistrc Normal file
View File

@ -0,0 +1,6 @@
> 0.2%
> 0.2% in US
last 2 versions
Firefox ESR
not dead
Chrome 26 # similar to PhantomJS

View File

@ -5,11 +5,16 @@
"description": "",
"main": "",
"dependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-typescript": "^7.3.3",
"@types/node": "12.0.7",
"@types/underscore": "1.8.18",
"@types/webpack": "4.4.32",
"@types/webpack-dev-server": "3.1.6",
"autosize": "4.0.2",
"babel-loader": "^8.0.6",
"blueimp-md5": "2.10.0",
"cache-loader": "4.0.0",
"clipboard": "2.0.4",
@ -47,7 +52,6 @@
"spectrum-colorpicker": "^1.8.0",
"style-loader": "0.23.1",
"to-markdown": "3.1.0",
"ts-loader": "6.0.2",
"ts-node": "7.0.1",
"typescript": "3.5.1",
"underscore": "1.9.1",

View File

@ -13,7 +13,6 @@ import "xdate/src/xdate.js";
import "jquery-validation/dist/jquery.validate.js";
import "blueimp-md5/js/md5.js";
import "clipboard/dist/clipboard.js";
import "core-js/features/string/code-point-at";
import "winchan/winchan.js";
import "handlebars/dist/cjs/handlebars.runtime.js";
import "to-markdown/dist/to-markdown.js";

View File

@ -1,7 +1,4 @@
import "core-js/features/promise";
import "core-js/features/string/ends-with";
import "core-js/features/string/starts-with";
import "core-js/features/string/code-point-at";
import "jquery/dist/jquery.js";
import "underscore/underscore.js";
import "../csrf.js";

View File

@ -33,13 +33,11 @@ export default (env?: string): webpack.Configuration[] => {
},
],
},
// Run the typescript compilier on .ts files before webpack
// Transpile .js and .ts files with Babel
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
configFile: require.resolve('../static/js/tsconfig.json'),
},
test: /\.(js|ts)$/,
include: resolve(__dirname, '../static/js'),
loader: 'babel-loader',
},
// Uses script-loader on minified files so we don't change global variables in them.
// Also has the effect of making processing these files fast
@ -156,7 +154,7 @@ export default (env?: string): webpack.Configuration[] => {
{ path: "sortablejs/Sortable.js"},
{ path: "winchan/winchan.js", name: 'WinChan'},
];
config.module.rules.push(...getExposeLoaders(exposeOptions));
config.module.rules.unshift(...getExposeLoaders(exposeOptions));
if (production) {
config.plugins = [

View File

@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/03/01/zulip-2-0-relea
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = '42.1'
PROVISION_VERSION = '43.0'

830
yarn.lock

File diff suppressed because it is too large Load Diff