Add patch to install .babelrc.js

This commit is contained in:
Utkarsh Gupta 2019-05-05 17:02:35 +05:30
parent a301ba6ec1
commit b7eae1279a
2 changed files with 52 additions and 0 deletions

51
debian/patches/0720-install-babelrc.js vendored Normal file
View file

@ -0,0 +1,51 @@
Description: Install .babelrc.js explicitally.
Author: Utkarsh Gupta <guptautkarsh2102@gmail.com>
--- /dev/null
+++ gitlab-11.8.9+dfsg/.babelrc.js
@@ -0,0 +1,45 @@
+const BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || null;
+
+const presets = [
+ [
+ '@babel/preset-env',
+ {
+ modules: false,
+ targets: {
+ ie: '11',
+ },
+ },
+ ],
+];
+
+// include stage 3 proposals
+const plugins = [
+ '@babel/plugin-syntax-dynamic-import',
+ '@babel/plugin-syntax-import-meta',
+ '@babel/plugin-proposal-class-properties',
+ '@babel/plugin-proposal-json-strings',
+ '@babel/plugin-proposal-private-methods',
+];
+
+// add code coverage tooling if necessary
+if (BABEL_ENV === 'coverage') {
+ plugins.push([
+ 'babel-plugin-istanbul',
+ {
+ exclude: ['spec/javascripts/**/*', 'app/assets/javascripts/locale/**/app.js'],
+ },
+ ]);
+}
+
+// add rewire support when running tests
+if (BABEL_ENV === 'karma' || BABEL_ENV === 'coverage') {
+ plugins.push('babel-plugin-rewire');
+}
+
+// Jest is running in node environment
+if (BABEL_ENV === 'jest') {
+ plugins.push('transform-es2015-modules-commonjs');
+ plugins.push('dynamic-import-node');
+}
+
+module.exports = { presets, plugins };

View file

@ -31,3 +31,4 @@
0690-debian-usage-ping.patch 0690-debian-usage-ping.patch
0700-add-salsa-link-to-help.patch 0700-add-salsa-link-to-help.patch
0710-use-yarnpkg.patch 0710-use-yarnpkg.patch
0720-install-babelrc.js