diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..aa30792 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + name: Node.js ${{ matrix.node }} / Babel ${{ matrix.babel }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [6, 22, 24, 26] + babel: [7, 8] + exclude: + # Babel 8 requires Node.js 20+, so it cannot run on Node.js 6. + - node: 6 + babel: 8 + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies (Babel 7) + # --ignore-engines: dev-only tools such as eslint declare a newer + # minimum Node.js version, but they are not executed in this job + # (linting runs in its own job), so installing them on Node.js 6 is fine. + run: yarn install --frozen-lockfile --ignore-engines + + - name: Upgrade dev dependencies to Babel 8 + if: matrix.babel == 8 + run: >- + yarn add --dev + @babel/core@^8.0.0 + @babel/preset-env@^8.0.0 + + - name: Run tests + run: yarn test + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 26 + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Lint + run: yarn lint diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e155464..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - '12' - - '10' - - '8' - - '6' diff --git a/Gruntfile.js b/Gruntfile.js index 85f55f1..41c44c8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,10 @@ module.exports = function(grunt) { compile: { options: { sourceMap: true, - presets: ["@babel/preset-env"], + // Target an old environment so that the test fixture is actually + // transpiled (e.g. classes -> functions) regardless of the default + // targets, which differ between Babel 7 and Babel 8. + presets: [["@babel/preset-env", { targets: { ie: "11" } }]], }, files: { "test/tmp/fixture-compiled.js": "test/fixtures/fixture.js", diff --git a/README.md b/README.md index ba2e66f..869829c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -> This readme is for grunt-babel v8 + Babel v7 +> This readme is for grunt-babel v8 + Babel v7 or v8 > Check the [7.x branch](https://github.com/babel/grunt-babel/tree/7.x) for docs with Babel v6 -# grunt-babel [![Build Status](https://travis-ci.org/babel/grunt-babel.svg?branch=master)](https://travis-ci.org/babel/grunt-babel) +# grunt-babel [![CI](https://github.com/babel/grunt-babel/actions/workflows/test.yml/badge.svg)](https://github.com/babel/grunt-babel/actions/workflows/test.yml) > Use next generation JavaScript, today, with [Babel](https://babeljs.io) diff --git a/package.json b/package.json index ea0e95c..ff5f209 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "scripts": { "lint": "eslint .", "format": "eslint . --fix", - "test": "yarn lint && grunt" + "test": "grunt" }, "files": [ "tasks" @@ -34,7 +34,7 @@ "compiler" ], "peerDependencies": { - "@babel/core": "^7.0.0", + "@babel/core": "^7.0.0 || ^8.0.0", "grunt": ">=0.4.0" }, "devDependencies": { diff --git a/tasks/babel.js b/tasks/babel.js index cf6871c..f19551a 100644 --- a/tasks/babel.js +++ b/tasks/babel.js @@ -7,7 +7,7 @@ try { } catch (err) { if (err.code === "MODULE_NOT_FOUND") { err.message += - "\n grunt-babel@8 requires Babel 7.x (the package '@babel/core'). " + + "\n grunt-babel@8 requires Babel 7.x or 8.x (the package '@babel/core'). " + "If you'd like to use Babel 6.x ('babel-core'), you should install 'grunt-babel@7'."; } throw err;