Browse Source

Merge pull request #2708 from overleaf/as-babel-polyfills

Automatically add polyfills to frontend

GitOrigin-RevId: 699a697478b8174ee569bd5e2d0fb0bc77c50931
Alasdair Smith 6 years ago
parent
commit
64386d819f

+ 5 - 1
services/web/.babelrc

@@ -1,7 +1,11 @@
 {
   "presets": [
     "@babel/react",
-    ["@babel/env", { "modules": false }]
+    ["@babel/env", {
+      "modules": false,
+      "useBuiltIns": "usage",
+      "corejs": { "version": 3 }
+    }]
   ],
   "plugins": ["angularjs-annotate"]
 }

+ 0 - 22
services/web/frontend/js/libraries.js

@@ -1,25 +1,3 @@
-import 'core-js/stable/symbol'
-import 'core-js/stable/symbol/async-iterator'
-import 'core-js/stable/symbol/description'
-import 'core-js/stable/symbol/has-instance'
-import 'core-js/stable/symbol/is-concat-spreadable'
-import 'core-js/stable/symbol/iterator'
-import 'core-js/stable/symbol/match'
-import 'core-js/stable/symbol/replace'
-import 'core-js/stable/symbol/search'
-import 'core-js/stable/symbol/species'
-import 'core-js/stable/symbol/split'
-import 'core-js/stable/symbol/to-primitive'
-import 'core-js/stable/symbol/to-string-tag'
-import 'core-js/stable/symbol/unscopables'
-import 'core-js/stable/symbol/for'
-import 'core-js/stable/symbol/key-for'
-import 'core-js/stable/object/get-own-property-symbols'
-import 'core-js/stable/promise'
-import 'core-js/stable/math/to-string-tag'
-import 'core-js/stable/array/fill'
-import 'core-js/stable/array/from'
-import 'core-js/stable/array/includes'
 import 'jquery'
 import 'angular'
 import 'angular-sanitize'

+ 5 - 0
services/web/package.json

@@ -28,6 +28,11 @@
     "format:fix": "prettier-eslint '**/*.{js,less}' --write",
     "migrations": "east"
   },
+  "browserslist": [
+    "last 1 year",
+    "ie 11",
+    "firefox esr"
+  ],
   "dependencies": {
     "@babel/cli": "^7.8.4",
     "@babel/core": "^7.9.0",

+ 7 - 5
services/web/webpack.config.js

@@ -56,8 +56,12 @@ module.exports = {
       {
         // Pass application JS files through babel-loader, compiling to ES5
         test: /\.js$/,
-        // Only compile application files (dependencies are in ES5 already)
-        exclude: /node_modules/,
+        // Only compile application files (npm and vendored dependencies are in
+        // ES5 already)
+        exclude: [
+          /node_modules/,
+          path.resolve(__dirname, 'frontend/js/vendor')
+        ],
         use: [
           {
             loader: 'babel-loader',
@@ -103,9 +107,7 @@ module.exports = {
             options: {
               // Uniquely identifies the postcss plugin (required by webpack)
               ident: 'postcss',
-              plugins: [
-                require('autoprefixer')({ env: 'last 2 versions, ie >= 10' })
-              ]
+              plugins: [require('autoprefixer')]
             }
           },
           // Compiles the Less syntax to CSS