From 69bbe09f0db9d158f8ef87a53eefb80653f48387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 10 Nov 2020 16:09:26 +0100 Subject: [PATCH 1/4] Test on Node.js 8.9 --- .github/workflows/ci.yml | 28 ++++++++++++++++ .gitignore | 1 + package.json | 2 +- scripts/test-legacy-source/input.js | 1 + scripts/test-legacy.js | 52 +++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 scripts/test-legacy-source/input.js create mode 100644 scripts/test-legacy.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5050973b..3655c8e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,3 +48,31 @@ jobs: if: ${{ matrix.coverage }} with: token: ${{ secrets.CODECOV_TOKEN }} + test-legacy: + name: Test - ubuntu-latest - Node v8.9, Webpack 4 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 14.x + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Install dependencies + run: yarn + env: + YARN_NODE_LINKER: node-modules + - name: Install webpack 4 + run: yarn add -D webpack@4 + env: + YARN_NODE_LINKER: node-modules + - name: Build babel-loader + run: yarn run build + env: + YARN_NODE_LINKER: node-modules + BABEL_ENV: test + - name: Use Node.js 8.9 + uses: actions/setup-node@v1 + with: + node-version: '8.9' + - name: Run tests for webpack version 4 + run: npm run test-only diff --git a/.gitignore b/.gitignore index ed7463b9..47579869 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ test/output !.yarn/releases .pnp.* .vscode +scripts/test-legacy-source/output diff --git a/package.json b/package.json index 55852079..456fa3c4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ ], "main": "lib/index.js", "engines": { - "node": ">= 6.9" + "node": ">= 8.9" }, "dependencies": { "find-cache-dir": "^2.1.0", diff --git a/scripts/test-legacy-source/input.js b/scripts/test-legacy-source/input.js new file mode 100644 index 00000000..c9ff7826 --- /dev/null +++ b/scripts/test-legacy-source/input.js @@ -0,0 +1 @@ +class App {} diff --git a/scripts/test-legacy.js b/scripts/test-legacy.js new file mode 100644 index 00000000..349b4df8 --- /dev/null +++ b/scripts/test-legacy.js @@ -0,0 +1,52 @@ +const webpack = require("webpack"); +const path = require("path"); +const fs = require("fs"); +const assert = require("assert"); + +const babelLoader = path.join(__dirname, "../lib"); + +const config = { + mode: "development", + entry: path.join(__dirname, "test-legacy-source/input.js"), + output: { + path: path.join(__dirname, "test-legacy-source/output"), + }, + module: { + rules: [ + { + test: /\.jsx?/, + loader: babelLoader, + options: { + presets: ["@babel/preset-env"], + }, + exclude: /node_modules/, + }, + ], + }, +}; + +webpack(config, (err, stats) => { + assert.strictEqual(err, null); + assert.deepStrictEqual(stats.compilation.errors, []); + assert.deepStrictEqual(stats.compilation.warnings, []); + + fs.readdir(path.join(__dirname, "test-legacy-source/output"), (err, files) => { + assert.strictEqual(err, null); + assert.strictEqual(files.length, 1); + fs.readFile(path.join(__dirname, "test-legacy-source/output", files[0]), (err, data) => { + assert.strictEqual(err, null); + const test = "var App = function App()"; + const subject = data.toString(); + + assert.notStrictEqual(subject.indexOf(test), -1); + + console.log("DONE"); + clearTimeout(timeout); + }); + }); +}); + +const timeout = setTimeout(() => { + console.error("TIMEOUT"); + process.exit(1); +}, 10 * 1000); From ec2bacc5fae48518138fe65148cf507c93e6acdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 10 Nov 2020 16:39:44 +0100 Subject: [PATCH 2/4] updates --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3655c8e5..23d76d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,8 @@ jobs: test-legacy: name: Test - ubuntu-latest - Node v8.9, Webpack 4 runs-on: ubuntu-latest + env: + YARN_NODE_LINKER: node-modules steps: - uses: actions/checkout@v2 - name: Use Node.js 14.x @@ -59,20 +61,15 @@ jobs: node-version: 14.x - name: Install dependencies run: yarn - env: - YARN_NODE_LINKER: node-modules - name: Install webpack 4 run: yarn add -D webpack@4 - env: - YARN_NODE_LINKER: node-modules - name: Build babel-loader run: yarn run build - env: - YARN_NODE_LINKER: node-modules BABEL_ENV: test - name: Use Node.js 8.9 uses: actions/setup-node@v1 with: node-version: '8.9' - name: Run tests for webpack version 4 - run: npm run test-only + run: node scripts/test-legacy + From d33856a0cd3131c114a292f9680be8d3df1bc88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 10 Nov 2020 16:48:21 +0100 Subject: [PATCH 3/4] Hey GH From 7121e2f10037942d7131dcfd7bb33a9af6c5188a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 10 Nov 2020 16:49:38 +0100 Subject: [PATCH 4/4] Fix yaml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23d76d9f..eec529ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,7 @@ jobs: run: yarn add -D webpack@4 - name: Build babel-loader run: yarn run build + env: BABEL_ENV: test - name: Use Node.js 8.9 uses: actions/setup-node@v1