Skip to content

Commit

Permalink
Update packages to reduce npm install warnings (closes DevExpress#769) (
Browse files Browse the repository at this point in the history
DevExpress#1203)

* Update packages to reduce npm install warnings (closes DevExpress#769)

* Disable regenerator for node>=4
  • Loading branch information
AndreyBelym authored and kirovboris committed Dec 18, 2019
1 parent b01a939 commit 946ef62
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@
"prepublish": "publish-please guard"
},
"dependencies": {
"babel-core": "^6.18.2",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2015-node4": "^2.1.0",
"babel-preset-stage-2": "^6.18.0",
"babel-runtime": "^6.18.0",
"babel-core": "^6.22.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.1.8",
"babel-preset-stage-2": "^6.22.0",
"babel-runtime": "^6.22.0",
"bin-v8-flags-filter": "^1.0.0",
"callsite": "^1.0.0",
"callsite-record": "^3.2.1",
Expand Down Expand Up @@ -104,7 +103,7 @@
"useragent": "^2.1.7"
},
"devDependencies": {
"babel-eslint": "^6.0.0",
"babel-eslint": "^7.1.1",
"babel-plugin-add-module-exports": "^0.2.0",
"basic-auth": "^1.1.0",
"broken-link-checker": "^0.7.0",
Expand All @@ -114,7 +113,7 @@
"del": "^2.2.0",
"dom-walk": "^0.1.1",
"error-stack-parser": "^1.3.3",
"eslint-plugin-babel": "^3.1.0",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-hammerhead": "0.0.6",
"eslint-plugin-import": "^1.14.0",
"express": "^4.13.3",
Expand All @@ -129,7 +128,7 @@
"gulp-if": "^2.0.0",
"gulp-less": "^3.0.3",
"gulp-ll": "^1.0.1",
"gulp-mocha": "^2.1.2",
"gulp-mocha": "^3.0.1",
"gulp-mustache": "^1.1.1",
"gulp-prompt": "^0.2.0",
"gulp-qunit-harness": "^0.1.10",
Expand Down
2 changes: 1 addition & 1 deletion src/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compact": false,
"presets": [
["es2015", { "loose": true }],
["env", { "loose": true }],
"babel-preset-stage-2"
],
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion src/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rules": {
"babel/arrow-parens": [2, "as-needed"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": [2, { "before": true, "after": true }],
"prefer-arrow-callback": 2
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compact": false,
"presets": [
["es2015", { "loose": true }]
["env", { "loose": true }]
],
"plugins": [
"add-module-exports"
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/es-next/compile-client-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ var babelArtifactPolyfills = {


function getBabelOptions () {
var { presetES2015Loose } = loadBabelLibs();
var { presetFallback } = loadBabelLibs();

return {
presets: [presetES2015Loose],
presets: [presetFallback],
sourceMaps: false,
retainLines: true,
ast: false,
Expand Down
7 changes: 2 additions & 5 deletions src/compiler/es-next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { readFileSync } from 'fs';
import stripBom from 'strip-bom';
import sourceMapSupport from 'source-map-support';
import loadBabelLibs from './load-babel-libs';
import NODE_VER from '../../utils/node-version';
import Globals from '../../api/globals';
import { TestCompilationError, APIError } from '../../errors/runtime';
import stackCleaningHook from '../../errors/stack-cleaning-hook';
Expand Down Expand Up @@ -32,9 +31,7 @@ export default class ESNextCompiler {
}

static _getBabelOptions (filename) {
var { presetStage2, transformRuntime, presetES2015Loose, presetES2015Node4 } = loadBabelLibs();

var presetES2015 = NODE_VER < 4 ? presetES2015Loose : presetES2015Node4;
var { presetStage2, transformRuntime, presetEnv } = loadBabelLibs();

// NOTE: passPrePreset and complex presets is a workaround for https://github.com/babel/babel/issues/2877
// Fixes https://github.com/DevExpress/testcafe/issues/969
Expand All @@ -44,7 +41,7 @@ export default class ESNextCompiler {
{ plugins: transformRuntime },
{
passPerPreset: false,
presets: [presetStage2, presetES2015]
presets: [presetStage2, presetEnv]
}
],
filename: filename,
Expand Down
24 changes: 17 additions & 7 deletions src/compiler/es-next/load-babel-libs.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import NODE_VER from '../../utils/node-version';

function getOptsForPresetEnv () {
var opts = { targets: { node: 'current' }, loose: true };

// NOTE: Disable transforming generators into state-machine for node>=4, because this versions have native generators.
// Also this versions have native template literals, regenerator do not work with them:
// https://github.com/facebook/regenerator/issues/276
if (NODE_VER >= 4)
opts.exclude = ['transform-regenerator'];

return opts;
}

// NOTE: lazy load heavy dependencies
export default function loadBabelLibs () {
return {
babel: require('babel-core'),
presetStage2: require('babel-preset-stage-2'),
transformRuntime: require('babel-plugin-transform-runtime'),
presetES2015Loose: require('babel-preset-es2015').buildPreset({ loose: true }),

// NOTE: we don't need this preset if we are on older versions of Node
presetES2015Node4: NODE_VER >= 4 ? require('babel-preset-es2015-node4') : null
babel: require('babel-core'),
presetStage2: require('babel-preset-stage-2'),
transformRuntime: require('babel-plugin-transform-runtime'),
presetFallback: require('babel-preset-env').default(null, { loose: true }),
presetEnv: require('babel-preset-env').default(null, getOptsForPresetEnv())
};
}
4 changes: 2 additions & 2 deletions test/server/data/client-fn-compilation/basic/expected.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
return (function () {
var _window$location = __get$(window, "location");
var hostname = __get$(_window$location, "hostname"),
var _window$location = __get$(window, "location"),
hostname = __get$(_window$location, "hostname"),
port = __get$(_window$location, "port");
return hostname + ':' + port;
});
Expand Down

0 comments on commit 946ef62

Please sign in to comment.