Skip to content

Commit

Permalink
chore: upgrade dependencies; add node 10; remove node 9 (#827)
Browse files Browse the repository at this point in the history
* chore: upgrade dependencies

* upgrade dependencies in all packages
* update yarn in ci
* babel generates `"use strict"` now in some places - update tests

* apply prettier

* remove node 9. add node 10

* babelrc to babel.config.js

* udpate configFile and set default sourceType to script

* cleanup test-transform sourceType logic

* try run circleci in node 8

* Revert "try run circleci in node 8"

This reverts commit 51e01a8.

* set smoke tests to script and no configfile
  • Loading branch information
boopathi committed May 1, 2018
1 parent 7b17646 commit b428527
Show file tree
Hide file tree
Showing 18 changed files with 848 additions and 513 deletions.
18 changes: 0 additions & 18 deletions .babelrc

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -5,12 +5,12 @@ language: node_js
cache: yarn

node_js:
- '9'
- '10'
- '8'
- '6'

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.5.1
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.6.0
- export PATH=$HOME/.yarn/bin:$PATH

before_script:
Expand All @@ -33,10 +33,10 @@ stages:
jobs:
include:
- stage: lint
node_js: '8'
node_js: '10'
script: yarn lint
- stage: publish
node_js: '8'
node_js: '10'
script: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
deploy:
provider: script
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -3,7 +3,7 @@ init:

environment:
matrix:
- nodejs_version: '9'
- nodejs_version: '10'
- nodejs_version: '8'
- nodejs_version: '6'

Expand All @@ -12,7 +12,7 @@ cache:

install:
- ps: Install-Product node $env:nodejs_version x64
- npm install -g yarn@1.5.1
- npm install -g yarn@1.6.0
- set PATH=%APPDATA%\npm;%PATH%
- yarn

Expand Down
19 changes: 19 additions & 0 deletions babel.config.js
@@ -0,0 +1,19 @@
/**
* Reason for Filename to be babel.config.js
*
* https://github.com/babel/babel/pull/7784
* https://github.com/facebook/jest/issues/6053#issuecomment-383632515
*/

module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: 6
}
}
]
]
};
38 changes: 19 additions & 19 deletions package.json
Expand Up @@ -6,7 +6,7 @@
"bootstrap": "lerna bootstrap",
"build": "gulp build",
"changelog": "lerna-changelog",
"clean": "lerna clean",
"clean": "rimraf packages/*/lib utils/*/lib",
"coverage": "yarn test --coverage",
"coverage-ci": "codecov -f coverage/coverage-final.json",
"fix": "eslint --fix .",
Expand All @@ -19,37 +19,37 @@
"watch": "gulp watch"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.40",
"@babel/plugin-transform-block-scoping": "^7.0.0-beta.40",
"@babel/preset-env": "^7.0.0-beta.40",
"@babel/core": "^7.0.0-beta.46",
"@babel/plugin-transform-block-scoping": "^7.0.0-beta.46",
"@babel/preset-env": "^7.0.0-beta.46",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.1",
"babel-jest": "^22.4.3",
"butternut": "^0.4.6",
"bytes": "^3.0.0",
"chalk": "^2.3.1",
"chalk": "^2.4.1",
"cli-table": "^0.3.1",
"closure-compiler": "^0.2.12",
"codecov": "^3.0.0",
"commander": "^2.14.1",
"eslint": "^4.18.1",
"codecov": "^3.0.1",
"commander": "^2.15.1",
"eslint": "^4.19.1",
"eslint-plugin-prettier": "^2.6.0",
"fancy-log": "^1.3.2",
"fs-readdir-recursive": "^1.1.0",
"google-closure-compiler-js": "^20180204.0.0",
"google-closure-compiler-js": "^20180402.0.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-babel": "^8.0.0-beta.1",
"gulp-babel": "^8.0.0-beta.2",
"gulp-newer": "^1.4.0",
"jest-cli": "^22.4.2",
"lerna": "^2.9.0",
"jest-cli": "^22.4.3",
"lerna": "^2.11.0",
"lerna-changelog": "^0.7.0",
"lint-staged": "^7.0.0",
"markdown-table": "^1.1.1",
"lint-staged": "^7.0.5",
"markdown-table": "^1.1.2",
"minimist": "^1.2.0",
"prettier": "^1.11.0",
"request": "^2.83.0",
"prettier": "^1.12.1",
"request": "^2.85.0",
"rimraf": "^2.6.2",
"through2": "^2.0.3",
"uglify-js": "^3.3.12",
"uglify-js": "^3.3.23",
"util.promisify": "^1.0.0"
},
"engines": {
Expand All @@ -58,7 +58,7 @@
},
"jest": {
"transform": {
".*": "<rootDir>/node_modules/babel-jest"
"^.+\\.js$": "babel-jest"
},
"testEnvironment": "node",
"testPathIgnorePatterns": [
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-minify/package.json
Expand Up @@ -18,11 +18,11 @@
},
"repository": "https://github.com/babel/minify/tree/master/packages/babel-minify",
"dependencies": {
"@babel/core": "^7.0.0-beta.40",
"@babel/core": "^7.0.0-beta.46",
"babel-preset-minify": "^0.4.0",
"fs-readdir-recursive": "^1.1.0",
"mkdirp": "^0.5.1",
"util.promisify": "^1.0.0",
"yargs-parser": "^9.0.2"
"yargs-parser": "^10.0.0"
}
}
7 changes: 5 additions & 2 deletions packages/babel-minify/src/index.js
Expand Up @@ -11,6 +11,7 @@ module.exports = function babelMinify(
minified = true,
inputSourceMap,
sourceMaps = false,
sourceType = "script",

// to override the default babelCore used
babel = babelCore,
Expand All @@ -19,12 +20,14 @@ module.exports = function babelMinify(
minifyPreset = babelPresetMinify
} = {}
) {
return babel.transform(input, {
return babel.transformSync(input, {
babelrc: false,
configFile: false,
presets: [[minifyPreset, options]],
comments: false,
inputSourceMap,
sourceMaps,
minified
minified,
sourceType
});
};
Expand Up @@ -7,8 +7,9 @@ const simplify = require("../../babel-plugin-minify-simplify/src/index");
const thePlugin = require("test-transform")(deadcode);

function transformWithSimplify(code) {
return babel.transform(code, {
plugins: [deadcode, simplify]
return babel.transformSync(code, {
plugins: [deadcode, simplify],
sourceType: "script"
}).code;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/babel-plugin-minify-mangle-names/src/index.js
Expand Up @@ -147,7 +147,10 @@ module.exports = babel => {
if (isLabelIdentifier(path)) {
return;
}
const { scope, node: { name } } = path;
const {
scope,
node: { name }
} = path;
const binding = scope.getBinding(name);
if (!binding) {
// Do not collect globals as they are already available via
Expand Down
Expand Up @@ -27,8 +27,9 @@ describe("type-constructors-plugin", () => {
`
);
expect(
babel.transform(source, {
plugins: [[plugin, { [names[i]]: false }]]
babel.transformSync(source, {
plugins: [[plugin, { [names[i]]: false }]],
sourceType: "script"
}).code
).toBe(source);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-preset-minify/__tests__/minify-env-tests.js
Expand Up @@ -54,6 +54,8 @@ describe("preset along with env", () => {
function a() {
return function a() {
"use strict";
_classCallCheck(this, a);
};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/gulp-babel-minify/__tests__/gulp-babili-test.js
Expand Up @@ -72,10 +72,10 @@ describe("gulp-babel-minify", () => {
const babel = Object.assign({}, babelCore);

let usedTransform = false;
Object.defineProperty(babel, "transform", {
Object.defineProperty(babel, "transformSync", {
get() {
usedTransform = true;
return babelCore.transform;
return babelCore.transformSync;
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/gulp-babel-minify/package.json
Expand Up @@ -13,7 +13,7 @@
"main": "lib/index.js",
"repository": "https://github.com/babel/minify/tree/master/packages/gulp-babel-minify",
"dependencies": {
"@babel/core": "7.0.0-beta.40",
"@babel/core": "7.0.0-beta.46",
"babel-preset-minify": "^0.4.0",
"plugin-error": "^1.0.1",
"through2": "^2.0.3",
Expand Down
7 changes: 5 additions & 2 deletions packages/gulp-babel-minify/src/index.js
Expand Up @@ -13,7 +13,8 @@ function gulpBabelMinify(
{
babel = babelCore,
minifyPreset = babelPresetMinify,
comments = /preserve|licen(s|c)e/
comments = /preserve|licen(s|c)e/,
sourceType = "script"
} = {}
) {
return through2.obj(function(file, enc, callback) {
Expand All @@ -35,6 +36,8 @@ function gulpBabelMinify(
babelrc: false,
ast: false,

sourceType,

/* preset */
presets: [[minifyPreset, minifyOpts]],

Expand Down Expand Up @@ -73,7 +76,7 @@ function transform({ babel, input, babelOpts }) {
try {
return {
success: true,
result: babel.transform(input, babelOpts)
result: babel.transformSync(input, babelOpts)
};
} catch (e) {
return {
Expand Down
4 changes: 3 additions & 1 deletion smoke/smoke-test.js
Expand Up @@ -119,8 +119,10 @@ class SmokeTest {
}

minify(contents) {
return babel.transform(contents, {
return babel.transformSync(contents, {
minified: true,
sourceType: "script",
configFile: false,
presets: [[minifyPreset, this.options.minifyOptions]]
});
}
Expand Down
18 changes: 14 additions & 4 deletions utils/test-runner/src/index.js
Expand Up @@ -58,9 +58,16 @@ function testRunner(dir) {
options = JSON.parse(await fs.readFile(optionsFile));
}

let babelOpts = {};
let babelOpts = {
// set the default sourcetype to be script
sourceType: "script"
};

if (await fs.isFile(babelOptionsFile)) {
babelOpts = JSON.parse(await fs.readFile(babelOptionsFile));
Object.assign(
babelOpts,
JSON.parse(await fs.readFile(babelOptionsFile))
);
}

const currentPlugin = pathJoin(pkgDir, "src/index.js");
Expand All @@ -71,9 +78,12 @@ function testRunner(dir) {
babelOpts.plugins = [[currentPlugin, options]];
}

const actualTransformed = babel.transform(actual, babelOpts).code;
// don't consider the project's babel.config.js
babelOpts.configFile = false;

const actualTransformed = babel.transformSync(actual, babelOpts).code;

if (!await fs.isFile(expectedFile)) {
if (!(await fs.isFile(expectedFile))) {
await fs.writeFile(expectedFile, actualTransformed);
console.warn("Created fixture's expected file - " + expectedFile);
} else if (updateFixtures) {
Expand Down

0 comments on commit b428527

Please sign in to comment.